More Dialogs → ImageBrowser | ScrolledMessag..
时间:2007-04-12 来源:wxPhoenix
import wx
import wx.lib.imagebrowser
import wx.lib.dialogs
import os
class Frame(wx.Frame):
def __init__(
self, parent, id=-1, title='More Dialog', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
Panel = wx.Panel(self, -1)
MenuBar = wx.MenuBar() # MenuBar = wx.MenuBar(self)???
FileMenu = wx.Menu()
MenuItem = FileMenu.Append(-1, 'Exit')
self.Bind(wx.EVT_MENU, self.OnExit, MenuItem)
TestMenu = wx.Menu()
MenuItem = TestMenu.Append(-1, 'ImageBrowser')
self.Bind(wx.EVT_MENU, self.OnImageBrowser, MenuItem)
MenuItem = TestMenu.Append(-1, 'ScrolledMessageDialog')
self.Bind(wx.EVT_MENU, self.OnScrolledMessageDialog, MenuItem)
MenuBar.Append(FileMenu, '&File')
MenuBar.Append(TestMenu, '&Test')
self.SetMenuBar(MenuBar)
def OnExit(self, event):
self.Close()
def OnImageBrowser(self, event):
DefaultDir = os.path.join(os.getcwd(), 'iamges')
ImageDialog = wx.lib.imagebrowser.ImageDialog(self, DefaultDir)
ImageDialog.Centre()
if ImageDialog.ShowModal() == wx.ID_OK:
wx.MessageBox('You Select %s' % ImageDialog.GetFile(), 'Prompt')
ImageDialog.Destroy()
def OnScrolledMessageDialog(self, event):
File = open('Main.py', 'r')
Msg = File.read()
File.close()
MsgDialog = wx.lib.dialogs.ScrolledMessageDialog(parent=self, msg=Msg,
caption='ScrolledMessageDialog')
MsgDialog.ShowModal()
MsgDialog.Destroy()
def TestFrame():
app = wx.PySimpleApp()
frame = Frame(parent=None)
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
import wx.lib.imagebrowser
import wx.lib.dialogs
import os
class Frame(wx.Frame):
def __init__(
self, parent, id=-1, title='More Dialog', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
Panel = wx.Panel(self, -1)
MenuBar = wx.MenuBar() # MenuBar = wx.MenuBar(self)???
FileMenu = wx.Menu()
MenuItem = FileMenu.Append(-1, 'Exit')
self.Bind(wx.EVT_MENU, self.OnExit, MenuItem)
TestMenu = wx.Menu()
MenuItem = TestMenu.Append(-1, 'ImageBrowser')
self.Bind(wx.EVT_MENU, self.OnImageBrowser, MenuItem)
MenuItem = TestMenu.Append(-1, 'ScrolledMessageDialog')
self.Bind(wx.EVT_MENU, self.OnScrolledMessageDialog, MenuItem)
MenuBar.Append(FileMenu, '&File')
MenuBar.Append(TestMenu, '&Test')
self.SetMenuBar(MenuBar)
def OnExit(self, event):
self.Close()
def OnImageBrowser(self, event):
DefaultDir = os.path.join(os.getcwd(), 'iamges')
ImageDialog = wx.lib.imagebrowser.ImageDialog(self, DefaultDir)
ImageDialog.Centre()
if ImageDialog.ShowModal() == wx.ID_OK:
wx.MessageBox('You Select %s' % ImageDialog.GetFile(), 'Prompt')
ImageDialog.Destroy()
def OnScrolledMessageDialog(self, event):
File = open('Main.py', 'r')
Msg = File.read()
File.close()
MsgDialog = wx.lib.dialogs.ScrolledMessageDialog(parent=self, msg=Msg,
caption='ScrolledMessageDialog')
MsgDialog.ShowModal()
MsgDialog.Destroy()
def TestFrame():
app = wx.PySimpleApp()
frame = Frame(parent=None)
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
相关阅读 更多 +