-
Notifications
You must be signed in to change notification settings - Fork 11
/
ZoomPanel.py
56 lines (39 loc) · 1.88 KB
/
ZoomPanel.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
import wx
FONT_COLOR = "#186F24"
class ZoomPanel(wx.Panel):
def __init__(self, mode, *args, **kwargs):
super(ZoomPanel, self).__init__(*args, **kwargs)
self.scalDownLbl = "Zoom: 4 -"
self.scalUpLbl = "+ "
self.mode = mode
self.selection = 4
self.InitUI()
def InitUI(self):
zoomSizer = wx.BoxSizer(wx.HORIZONTAL)
self.SetSizer(zoomSizer)
self.scalDownTxt = wx.StaticText(self, label=self.scalDownLbl, size=(-1, -1))
self.scalDownTxt.SetForegroundColour(FONT_COLOR)
self.scrollBar = wx.ScrollBar(self, size=(200, -1), style=wx.SB_HORIZONTAL)
self.scrollBar.SetScrollbar(4, 1, 9, 1, False)
# self.scrollBar.Bind(wx.EVT_SCROLL_PAGEDOWN, self.OnScrollBar)
self.scrollBar.Bind(wx.EVT_SCROLL_CHANGED, self.OnScrollBar)
scalUpTxt = wx.StaticText(self, label=self.scalUpLbl, size=(-1, -1))
scalUpTxt.SetForegroundColour(FONT_COLOR)
# self.scrollBar.SetBackgroundColour("Grey")
zoomSizer.Add((-1,-1),1, wx.EXPAND)
zoomSizer.Add(self.scalDownTxt, 0, wx.EXPAND)
zoomSizer.Add(self.scrollBar, 0, wx.EXPAND)
zoomSizer.Add(scalUpTxt, 0, wx.EXPAND)
def OnScrollBar(self, evt):
label = self.scalDownTxt.GetLabelText().split(" ")
label[1] = str(evt.GetSelection())
newLabel = ""
for index, i in enumerate(label):
newLabel += i + " " if i != label[-1] else i
self.scalDownTxt.SetLabelText(newLabel)
# label = str((100 + 100 * evt.GetPosition())) + '%'
# self.scalTxt.SetLabelText(label)
self.GetParent().ApplyFontToChildren(self.GetParent().layout, evt.GetSelection() - self.selection)
self.GetParent().ChangeFontToMidsectionGrid(evt.GetSelection() - self.selection)
self.selection = evt.GetSelection()
evt.Skip()