def layout(self):
"""
Layout the widgets on the panel
"""
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
img = wx.EmptyImage(self.photoMaxSize,self.photoMaxSize)
self.imageCtrl = wx.StaticBitmap(self, wx.ID_ANY,
wx.BitmapFromImage(img))
self.mainSizer.Add(self.imageCtrl, 0, wx.ALL|wx.CENTER, 5)
self.imageLabel = wx.StaticText(self, label="")
self.mainSizer.Add(self.imageLabel, 0, wx.ALL|wx.CENTER, 5)
btnData = [("Previous", btnSizer, self.onPrevious),
("Slide Show", btnSizer, self.onSlideShow),
("Next", btnSizer, self.onNext)]
for data in btnData:
label, sizer, handler = data
self.btnBuilder(label, sizer, handler)
self.mainSizer.Add(btnSizer, 0, wx.CENTER)
self.SetSizer(self.mainSizer)
python类ID_ANY的实例源码
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="Timer Tutorial 2")
panel = wx.Panel(self, wx.ID_ANY)
self.timer = wx.Timer(self, wx.ID_ANY)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
self.timer2 = wx.Timer(self, wx.ID_ANY)
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.onStartTimer)
self.toggleBtn2 = wx.Button(panel, wx.ID_ANY, "Start Timer 2")
self.toggleBtn2.Bind(wx.EVT_BUTTON, self.onStartTimer)
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)
# Each value in the following dict is formatted as follows:
# (timerNum, timerObj, secs between timer events)
self.objDict = {self.toggleBtn: (1, self.timer, 1000),
self.toggleBtn2: (2, self.timer2, 3000)}
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
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,
'My First Plot (to take over the world!)')
# 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(drawBarGraph())
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,
'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.7 / 3.5</a></b></p>'
'<p><b><a href="http://www.wxpython.org">wxPython 3.0.2.0 / Phoenix</a></b></p>'
)
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 __init__(self):
wx.Frame.__init__(self, None, title="Tutorial")
panel = wx.Panel(self, wx.ID_ANY)
cars = [Car(0, "Ford", "F-150", "2008"),
Car(1, "Chevrolet", "Camaro", "2010"),
Car(2, "Nissan", "370Z", "2005")]
sampleList = []
self.cb = wx.ComboBox(panel,
size=wx.DefaultSize,
choices=sampleList)
self.widgetMaker(self.cb, cars)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.cb, 0, wx.ALL, 5)
panel.SetSizer(sizer)
def __init__(self):
wx.Frame.__init__(self, None, title="ListBox Obj Tutorial")
panel = wx.Panel(self, wx.ID_ANY)
ford = Car(0, "Ford", "F-150", "2008")
chevy = Car(1, "Chevrolet", "Camaro", "2010")
nissan = Car(2, "Nissan", "370Z", "2005")
sampleList = []
lb = wx.ListBox(panel,
size=wx.DefaultSize,
choices=sampleList)
self.lb = lb
lb.Append(ford.make, ford)
lb.Append(chevy.make, chevy)
lb.Append(nissan.make, nissan)
lb.Bind(wx.EVT_LISTBOX, self.onSelect)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(lb, 0, wx.ALL, 5)
panel.SetSizer(sizer)
def __init__(self):
super(SignalKScope, self).__init__(None)
self.plot = SignalKPlot()
self.glContext = wx.glcanvas.GLContext(self.glArea)
self.client = SignalKClientFromArgs(sys.argv[:2], True, self.on_con)
self.host_port = self.client.host_port
self.client.autoreconnect = False
self.value_list = self.client.list_values()
self.plot.init(self.value_list)
self.watches = {}
watches = sys.argv[2:]
for name in sorted(self.value_list):
if self.value_list[name]['type'] != 'SensorValue':
continue
i = self.clValues.Append(name)
self.watches[name] = False
for arg in watches:
if arg == name:
self.clValues.Check(i, True)
self.watches[name] = True
watches.remove(name)
for arg in watches:
print 'value not found:', arg
self.on_con(self.client)
self.timer = wx.Timer(self, wx.ID_ANY)
self.Bind(wx.EVT_TIMER, self.receive_messages, id=wx.ID_ANY)
self.timer.Start(100)
self.sTime.SetValue(self.plot.disptime)
self.plot_reshape = False
def InitUI(self,config=None):
artprovider = wx.ArtProvider()
toolbar = self.CreateToolBar(style=wx.TB_TEXT|wx.TB_HORZ_LAYOUT)
toolOpen = toolbar.AddTool(wx.ID_ANY, 'Open', artprovider.GetBitmap(wx.ART_FILE_OPEN,client=wx.ART_TOOLBAR),"Open an i3 config file")
toolSave = toolbar.AddTool(wx.ID_ANY, 'Save', artprovider.GetBitmap(wx.ART_FILE_SAVE,client=wx.ART_TOOLBAR),"Save the current settings to the open file")
toolApply = toolbar.AddTool(wx.ID_ANY, 'Apply', artprovider.GetBitmap(wx.ART_TICK_MARK,client=wx.ART_TOOLBAR),"Apply the changes without changing file")
toolUpdateLocal = toolbar.AddTool(wx.ID_ANY, 'Save to config', artprovider.GetBitmap(wx.ART_FILE_SAVE_AS,client=wx.ART_TOOLBAR),"Save the current colour scheme into your current config")
toolSnippet = toolbar.AddTool(wx.ID_ANY, 'Create colour snippet', artprovider.GetBitmap(wx.ART_NEW,client=wx.ART_TOOLBAR),"Save the current colour scheme as a standalone colour file you can send to others")
toolVariable = toolbar.AddTool(wx.ID_ANY, 'Create colour variable', artprovider.GetBitmap(wx.ART_PLUS,client=wx.ART_TOOLBAR),"Create a new colour variable")
toolbar.AddStretchableSpace()
toolQuit = toolbar.AddTool(wx.ID_ANY, 'Quit', artprovider.GetBitmap(wx.ART_QUIT,client=wx.ART_TOOLBAR),"Quit the program")
self.Bind(wx.EVT_TOOL, self.OnQuit,toolQuit)
self.Bind(wx.EVT_TOOL, self.OnOpen,toolOpen)
self.Bind(wx.EVT_TOOL, self.OnApply,toolApply)
self.Bind(wx.EVT_TOOL, self.OnSave,toolSave)
self.Bind(wx.EVT_TOOL, self.OnUpdateLocal,toolUpdateLocal)
self.Bind(wx.EVT_TOOL, self.OnCreateSnippet,toolSnippet)
self.Bind(wx.EVT_TOOL, self.OnCreateVariable,toolVariable)
self.scrolled = wx.lib.scrolledpanel.ScrolledPanel(self,-1)
self.scrolled.SetupScrolling()
self.scrolled.Show()
self.Centre()
self.Show(True)
if config!=None:
self.LoadConfig(config)
def __init__(self, parent):
wx.Dialog.__init__(self, parent, wx.ID_ANY, "About NodeMCU PyFlasher")
html = HtmlWindow(self, wx.ID_ANY, size=(420, -1))
if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo:
html.SetStandardFonts()
txt = self.text.format(self._get_bundle_dir(), __version__)
html.SetPage(txt)
ir = html.GetInternalRepresentation()
html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25))
self.SetClientSize(html.GetSize())
self.CentreOnParent(wx.BOTH)
HtmlPopupTransientWindow.py 文件源码
项目:nodemcu-pyflasher
作者: marcelstoer
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self, parent, style, html_body_content, bgcolor, size):
wx.PopupTransientWindow.__init__(self, parent, style)
panel = wx.Panel(self)
panel.SetBackgroundColour(bgcolor)
html_window = self.HtmlWindow(panel, wx.ID_ANY, size=size)
html_window.SetPage('<body bgcolor="' + bgcolor + '">' + html_body_content + '</body>')
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(html_window, 0, wx.ALL, 5)
panel.SetSizer(sizer)
sizer.Fit(panel)
sizer.Fit(self)
self.Layout()
def __init__(self, title, pos, size):
# Initialize some flags
self.IsEtotRead = False
wx.Frame.__init__(self, None, -1, title, pos, size)
panel = wx.Panel(self, -1)
panel.SetBackgroundColour("White")
text = wx.TextCtrl(self, wx.ID_ANY, size=size, style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(text, 1, wx.EXPAND)
self.SetSizer(sizer)
self.Fit()
self.Bind(wx.EVT_CLOSE, self.OnQuit)
self.createMenuBar()
self.CreateStatusBar()
self.SetStatusText("Welcome to pyQHA")
# Redirect stout to the TextCtrl in the main panel
self.redir=RedirectText(text)
sys.stdout=self.redir
sys.stderr=self.redir
############################################################################
#
# Menu functions
#
def __init__(self, parent, columns, df_list_ctrl, change_callback):
wx.Panel.__init__(self, parent)
columns_with_neutral_selection = [''] + list(columns)
self.columns = columns
self.df_list_ctrl = df_list_ctrl
self.change_callback = change_callback
self.num_filters = 10
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
self.combo_boxes = []
self.text_controls = []
for i in range(self.num_filters):
combo_box = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
text_ctrl = wx.TextCtrl(self, wx.ID_ANY, '')
self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)
self.Bind(wx.EVT_TEXT, self.on_text_change)
row_sizer = wx.BoxSizer(wx.HORIZONTAL)
row_sizer.Add(combo_box, 0, wx.ALL, 5)
row_sizer.Add(text_ctrl, 1, wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT, 5)
self.combo_boxes.append(combo_box)
self.text_controls.append(text_ctrl)
self.main_sizer.Add(row_sizer, 0, wx.EXPAND)
self.SetSizer(self.main_sizer)
def CreateMenuBar(self):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
nitem = fileMenu.Append(wx.ID_NEW, '&New', 'New project' )
oitem = fileMenu.Append(wx.ID_OPEN, '&Open', 'Open project')
self.ritem = fileMenu.Append(wx.ID_SAVEAS, '&Render\tCtrl-r', 'Render')
self.iitem = fileMenu.Append(wx.ID_ANY, '&Import\tCtrl-i', 'Import image directory')
self.qitem = fileMenu.Append(wx.ID_EXIT, '&Quit', 'Quit application')
editMenu = wx.Menu()
self.zitem = editMenu.Append(wx.ID_UNDO, '&Undo\tCtrl-z', 'Undo Delete')
#yitem = editMenu.Append(wx.ID_REDO, '&Redo', 'Redo')
self.ditem = editMenu.Append(wx.ID_DELETE, '&Delete\tDelete', 'Delete')
pitem = editMenu.Append(wx.ID_PREFERENCES, '&Preferences\tCtrl-,', 'Preferences')
helpMenu = wx.Menu()
aitem = helpMenu.Append(wx.ID_ABOUT, '&About\tCtrl-?', 'About Stopgo')
menubar.Append(fileMenu, '&File')
menubar.Append(editMenu, '&Edit')
menubar.Append(helpMenu, '&Help')
self.Bind(wx.EVT_MENU, lambda event, args=(False): self.OpenFile(event,args), oitem)
self.Bind(wx.EVT_MENU, self.NewFile, nitem)
self.Bind(wx.EVT_MENU, self.Pref, pitem)
self.Bind(wx.EVT_MENU, lambda event,args=(False): ingest.Ingest(self),self.iitem)
self.Bind(wx.EVT_MENU, self.SimpleQuit, self.qitem)
self.Bind(wx.EVT_CLOSE, self.SimpleQuit, self.qitem)
self.Bind(wx.EVT_MENU, self.About, aitem)
self.SetMenuBar(menubar)
def BuildTimeline(self,dbfile):
for child in self.panel3.GetChildren():
logging.exception(child)
child.Destroy()
# the last frame is
latestfram = self.cur.execute("SELECT * FROM Timeline ORDER BY Image DESC LIMIT 1")
#latestfram = self.cur.execute("SELECT * FROM Timeline WHERE ID = (SELECT MAX(ID) FROM TABLE) AND Blackspot = 0");
try:
for entry in latestfram:
self.framlog = int(entry[1].split('.')[0])
self.framlog += 1
logging.exception(self.framlog)
except:
logging.exception('Looking for last frame but did not find.')
pass
# timeline contains
tbl_timeline = self.cur.execute("SELECT * FROM Timeline WHERE Blackspot=0")
for entry in tbl_timeline:
img = self.MakeThumbnail(os.path.join(self.imgdir, entry[1]), self.thumbsize)
self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY,
wx.BitmapFromImage(img),name=entry[1])
self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))
self.imageCtrl.Bind( wx.EVT_LEFT_DOWN, self.OnLeftClick )
self.imageCtrl.Bind( wx.EVT_LEFT_UP, self.OnLeftRelease )
logging.exception(self.imageCtrl.GetId() )
self.hbox2.Add( self.imageCtrl, 0, wx.ALL, 5 )
self.Layout()
self.panel3.SetFocus()
self.BindKeys(dbfile)
self.hbox2.Layout()
self.panel3.Refresh()
self.panel3.Update()
self.Refresh()