Advertisement
Guest User

Untitled

a guest
Jun 11th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 Ui_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.QMetaObject.connectSlotsByName(Form)
  27.  
  28.     def retranslateUi(self, Form):
  29.         Form.setWindowTitle(QtGui.QApplication.translate("Form", "subwindow", None, QtGui.QApplication.UnicodeUTF8))
  30.         self.pushButton.setText(QtGui.QApplication.translate("Form", "Do sum function", None, QtGui.QApplication.UnicodeUTF8))
  31.         self.pushButton_2.setText(QtGui.QApplication.translate("Form", "Quit", None, QtGui.QApplication.UnicodeUTF8))
  32.         self.label.setText(QtGui.QApplication.translate("Form", "subwindow", None, QtGui.QApplication.UnicodeUTF8))
  33.  
  34.  
  35. class Ui_Form(object):
  36.     def setupUi(self, Form):
  37.         Form.setObjectName("Form")
  38.         Form.resize(407, 258)
  39.         self.pushButton = QtGui.QPushButton(Form)
  40.         self.pushButton.setGeometry(QtCore.QRect(40, 170, 131, 31))
  41.         self.pushButton.setObjectName("pushButton")
  42.         self.pushButton_2 = QtGui.QPushButton(Form)
  43.         self.pushButton_2.setGeometry(QtCore.QRect(300, 170, 93, 31))
  44.         self.pushButton_2.setObjectName("pushButton_2")
  45.         self.label = QtGui.QLabel(Form)
  46.         self.label.setGeometry(QtCore.QRect(140, 60, 171, 51))
  47.         self.label.setObjectName("label")
  48.  
  49.         self.retranslateUi(Form)
  50.         QtCore.QMetaObject.connectSlotsByName(Form)
  51.    
  52.     def retranslateUi(self, Form):
  53.         Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
  54.         self.pushButton.setText(QtGui.QApplication.translate("Form", "Open New Window", None, QtGui.QApplication.UnicodeUTF8))
  55.         self.pushButton_2.setText(QtGui.QApplication.translate("Form", "close", None, QtGui.QApplication.UnicodeUTF8))
  56.         self.label.setText(QtGui.QApplication.translate("Form", "Main Window", None, QtGui.QApplication.UnicodeUTF8))
  57.  
  58. class window(QtGui.QWidget):
  59.  
  60.     def __init__(self, parent = None):
  61.         QtGui.QWidget.__init__(self, parent)
  62.         ui = Ui_Form()
  63.         ui.setupUi(self)
  64.        
  65.         QtCore.QObject.connect(ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.close)
  66.         QtCore.QObject.connect(ui.pushButton, QtCore.SIGNAL("clicked()"), self.opensubwindow)
  67.        
  68.     def opensubwindow(self):
  69.         print "Subwindow starts"
  70.         self.Form = sub_window()
  71.         self.Form.show()
  72.  
  73. class sub_window(QtGui.QWidget):
  74.  
  75.     def __init__(self, parent = None):
  76.         QtGui.QWidget.__init__(self, parent)
  77.         ui = Ui_sub_window()
  78.         ui.setupUi(self)
  79.        
  80.         QtCore.QObject.connect(ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.close)
  81.         QtCore.QObject.connect(ui.pushButton, QtCore.SIGNAL("clicked()"), self.dosumfuction)
  82.    
  83.     def dosumfuction(self):
  84.         print "Doing sum fuction"
  85.         print "Function finished"
  86.         print "But window did not close How to close sub window"
  87.         self.close()
  88.  
  89. if __name__ == "__main__":
  90.     import sys
  91.     app = QtGui.QApplication(sys.argv)
  92.     Form = window()
  93.     Form.show()
  94.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement