def __init__(self, redirect=False, filename=None):
wx.App.__init__(self, redirect, filename)
BASEURL = "http://127.0.0.1:8000"
self.InitUpdates(BASEURL,
BASEURL + "/" + 'ChangeLog.txt')
self.SetAppDisplayName('Image Viewer')
self.CheckForUpdate()
self.frame = wx.Frame(None, title='Photo Control')
self.panel = wx.Panel(self.frame)
self.PhotoMaxSize = 500
self.createWidgets()
self.frame.Show()
python类Frame()的实例源码
def __init__(self):
wx.Frame.__init__(self, None, title="Timer Tutorial 2")
panel = wx.Panel(self, wx.ID_ANY)
self.timer = wx.Timer(self, id=TIMER_ID1)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
self.timer2 = wx.Timer(self, id=TIMER_ID2)
self.Bind(wx.EVT_TIMER, self.update, self.timer2)
self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start Timer 1")
self.toggleBtn.Bind(wx.EVT_BUTTON, self.onStartTimerOne)
self.toggleBtn2 = wx.Button(panel, wx.ID_ANY, "Start Timer 2")
self.toggleBtn2.Bind(wx.EVT_BUTTON, self.onStartTimerOne)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.toggleBtn, 0, wx.ALL|wx.CENTER, 5)
sizer.Add(self.toggleBtn2, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
def __init__(self):
wx.Frame.__init__(self, None, title="wxPython Redirect Tutorial")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
log = wx.TextCtrl(panel, wx.ID_ANY, size=(300,100),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
btn = wx.Button(panel, wx.ID_ANY, 'Push me!')
self.Bind(wx.EVT_BUTTON, self.onButton, btn)
# Add widgets to a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(log, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
# redirect text here
redir = RedirectText(log)
sys.stdout = redir
main_non_thread_safe_phoenix.py 文件源码
项目:wxpythoncookbookcode
作者: driscollis
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self):
wx.Frame.__init__(self, None,
title="wxPython Redirect Tutorial")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL
log = MyCustomTextCtrl(panel, wx.ID_ANY, size=(300,100),
style=style)
btn = wx.Button(panel, wx.ID_ANY, 'Push me!')
self.Bind(wx.EVT_BUTTON, self.onButton, btn)
# Add widgets to a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(log, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
# redirect text here
sys.stdout = log
def __init__(self):
wx.Frame.__init__(self, None,
title="wxPython Redirect Tutorial")
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL
log = wx.TextCtrl(panel, wx.ID_ANY, size=(300,100),
style=style)
btn = wx.Button(panel, wx.ID_ANY, 'Push me!')
self.Bind(wx.EVT_BUTTON, self.onButton, btn)
# Add widgets to a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(log, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
# redirect text here
sys.stdout = log
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY,
'It Looks Like a Line Graph!')
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
# create some sizers
mainSizer = wx.BoxSizer(wx.VERTICAL)
checkSizer = wx.BoxSizer(wx.HORIZONTAL)
# create the widgets
self.canvas = PlotCanvas(panel)
self.canvas.Draw(drawLinePlot())
toggleGrid = wx.CheckBox(panel, label="Show Grid")
toggleGrid.Bind(wx.EVT_CHECKBOX, self.onToggleGrid)
toggleLegend = wx.CheckBox(panel, label="Show Legend")
toggleLegend.Bind(wx.EVT_CHECKBOX, self.onToggleLegend)
# layout the widgets
mainSizer.Add(self.canvas, 1, wx.EXPAND)
checkSizer.Add(toggleGrid, 0, wx.ALL, 5)
checkSizer.Add(toggleLegend, 0, wx.ALL, 5)
mainSizer.Add(checkSizer)
panel.SetSizer(mainSizer)
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY,
'Sin / Cos Plot')
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
# create some sizers
mainSizer = wx.BoxSizer(wx.VERTICAL)
checkSizer = wx.BoxSizer(wx.HORIZONTAL)
# create the widgets
self.canvas = PlotCanvas(panel)
self.canvas.Draw(drawSinCosWaves())
toggleGrid = wx.CheckBox(panel, label="Show Grid")
toggleGrid.Bind(wx.EVT_CHECKBOX, self.onToggleGrid)
toggleLegend = wx.CheckBox(panel, label="Show Legend")
toggleLegend.Bind(wx.EVT_CHECKBOX, self.onToggleLegend)
# layout the widgets
mainSizer.Add(self.canvas, 1, wx.EXPAND)
checkSizer.Add(toggleGrid, 0, wx.ALL, 5)
checkSizer.Add(toggleLegend, 0, wx.ALL, 5)
mainSizer.Add(checkSizer)
panel.SetSizer(mainSizer)
def __init__(self, parent):
wx.Frame.__init__(self, parent, wx.ID_ANY, title="About", size=(400,400))
html = wxHTML(self)
html.SetPage(
''
"<h2>About the About Tutorial</h2>"
"<p>This about box is for demo purposes only. It was created in June 2006"
"by Mike Driscoll.</p>"
"<p><b>Software used in making this demo:</h3></p>"
'<p><b><a href="http://www.python.org">Python 2.4</a></b></p>'
'<p><b><a href="http://www.wxpython.org">wxPython 2.8</a></b></p>'
)
def OnInit(self):
"""
Run automatically when the wxPython application starts.
"""
self.frame = wx.Frame(None, title="PyUpdater wxPython Demo")
self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self.frame.SetSize(wx.Size(400, 100))
self.statusBar = wx.StatusBar(self.frame)
self.statusBar.SetStatusText(self.status)
self.frame.SetStatusBar(self.statusBar)
self.panel = wx.Panel(self.frame)
self.sizer = wx.BoxSizer()
self.sizer.Add(
wx.StaticText(self.frame, label="Version %s" % __version__))
self.panel.SetSizerAndFit(self.sizer)
self.frame.Show()
if hasattr(sys, "frozen") and \
not os.environ.get('PYUPDATER_FILESERVER_DIR'):
dlg = wx.MessageDialog(
self.frame,
"The PYUPDATER_FILESERVER_DIR environment variable "
"is not set!", "PyUpdaterWxDemo File Server Error",
wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
return True
def __init__(self, timelen, services):
wx.Frame.__init__(self, parent=None, title=C_APP_NAME)
self.timelen = timelen * 1000
self.services = services
self.Show(False)
self.Bind(wx.EVT_TIMER, self.OnTimerEvent)
self.Bind(wx.EVT_CLOSE, self.OnExitEvent)
self.timer = wx.Timer(self)
self.timer.Start(self.timelen)
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, -1, title, size = (1, 1),
style=wx.FRAME_NO_TASKBAR|wx.NO_FULL_REPAINT_ON_RESIZE)
self.tbicon = MyTaskBarIcon(self)
self.tbicon.SetIconTimer()
self.Show(True)
##
# The main application wx.App class
#
def __init__(self, *args, **kwds):
# begin wxGlade: ChatFrameGui.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_2 = wx.Panel(self, -1, style=wx.RAISED_BORDER|wx.TAB_TRAVERSAL)
self.panel_1 = wx.Panel(self, -1, style=wx.RAISED_BORDER|wx.TAB_TRAVERSAL)
self.panel_3 = wx.Panel(self.panel_1, -1)
self.panel_4 = wx.Panel(self.panel_1, -1)
self.frmMain_statusbar = self.CreateStatusBar(1)
self.lblIpAddress = wx.StaticText(self.panel_4, -1, "IP &Address")
self.edtIPAddress = wx.TextCtrl(self.panel_4, -1, "127.0.0.1")
self.spnConnectPort = wx.SpinCtrl(self.panel_4, -1, "8080", min=1, max=65535, style=wx.SP_ARROW_KEYS|wx.SP_WRAP)
self.btnConnect = wx.ToggleButton(self.panel_4, -1, "&Connect")
self.lblListenPort = wx.StaticText(self.panel_3, -1, "Listen &on port")
self.spnListenPort = wx.SpinCtrl(self.panel_3, -1, "8080", min=1, max=65535, style=wx.SP_ARROW_KEYS|wx.SP_WRAP)
self.btnListen = wx.ToggleButton(self.panel_3, -1, "Lis&ten")
self.lblReceived = wx.StaticText(self.panel_1, -1, "Received")
self.edtReceived = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2|wx.TE_AUTO_URL)
self.lblSent = wx.StaticText(self.panel_1, -1, "Sent:")
self.edtSent = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2|wx.TE_AUTO_URL)
self.edtToSend = wx.TextCtrl(self.panel_2, -1, "")
self.btnSend = wx.Button(self.panel_2, -1, "&Send")
self.btnClose = wx.Button(self.panel_2, -1, "&Close")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __init__(self, parent=None, id=-1, title=None):
wx.Frame.__init__(self, parent, id, title)
self.MainPanel = wx.Panel(self, size=(640, 480))
self.MainPanel.SetBackgroundColour('WHITE')
self.panel = wx.Panel(self.MainPanel, size = (640,480))
self.panel.SetBackgroundColour('WHITE')
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(self.panel)
self.SetSizer(mainSizer)
self.Fit()
self.Bind(wx.EVT_CLOSE, self.CloseWindow)
self.World = None
self.cdc = wx.ClientDC(self.panel)
w, h = self.panel.GetSize()
self.bmp = wx.EmptyBitmap(w,h)
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.timer.Start(20)
Control_Frameworks_NOT_working.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def wxPythonApp():
import wx
app = wx.App()
frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150))
frame.SetBackgroundColour('white')
frame.CreateStatusBar()
menu= wx.Menu()
menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
menuBar = wx.MenuBar()
menuBar.Append(menu,"File")
frame.SetMenuBar(menuBar)
frame.Show()
app.MainLoop()
GUI_wxPython.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def createWidgetsFrame(self):
staticBox = wx.StaticBox( self.panel, -1, "Widgets Frame", size=(285, -1) )
self.statBoxSizerV = wx.StaticBoxSizer(staticBox, wx.VERTICAL)
#----------------------------------------------------------
GUI_wxPython.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def addStaticBoxWithLabels(self):
boxSizerH = wx.BoxSizer(wx.HORIZONTAL)
staticBox = wx.StaticBox( self.panel, -1, "Labels within a Frame" )
staticBoxSizerV = wx.StaticBoxSizer( staticBox, wx.VERTICAL )
boxSizerV = wx.BoxSizer( wx.VERTICAL )
staticText1 = wx.StaticText( self.panel, -1, " Choose a number:" )
boxSizerV.Add( staticText1, 0, wx.ALL)
staticText2 = wx.StaticText( self.panel, -1, " Label 2")
boxSizerV.Add( staticText2, 0, wx.ALL )
#------------------------------------------------------
staticBoxSizerV.Add( boxSizerV, 0, wx.ALL )
boxSizerH.Add(staticBoxSizerV)
#------------------------------------------------------
boxSizerH.Add(wx.ComboBox(self.panel, size=(70, -1)))
#------------------------------------------------------
boxSizerH.Add(wx.SpinCtrl(self.panel, size=(50, -1), style=wx.BORDER_RAISED))
# Add local boxSizer to main frame
self.statBoxSizerV.Add( boxSizerH, 1, wx.ALL )
#----------------------------------------------------------
GUI_wxPython.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.createWidgets()
self.Show()
#----------------------------------------------------------
Embed_wxPython.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def wxPythonApp():
import wx
app = wx.App()
frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150))
frame.SetBackgroundColour('white')
frame.CreateStatusBar()
menu= wx.Menu()
menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
menuBar = wx.MenuBar()
menuBar.Append(menu, "File")
frame.SetMenuBar(menuBar)
frame.Show()
app.MainLoop()
wxPython_frame_GUI.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def __init__(self, parent, title, size=(200,100)):
# Initialize super class
wx.Frame.__init__(self, parent, title=title, size=size)
# Change the frame color
self.SetBackgroundColour('white')
# Create Status Bar
self.CreateStatusBar()
# Create the Menu
menu= wx.Menu()
# Add Menu Items to the Menu
menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
menu.AppendSeparator()
menu.Append(wx.ID_EXIT,"Exit"," Exit the GUI")
# Create the MenuBar
menuBar = wx.MenuBar()
# Give the Menu a Title
menuBar.Append(menu,"File")
# Connect the Menu to the frame
self.SetMenuBar(menuBar)
# Display the frame
self.Show()
# Create instance of wxPython application
wxPython_Wallpaper.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def buttonCallback(self, event):
self.textWidget.AppendText("Enjoy 3-Dimensional Space in Python.")
self.textWidget.AppendText("\n*** Use your mouse to spin the Cube! ***\n\n")
frame = wx.Frame(None, -1, title='Python OpenGL', size=(300, 300), pos=(400, 20))
CubeCanvas(frame)
frame.Show()