Skip to content

Commit a399efb

Browse files
update demo for v0.8
1 parent 5bc75c2 commit a399efb

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

demo/demo3-styles.uiss

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22

3-
3+
44
@style main-frame {
5-
background-color: white;
5+
background-color: red;
66
}
77

8+
/* button */
89
@style button {
910
background-color: #F4F4F4;
1011
top: 20px;
@@ -15,20 +16,40 @@
1516
border-size: 2px;
1617
}
1718

18-
@style button-- {
19-
background-color: #F4F4F4;
19+
@style button:hover {
20+
background-color: #FDFDFD;
2021
top: 20px;
2122
left: 40px;
22-
width: 100px;
23-
height: 30px;
23+
width: 115px;
24+
height: 35px;
2425
border-color: #D1D1D1;
2526
border-size: 2px;
2627
}
2728

29+
@style button:press {
30+
background-color: #D1D1D1;
31+
top: 20px;
32+
left: 40px;
33+
width: 115px;
34+
height: 35px;
35+
border-color: #D1D1D1;
36+
border-size: 2px;
37+
}
2838

2939
@style button-text {
30-
type: text;
3140
color: black;
3241
top: 30px;
3342
left: 47px;
3443
}
44+
45+
@style button-text:hover {
46+
color: #444;
47+
top: 30px;
48+
left: 47px;
49+
}
50+
51+
@style text {
52+
color: green;
53+
top: 300px;
54+
left: 47px;
55+
}

demo/demo3.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# Usage:
77
# It's a custom button...click it!
88

9-
# TODO:
10-
# Comments!!!
9+
# This demo is up-to-date
1110

1211

1312
import wx
@@ -22,7 +21,7 @@ def __init__(self):
2221
# Create the DC
2322
self._pdc = UIStylePDC(
2423
self,
25-
'./demo3-styles.uiss'
24+
'./custom-widget-demo.uiss'
2625
)
2726

2827
self.DrawDrawing(self._pdc)
@@ -48,47 +47,50 @@ def OnPaint(self, event):
4847

4948
def OnMotion(self, event):
5049
pnt = event.GetPosition()
51-
elem_rect = self._pdc.GetWXRect('button')
50+
elem_rect = self._pdc.GetWxRect('button')
5251
mouse_pnt = wx.Rect(pnt[0], pnt[1], 1, 1)
5352

5453
if mouse_pnt.Intersects(elem_rect) == True:
55-
self._pdc.UpdateShapeStyles('button', styles="background-color: #FDFDFD;")
54+
self._pdc.UpdateElem('button:hover')
5655
else:
57-
self._pdc.UpdateShapeStyles('button', styles="background-color: #F4F4F4;")
56+
self._pdc.UpdateElem('button')
5857

5958
self.RefreshDemo()
6059

6160

6261
def OnLeftDown(self, event):
6362
pnt = event.GetPosition()
64-
elem_rect = self._pdc.GetWXRect('button')
63+
elem_rect = self._pdc.GetWxRect('button')
6564

6665
# Create a 1x1 rect for the mouse pointer
6766
mouse_pnt = wx.Rect(pnt[0], pnt[1], 1, 1)
6867

6968
if mouse_pnt.Intersects(elem_rect) == True:
70-
self._pdc.UpdateShapeStyles('button', styles="background-color: #D1D1D1;")
69+
self._pdc.UpdateElem('button:press')
70+
self._pdc.UpdateElem('button-text:hover')
7171

7272
self.RefreshDemo()
7373

7474
def OnLeftUp(self, event):
7575
pnt = event.GetPosition()
76-
elem_rect = self._pdc.GetWXRect('button')
76+
elem_rect = self._pdc.GetWxRect('button')
7777

7878
# Create a 1x1 rect for the mouse pointer
7979
mouse_pnt = wx.Rect(pnt[0], pnt[1], 1, 1)
8080

8181
if mouse_pnt.Intersects(elem_rect) == True:
82-
self._pdc.UpdateShapeStyles('button', styles="background-color: #F4F4F4;")
82+
self._pdc.UpdateElem('button')
83+
self._pdc.UpdateElem('button-text')
8384
self.ButtonCallback()
8485

8586
self.RefreshDemo()
8687

8788
def DrawDrawing(self, dc):
8889

8990
# Initial
90-
dc.InitShapeStyles('button')
91-
dc.InitTextStyles('button-text', text="UI Style Lang Demo")
91+
dc.InitElem('button')
92+
dc.InitElem('button-text', "TEXT", "UI Style Lang Demo")
93+
dc.InitElem('text', "TEXT", "UI Style Lang Demo")
9294

9395

9496
def RefreshDemo(self):
@@ -112,3 +114,4 @@ def ButtonCallback(self):
112114
frame.Show()
113115
app.SetTopWindow(frame)
114116
app.MainLoop()
117+

0 commit comments

Comments
 (0)