# -*- coding: utf-8 -*-
import sys
import wx
from PyQt4 import QtGui,QtCore
import ui # pyQt UI
# wxPython Dialog
class Form(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self,None,-1,title="My first PyQt Demo",pos=wx.DefaultPosition)
btn = wx.Button(self,-1,"Click Me",size=(100,-1))
self.Bind(wx.EVT_BUTTON,self.OnClick,btn)
def OnClick(self,EVT):
# 必须是成员变量 self.qf 不能是qf ,否则除了函数
# 作用域,该变量就销毁,窗体一闪而过
self.qf = QtForm()
self.qf.show()
# pyQt Dialog
class QtForm(QtGui.QDialog):
def __init__(self):
QtGui.QWidget.__init__(self,None)
self.ui = ui.Ui_Dialog()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.pushButton,QtCore.SIGNAL("clicked()"),self.OnClick)
def OnClick(self):
wx.MessageBox("Clicked me")
if __name__=="__main__":
qt = QtGui.QApplication(sys.argv)
app = wx.App()
form = Form()
form.Show()
app.MainLoop()
# sys.exit(qt.exec_())