def __init__(self, parent):
super(MyFrame, self).__init__(parent, title=TITLE, size=(1280, 768))
icon_path = 'Assets/Microsoft-logo_rgb_c-gray.png'
self.SetIcon(wx.Icon(icon_path))
sizer = wx.BoxSizer(wx.VERTICAL)
self.title = MyTitle(self)
sizer.Add(self.title, flag=wx.EXPAND)
self.book = MyLabelBook(self)
sizer.Add(self.book, 1, flag=wx.EXPAND)
status_text = (
'Microsoft will receive the images you upload and may use them to '
'improve Face API and related services. By submitting an image, '
'you confirm you have consent from everyone in it.'
)
self.status = wx.StatusBar(self)
self.status.SetStatusText(status_text)
sizer.Add(self.status, flag=wx.EXPAND)
self.SetSizer(sizer)
self.Layout()
python类StatusBar()的实例源码
def __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP,
name="EnhancedStatusBar"):
"""Default Class Constructor.
EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY,
style=wx.ST_SIZEGRIP,
name="EnhancedStatusBar")
"""
wx.StatusBar.__init__(self, parent, id, style, name)
self._items = {}
self._curPos = 0
self._parent = parent
wx.EVT_SIZE(self, self.OnSize)
wx.CallAfter(self.OnSize, None)
def __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP,
name="EnhancedStatusBar"):
"""Default Class Constructor.
EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY,
style=wx.ST_SIZEGRIP,
name="EnhancedStatusBar")
"""
wx.StatusBar.__init__(self, parent, id, style, name)
self._items = {}
self._curPos = 0
self._parent = parent
wx.EVT_SIZE(self, self.OnSize)
wx.CallAfter(self.OnSize, None)
def __init__(self, controller_uid):
UIViewBase.__init__(self, controller_uid)
_UIM = UIManager()
parent_controller_uid = _UIM._getparentuid(self._controller_uid)
parent_controller = _UIM.get(parent_controller_uid)
wx.StatusBar.__init__(self, parent_controller.view)
"""
self.paneinfo = wx.aui.AuiPaneInfo().Name(self.tid).Bottom()
mgr = wx.aui.AuiManager_GetManager(self.parent)
mgr.AddPane(self, self.paneinfo)
mgr.Update()
"""
parent_controller.view.SetStatusBar(self)
#if isinstance(self.parent, MainWindow):
# self.parent.SetStatusBar(self)
#else:
# raise Exception('')
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, parent, pixelsPerUnit=20):
wx.StatusBar.__init__(self, parent, -1)
self.pixelsPerUnit = pixelsPerUnit
self.SetMinHeight(16)
# Dummy panel para encobrir a ScrollBar
#self.panelDummy = wx.Panel(self)
#self.panelDummy.SetBackgroundColour('green')
#self.panelDummy.Show(False)
self.SetFieldsCount(3)
self.SetStatusWidths([-3, -1, -1])
#self.SetStatusText("Aqui vai a legenda dos Logs...", 0)
self.sb = wx.ScrollBar(self)
self.sb.show = False
self.sb.SetScrollbar(0, 10, 100, 10)
self.Bind(wx.EVT_SIZE, self._OnSize)
self.sb.Bind(wx.EVT_SCROLL_THUMBTRACK, self._OnScroll)
self.sb.Bind(wx.EVT_SCROLL_LINEUP, self._OnScroll)
self.sb.Bind(wx.EVT_SCROLL_PAGEUP, self._OnScroll)
self.sb.Bind(wx.EVT_SCROLL_LINEDOWN, self._OnScroll)
self.sb.Bind(wx.EVT_SCROLL_PAGEDOWN, self._OnScroll)
self.sb.ultimaPosicao = 0
self.Reposition()
#self.timer = wx.PyTimer(self.Notify)
#self.timer.Start(1000)
#self.Notify()
self.HideScrollBar()
def AddWidget(self, widget, horizontalalignment=ESB_ALIGN_CENTER_HORIZONTAL,
verticalalignment=ESB_ALIGN_CENTER_VERTICAL, pos = -1):
"""Add A Widget To The EnhancedStatusBar.
Parameters:
- horizontalalignment: This Can Be One Of:
a) ESB_EXACT_FIT: The Widget Will Fit Horizontally The StatusBar Field Width;
b) ESB_ALIGN_CENTER_HORIZONTAL: The Widget Will Be Centered Horizontally In
The StatusBar Field;
c) ESB_ALIGN_LEFT: The Widget Will Be Left Aligned In The StatusBar Field;
d) ESB_ALIGN_RIGHT: The Widget Will Be Right Aligned In The StatusBar Field;
- verticalalignment:
a) ESB_EXACT_FIT: The Widget Will Fit Vertically The StatusBar Field Height;
b) ESB_ALIGN_CENTER_VERTICAL: The Widget Will Be Centered Vertically In
The StatusBar Field;
c) ESB_ALIGN_BOTTOM: The Widget Will Be Bottom Aligned In The StatusBar Field;
d) ESB_ALIGN_TOP: The Widget Will Be TOP Aligned In The StatusBar Field;
"""
if pos == -1:
pos = self._curPos
self._curPos += 1
if self.GetFieldsCount() <= pos:
raise "\nERROR: EnhancedStatusBar has a max of %d items, you tried to set item #%d" % (self.GetFieldsCount(), pos)
if horizontalalignment not in [ESB_ALIGN_CENTER_HORIZONTAL, ESB_EXACT_FIT,
ESB_ALIGN_LEFT, ESB_ALIGN_RIGHT]:
raise '\nERROR: Parameter "horizontalalignment" Should Be One Of '\
'"ESB_ALIGN_CENTER_HORIZONTAL", "ESB_ALIGN_LEFT", "ESB_ALIGN_RIGHT"' \
'"ESB_EXACT_FIT"'
if verticalalignment not in [ESB_ALIGN_CENTER_VERTICAL, ESB_EXACT_FIT,
ESB_ALIGN_TOP, ESB_ALIGN_BOTTOM]:
raise '\nERROR: Parameter "verticalalignment" Should Be One Of '\
'"ESB_ALIGN_CENTER_VERTICAL", "ESB_ALIGN_TOP", "ESB_ALIGN_BOTTOM"' \
'"ESB_EXACT_FIT"'
try:
self.RemoveChild(self._items[pos].widget)
self._items[pos].widget.Destroy()
except KeyError: pass
self._items[pos] = EnhancedStatusBarItem(widget, pos, horizontalalignment, verticalalignment)
wx.CallAfter(self.OnSize, None)
def AddWidget(self, widget, horizontalalignment=ESB_ALIGN_CENTER_HORIZONTAL,
verticalalignment=ESB_ALIGN_CENTER_VERTICAL, pos=-1):
"""Add A Widget To The EnhancedStatusBar.
Parameters:
- horizontalalignment: This Can Be One Of:
a) ESB_EXACT_FIT: The Widget Will Fit Horizontally The StatusBar Field Width;
b) ESB_ALIGN_CENTER_HORIZONTAL: The Widget Will Be Centered Horizontally In
The StatusBar Field;
c) ESB_ALIGN_LEFT: The Widget Will Be Left Aligned In The StatusBar Field;
d) ESB_ALIGN_RIGHT: The Widget Will Be Right Aligned In The StatusBar Field;
- verticalalignment:
a) ESB_EXACT_FIT: The Widget Will Fit Vertically The StatusBar Field Height;
b) ESB_ALIGN_CENTER_VERTICAL: The Widget Will Be Centered Vertically In
The StatusBar Field;
c) ESB_ALIGN_BOTTOM: The Widget Will Be Bottom Aligned In The StatusBar Field;
d) ESB_ALIGN_TOP: The Widget Will Be TOP Aligned In The StatusBar Field;
"""
if pos == -1:
pos = self._curPos
self._curPos += 1
if self.GetFieldsCount() <= pos:
raise "\nERROR: EnhancedStatusBar has a max of %d items, you tried to set item #%d" % (self.GetFieldsCount(), pos)
if horizontalalignment not in [ESB_ALIGN_CENTER_HORIZONTAL, ESB_EXACT_FIT,
ESB_ALIGN_LEFT, ESB_ALIGN_RIGHT]:
raise '\nERROR: Parameter "horizontalalignment" Should Be One Of '\
'"ESB_ALIGN_CENTER_HORIZONTAL", "ESB_ALIGN_LEFT", "ESB_ALIGN_RIGHT"' \
'"ESB_EXACT_FIT"'
if verticalalignment not in [ESB_ALIGN_CENTER_VERTICAL, ESB_EXACT_FIT,
ESB_ALIGN_TOP, ESB_ALIGN_BOTTOM]:
raise '\nERROR: Parameter "verticalalignment" Should Be One Of '\
'"ESB_ALIGN_CENTER_VERTICAL", "ESB_ALIGN_TOP", "ESB_ALIGN_BOTTOM"' \
'"ESB_EXACT_FIT"'
try:
self.RemoveChild(self._items[pos].widget)
self._items[pos].widget.Destroy()
except KeyError:
pass
self._items[pos] = EnhancedStatusBarItem(widget, pos, horizontalalignment, verticalalignment)
wx.CallAfter(self.OnSize, None)
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_TFRAME, name='TFrame', parent=prnt,
pos=wx.Point(254, 241), size=wx.Size(829, 786),
style=wx.DEFAULT_FRAME_STYLE, title=u'PAWS Terminal')
self._init_utils()
self.SetClientSize(wx.Size(821, 748))
self.SetMenuBar(self.TMenuBar)
self.SetAutoLayout(True)
self.SetToolTipString('TFrame')
self.SetMinSize(wx.Size(-1, 21))
self.TStatusBar = wx.StatusBar(id=wxID_TFRAMETSTATUSBAR,
name='TStatusBar', parent=self, style=0)
self.TStatusBar.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
u'Courier New'))
self._init_coll_TStatusBar_Fields(self.TStatusBar)
self.SetStatusBar(self.TStatusBar)
self.TInput = wx.TextCtrl(id=wxID_TFRAMETINPUT, name='TInput',
parent=self, pos=wx.Point(1, 728), size=wx.Size(819, 20),
style=wx.SIMPLE_BORDER | wx.TE_PROCESS_ENTER, value="''")
self.TInput.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
u'Courier'))
self.TInput.SetToolTipString(u'Type command here.')
self.TInput.SetAutoLayout(False)
self.TInput.SetEditable(True)
self.TInput.Enable(False)
self.TInput.Bind(wx.EVT_TEXT_ENTER, self.OnTInputTextEnter,
id=wxID_TFRAMETINPUT)
self.TDisplay = wx.TextCtrl(id=wxID_TFRAMETDISPLAY, name='TDisplay',
parent=self, pos=wx.Point(0, 0), size=wx.Size(821, 728),
style=wx.TE_RICH2 | wx.TE_MULTILINE | wx.TE_READONLY,
value=u'To run a game, choose File ? Pick Game … then choose a game from the list.')
self.TDisplay.SetMinSize(wx.Size(517, 440))
self.TDisplay.SetEditable(False)
self.TDisplay.SetToolTipString(u"Game's output displays here.")
self.TDisplay.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
u'Arial'))
self.TDisplay.Enable(True)
self._init_sizers()