PyQt5, when I click button, it close window itself.
Hi, I am very new to PyQt5. if this it too basic question.
please give me some howtouse url. so I can learn my self.
import sys, io
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import uic
from tag_test import Ui_MainWindow
import pymysql
pymysql.install_as_MySQLdb()
import MySQLdb
from sqlalchemy import create_engine
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
class Main(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.initSignal()
def initSignal(self):
self.pushButton_7.clicked.connect(self.inputAdinfo)
self.pushButton_8.clicked.connect(self.inputKeyword)
@pyqtSlot()
def inputAdinfo(self):
self.ad_productN = self.lineEdit.text()
self.ad_camN = self.lineEdit_2.text()
print(self.ad_productN, self.ad_camN)
@pyqtSlot()
def inputKeyword(self):
self.Keywords = self.plainTextEdit.text()
print(self.Keywords)
# print(self.ad_productN, self.ad_camN , self.Keywords)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Main()
window.show()
app.exec_()
this is my code.
i tested it with
print('test')
at both of pyqtSlot and it worked fine.
so I thought signal and slot are connected.
but when i put second def
def inputKeyword(self):
self.Keywords = self.plainTextEdit.text()
print(self.Keywords)
as soon as I click the button, it close itself.
how can i fix this?