Displaying 2nd Window Issue

后端 未结 1 1170
不思量自难忘°
不思量自难忘° 2021-01-27 00:31

I am dealing with 2 windows . One is created by Qt Designer and i import it on test.py program . what i did i make a Widget on the test program and than add a button to it and o

相关标签:
1条回答
  • 2021-01-27 01:06

    The reason the other window doesn't appear, is because you are not keeping a reference to it, and so it gets garbage-collected immediately after it is shown.

    To fix the problem, you could either store the window instance it as an attribute, or give it a parent:

    def local_manag(self):
        print "pressed"
        # store it as an attribute
        self.myapp2 = MyForm()
        self.myapp2.show()
        # or give it a parent
        # myapp2 = MyForm(self)
        # myapp2.show()
    
    0 讨论(0)
提交回复
热议问题