-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathstatusbar.py
55 lines (40 loc) · 1.98 KB
/
statusbar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
# -*- coding: utf-8 -*-
"gui2py's StatusBar (encapsulates wx.StatusBar)"
__author__ = "Mariano Reingart (reingart@gmail.com)"
__copyright__ = "Copyright (C) 2013- Mariano Reingart"
__license__ = "LGPL 3.0"
# Initial implementation was based on PythonCard's statusbar module, altought
# some of it was redesigned and overhauled a lot (specially Color)
import wx
from .event import FormEvent
from .component import Component, Control, Spec, StyleSpec, InitSpec
from . import images
from . import registry
class StatusBar(Component):
"A simple StatusBar with a single text field."
_wx_class = wx.StatusBar
_image = images.statusbar
_registry = registry.CONTROLS
def __init__(self, parent=None, **kwargs):
Component.__init__(self, parent, **kwargs)
if wx.Platform == '__WXMAC__':
self.wx_obj.SetSize((self.wx_obj.GetSizeTuple()[0], 15))
# only display the resizing grip if the window is resizable
# the logic below is used because it appears different
# default flags are used on different platforms
#self.size_grip = self._parent.resizable
self._parent.statusbar = self # add the statusbar to the parent
def set_parent(self, new_parent, init=False):
"Re-parent a child control with the new wx_obj parent"
Component.set_parent(self, new_parent, init)
# if new_parent is rebuild, reparent (even to None) to avoid segv:
if not init:
wx_obj = new_parent and new_parent.wx_obj
self.wx_obj.Reparent(wx_obj)
if wx.VERSION < (2, 9, 5):
grip = StyleSpec(wx.ST_SIZEGRIP, doc="resizing grip", default=False)
text = Spec(lambda self: self.wx_obj.GetStatusText(),
lambda self, value: self.wx_obj.SetStatusText(value),
default="", type="string",
doc="text displayed in the statusBar")