PyQt5 when I click button it close window itself

+2 votes

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
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):

    def initSignal(self):

    def inputAdinfo(self):
        self.ad_productN = self.lineEdit.text()
        self.ad_camN = self.lineEdit_2.text()
        print(self.ad_productN, self.ad_camN)

    def inputKeyword(self):
        self.Keywords = self.plainTextEdit.text()

# print(self.ad_productN, self.ad_camN , self.Keywords)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Main()

this is my code.

i tested it with 


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()

as soon as I click the button, it close itself.

how can i fix this?

Dec 9, 2019 in Python by 의철
• 140 points
If you run it from the terminal or cmd it will show an error which will give a clue as to where the problem is

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
0 answers

I am trying to click the button but it is not working and it is drop list ..

<a class="quickreports btn btn3d tbbtn" href="javascript:" style="position:static" ...READ MORE

Dec 1, 2019 in Python by anonymous
• 120 points
+1 vote
0 answers

How to close a window, and then reinitialize it using PyQt

There is a button "btn_closeWin_and_reinit"  in the ...READ MORE

Jul 10, 2019 in Python by marceepoo
• 130 points

edited Jul 22, 2019 by Kalgi 5,183 views
0 votes
0 answers

For some reason i cannot click on this element/button and have been trying for hours PLEASE HELP!!

from selenium import webdriver from import Options from ...READ MORE

Jun 18, 2020 in Python by Justin
• 140 points

reshown Jun 18, 2020 by Sirajul 198 views
0 votes
1 answer

How do I call a Django function on button click?

Hello @kartik, There are 2 possible solutions that ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,780 points
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,780 points
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,259 views
0 votes
0 answers