各个窗口的应用




import wx
class MDIFrame(wx.MDIParentFrame):
    def __init__(self):
        wx.MDIParentFrame.__init__(self,None,-1,'mdi',size = (200,300))
        menubar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(1000,'new')
        menu.Append(1001,'quit')
        menubar.Append(menu,'file')
        self.SetMenuBar(menubar)
        self.Bind(wx.EVT_MENU, self.OnNew, id = 1000)
        self.Bind(wx.EVT_MENU, self.OnQuit,id = 1001)
    def OnNew(self,event):
        win = wx.MDIChildFrame(self,-1,'child',size = (100,300))
        panel = wx.Panel(self,-1)
        button = wx.Button(pane,-1,'open',pos = (0,0),size = (30,50))
        win.Show()
    def OnQuit(self,event):
        self.Close(True)
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MDIFrame()
    frame.Show()
    app.MainLoop()


#-*- coding:utf-8 -*-
import wx
import os   


from wx.tools.Editra.src.ed_main import OnAbout
from wx import ID_OPEN
class MniFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,'mini',pos = (100,100),size = (400,300),style = wx.DEFAULT_FRAME_STYLE | wx.CLOSE_BOX)
        pannel = wx.Panel(self,-1,size = (200,300))
        menubar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(1001,'about')
        menubar.Append(menu,'help(&h)')
        self.SetMenuBar(menubar)
        self.Bind(wx.EVT_MENU, self.OnAbout, id=1001)
        btn  = wx.Button(pannel,-1,'MessageDialog',pos = (20,20),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnMessageDialog,btn)
        btn1  = wx.Button(pannel,-1,'MessageDialog',pos = (20,60),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnTextInput,btn1)
        btn2  = wx.Button(pannel,-1,'MessageDialog',pos = (20,100),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnOpen,btn2)
        
    def OnOpen(self,event):
        filter = "Paint files(*.py)|*.py|All files(*.*)|*.*"
        #dlg = wx.FileDialog(self,"Save paint as ...",  os.getcwd(),  style = wx.SAVE | wx.OVERWRITE_PROMPT,  wildcard = filter)
        dlg = wx.FileDialog(self,u"打开文件",  os.getcwd(),    style = wx.OPEN,  wildcard = filter)
        if dlg.ShowModal()==wx.ID_OK:
            print 'path = ' +dlg.GetPath()
            
        dlg.Destroy()
    def OnMessageDialog(self,event):  #提示对话框例子
        dlg  = wx.MessageDialog(self,u'是否退出',u"quit",wx.YES_NO|wx.ICON_QUESTION)
        if dlg.ShowModal() == wx.ID_YES:
            print 'quit'
        dlg.Destroy()
    def OnTextInput(self,event):    #文本输入对话框的输入例子
        dlg = wx.TextEntryDialog(self,u"请输入文本",u"文本框",'',style = wx.OK|wx.CANCEL)
        if dlg.ShowModal() == wx.ID_OK:
            print '--:'+dlg.GetValue()
        dlg.Destroy()
        
    def OnAbout(self,e):
        MyDialog(self,'test').Show()
class MyDialog(wx.Dialog):
    def __init__(self,parant,title):
        wx.Dialog.__init__(self,parant,-1,title,size = (100,100))
        self.panel = wx.Panel(self,-1)
        self.button = wx.Button(self.panel,1002,'OK',pos = (10,10),size = (50,30))
        self.Bind(wx.EVT_BUTTON,self.OnClose,self.button)
        self.Show()
    def OnClose(self,e):  #不要有自己调用自己的方法
        print '=='
        self.Close(True)


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MniFrame()
    frame.Show()
    app.MainLoop()

#-*- coding:utf-8 -*-
import wx
import os   


from wx.tools.Editra.src.ed_main import OnAbout
from wx import ID_OPEN
class MniFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,'mini',pos = (100,100),size = (400,300),style = wx.DEFAULT_FRAME_STYLE | wx.CLOSE_BOX)
        pannel = wx.Panel(self,-1,size = (200,300))
        menubar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(1001,'about')
        menubar.Append(menu,'help(&h)')
        self.SetMenuBar(menubar)
        self.Bind(wx.EVT_MENU, self.OnAbout, id=1001)
        btn  = wx.Button(pannel,-1,'MessageDialog',pos = (20,20),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnMessageDialog,btn)
        btn1  = wx.Button(pannel,-1,'MessageDialog',pos = (20,60),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnTextInput,btn1)
        btn2  = wx.Button(pannel,-1,'MessageDialog',pos = (20,100),size = (100,30))
        self.Bind(wx.EVT_BUTTON,self.OnOpen,btn2)
        
    def OnOpen(self,event):
        filter = "Paint files(*.py)|*.py|All files(*.*)|*.*"
        #dlg = wx.FileDialog(self,"Save paint as ...",  os.getcwd(),  style = wx.SAVE | wx.OVERWRITE_PROMPT,  wildcard = filter)
        dlg = wx.FileDialog(self,u"打开文件",  os.getcwd(),    style = wx.OPEN,  wildcard = filter)
        if dlg.ShowModal()==wx.ID_OK:
            print 'path = ' +dlg.GetPath()
            
        dlg.Destroy()
    def OnMessageDialog(self,event):  #提示对话框例子
        dlg  = wx.MessageDialog(self,u'是否退出',u"quit",wx.YES_NO|wx.ICON_QUESTION)
        if dlg.ShowModal() == wx.ID_YES:
            print 'quit'
        dlg.Destroy()
    def OnTextInput(self,event):    #文本输入对话框的输入例子
        dlg = wx.TextEntryDialog(self,u"请输入文本",u"文本框",'',style = wx.OK|wx.CANCEL)
        if dlg.ShowModal() == wx.ID_OK:
            print '--:'+dlg.GetValue()
        dlg.Destroy()
        
    def OnAbout(self,e):
        MyDialog(self,'test').Show()
class MyDialog(wx.Dialog):
    def __init__(self,parant,title):
        wx.Dialog.__init__(self,parant,-1,title,size = (100,100))
        self.panel = wx.Panel(self,-1)
        self.button = wx.Button(self.panel,1002,'OK',pos = (10,10),size = (50,30))
        self.Bind(wx.EVT_BUTTON,self.OnClose,self.button)
        self.Show()
    def OnClose(self,e):  #不要有自己调用自己的方法
        print '=='
        self.Close(True)


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MniFrame()
    frame.Show()
    app.MainLoop()




                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Car12

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值