import sys
from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QPixmap
import pityna
import responder
#class MainWindow(QtWidgets.QMainWindow):
class MainWindow():
def __init__(self):
#super().__init__()
self.pityna=pityna.Pityna('pityna')
self.action=True
#self.ui = uic.loadUi("../../qt_Pityna_Simple.ui")
self.ui = uic.loadUi("qt_Pityna_Simple.ui")
self.ui.label_2.setPixmap(QPixmap("img1.gif"))
self.slotSetting()
self.ui.show()
def slotSetting(self):
self.ui.buttonTalk.clicked.connect(self.buttonTalkSlot)
self.ui.radioButton.clicked.connect(self.showResponderName)
self.ui.radioButton_2.clicked.connect(self.HideResponderName)
self.ui.menuClose.triggered.connect(self.close)
def putlog(self,str):
self.ui.listWidgetLog.addItem(str)
def prompt(self):
p=self.pityna.get_name()
if self.action==True:
p+=':'+self.pityna.get_responder_name()
return p+'> '
def buttonTalkSlot(self):
print("buttonTalkSlot")
value= self.ui.lineEdit.text()
if not value:
self.ui.labelResponce.setText('なに?')
else:
responce=self.pityna.dialogue(value)
self.ui.labelResponce.setText(responce)
self.putlog('> '+value)
self.putlog(self.prompt() + responce)
self.ui.lineEdit.clear()
def showResponderName(self):
print("showResponderName")
self.action=True
def HideResponderName(self):
print("HideResponderName")
self.action=False
def close(self):
replay = QtWidgets.QMessageBox.question(
self.ui,
'確認',
'プログラムを終了しますか?',
buttons=QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No
)
if replay==QtWidgets.QMessageBox.Yes:
#event.accept()
self.ui.close()
else:
#event.ignore()
pass
app = QtWidgets.QApplication(sys.argv)
MainWindow=MainWindow()
ret=app.exec()
sys.exit(ret)
https://www.mediafire.com/file/zaecgqbqjx878er/Ch5_01.zip/file
https://www.mediafire.com/file/si4atzrh6uatidf/Ch6_31templateDict.zip/file
コメント