vitorlobo
9th February 2012, 02:23
Hi Guys!
I'm hours trying to solve this code .... how do I close the first by window the X title bar button...popup and close together?
Obs: (I'm using PyQt4)
http://s14.postimage.org/wf1m8alxb/close.png
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class Mainw(object):
def __init__(self, MainWindow):
super(Mainw, self).__init__()
self.cw = QWidget(MainWindow)
self.btn1 = QPushButton("Popup", self.cw)
MainWindow.setCentralWidget(self.cw)
self.btn1.setGeometry(QRect(0, 0, 100, 30))
QObject.connect(self.btn1, SIGNAL("clicked()"), self.openpopup)
def openpopup(self):
self.pop = QWidget()
self.pop.setGeometry(QRect(100, 100, 400, 200))
self.pop.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
MainWindow = QMainWindow()
main = Mainw(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
I'm hours trying to solve this code .... how do I close the first by window the X title bar button...popup and close together?
Obs: (I'm using PyQt4)
http://s14.postimage.org/wf1m8alxb/close.png
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class Mainw(object):
def __init__(self, MainWindow):
super(Mainw, self).__init__()
self.cw = QWidget(MainWindow)
self.btn1 = QPushButton("Popup", self.cw)
MainWindow.setCentralWidget(self.cw)
self.btn1.setGeometry(QRect(0, 0, 100, 30))
QObject.connect(self.btn1, SIGNAL("clicked()"), self.openpopup)
def openpopup(self):
self.pop = QWidget()
self.pop.setGeometry(QRect(100, 100, 400, 200))
self.pop.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
MainWindow = QMainWindow()
main = Mainw(MainWindow)
MainWindow.show()
sys.exit(app.exec_())