Advertisement
Guest User

button click close window

a guest
Jun 11th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.66 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'window_process.ui'
  4. #
  5. # Created: Mon Jun 11 15:20:34 2012
  6. #      by: PyQt4 UI code generator 4.7.2
  7. #
  8. # WARNING! All changes made in this file will be lost!
  9.  
  10. from PyQt4 import QtCore, QtGui
  11. class sub_window(object):
  12.     def setupUi(self, Form):
  13.         Form.setObjectName("Form")
  14.         Form.resize(363, 188)
  15.         self.pushButton = QtGui.QPushButton(Form)
  16.         self.pushButton.setGeometry(QtCore.QRect(22, 120, 121, 31))
  17.         self.pushButton.setObjectName("pushButton")
  18.         self.pushButton_2 = QtGui.QPushButton(Form)
  19.         self.pushButton_2.setGeometry(QtCore.QRect(240, 120, 93, 31))
  20.         self.pushButton_2.setObjectName("pushButton_2")
  21.         self.label = QtGui.QLabel(Form)
  22.         self.label.setGeometry(QtCore.QRect(140, 50, 141, 31))
  23.         self.label.setObjectName("label")
  24.  
  25.         self.retranslateUi(Form)
  26.         QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL("clicked()"), Form.close)
  27.         QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.dosumfuction)
  28.         QtCore.QMetaObject.connectSlotsByName(Form)
  29.  
  30.     def dosumfuction(self):
  31.         print "Doing sum fuction"
  32.         print "Function finished"
  33.         print "But window did not close How to close sub window"
  34.        
  35.        
  36.     def retranslateUi(self, Form):
  37.         Form.setWindowTitle(QtGui.QApplication.translate("Form", "subwindow", None, QtGui.QApplication.UnicodeUTF8))
  38.         self.pushButton.setText(QtGui.QApplication.translate("Form", "Do sum function", None, QtGui.QApplication.UnicodeUTF8))
  39.         self.pushButton_2.setText(QtGui.QApplication.translate("Form", "Quit", None, QtGui.QApplication.UnicodeUTF8))
  40.         self.label.setText(QtGui.QApplication.translate("Form", "subwindow", None, QtGui.QApplication.UnicodeUTF8))
  41.  
  42.  
  43. class Ui_Form(object):
  44.     def setupUi(self, Form):
  45.         Form.setObjectName("Form")
  46.         Form.resize(407, 258)
  47.         self.pushButton = QtGui.QPushButton(Form)
  48.         self.pushButton.setGeometry(QtCore.QRect(40, 170, 131, 31))
  49.         self.pushButton.setObjectName("pushButton")
  50.         self.pushButton_2 = QtGui.QPushButton(Form)
  51.         self.pushButton_2.setGeometry(QtCore.QRect(300, 170, 93, 31))
  52.         self.pushButton_2.setObjectName("pushButton_2")
  53.         self.label = QtGui.QLabel(Form)
  54.         self.label.setGeometry(QtCore.QRect(140, 60, 171, 51))
  55.         self.label.setObjectName("label")
  56.  
  57.         self.retranslateUi(Form)
  58.         QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL("clicked()"), Form.close)
  59.         QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.opensubwindow)
  60.         QtCore.QMetaObject.connectSlotsByName(Form)
  61.    
  62.     def opensubwindow(self):
  63.         print "Subwindow starts"
  64.         self.Form = QtGui.QWidget()
  65.         self.sub_window1 = sub_window()
  66.         self.sub_window1.setupUi(self.Form)
  67.         self.Form.show()
  68.        
  69.        
  70.     def retranslateUi(self, Form):
  71.         Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
  72.         self.pushButton.setText(QtGui.QApplication.translate("Form", "Open New Window", None, QtGui.QApplication.UnicodeUTF8))
  73.         self.pushButton_2.setText(QtGui.QApplication.translate("Form", "close", None, QtGui.QApplication.UnicodeUTF8))
  74.         self.label.setText(QtGui.QApplication.translate("Form", "Main Window", None, QtGui.QApplication.UnicodeUTF8))
  75.  
  76.  
  77. if __name__ == "__main__":
  78.     import sys
  79.     app = QtGui.QApplication(sys.argv)
  80.     Form = QtGui.QWidget()
  81.     ui = Ui_Form()
  82.     ui.setupUi(Form)
  83.     Form.show()
  84.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement