サブウィンドウ作成
2014/12/14
Python2.7.6, pyQt4.11
#-*- coding:utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui
class MainWindow:
def __init__(self):
self.w = QtGui.QWidget()
btn = QtGui.QPushButton(self.w)
btn.setText('Click Here!')
QtCore.QObject.connect(btn,QtCore.SIGNAL('clicked()'),self.onClicked)
self.sub = SubWindow(self.w)
def show(self):
self.w.show()
def onClicked(self):
self.sub.show()
class SubWindow:
def __init__(self,parent=None):
self.w = QtGui.QDialog(parent)
label = QtGui.QLabel(self.w)
label.setText('Sub Window!')
def show(self):
self.w.exec_()
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
PyQT on click open new window
http://stackoverflow.com/questions/14410152/pyqt-on-click-open-new-window