Problems with Open-Source Downloads read and

Why click on button opens new PyQt window ?

  • Hey guys, i have 3 pyhon files that cooperate and my problem is when i click button that should change text in textbox it also open new window. What is causing it here ? I dont get it


    from PyQt5 import QtWidgets
    import sys
    from PyQt5.QtWidgets import QMainWindow, QApplication, QLineEdit
    class Window(QMainWindow):
       def __init__(self):
           self.textboxvalue2 = ""
           self.setGeometry(200, 200, 259, 258)
           self.textbox = QLineEdit(self)
           self.textbox.move(5, 5)
           self.textbox.resize(188, 35)
           self.textbox.setPlaceholderText("Enter numbers")
           self.textboxValue = self.textbox.text()
           self.b10 = QtWidgets.QPushButton(self)
           self.b10.move(68, 219)
           self.b10.resize(60, 35)
       def setExpression(self,expression):
       def clicked0(self):
           import Buttons
           z = Buttons.Button()
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = Window()


    from kkts import abstract
    class Button(abstract):
        def kkt(self):


    import test
    from abc import ABC, abstractmethod
    x = test.Window()
    class abstract:
        def buttonSent(self,number):
            global x

  • Lifetime Qt Champion


    Why are you doing all this convoluted abstract class ?

    Just do the update in your clicked0 method.

    As for your issue, you are creating two MainWindow. One in your main method and the other in your file.

    They are both shown because you call show in your class constructor (which is wrong, it's the code that creates the widget that should decide when to show it).

  • Hello @SGaist Thank you for you helpfull reply, i already made changes you mentioned and it is working fine, Thank you a lot!

  • But if i can have one more question, i removed constructor from and i made it normal function and i call this function in if name == "main": And when i do it by this way, textbox again not changing text.... When i have contructor it is working fine, but when i remove construcot and make it function it is not responding

  • @Samuel-Bachorik
    Why not show whatever it is you have now so we can see & understand?

Log in to reply