6
6
# Usage:
7
7
# It's a custom button...click it!
8
8
9
- # TODO:
10
- # Comments!!!
9
+ # This demo is up-to-date
11
10
12
11
13
12
import wx
@@ -22,7 +21,7 @@ def __init__(self):
22
21
# Create the DC
23
22
self ._pdc = UIStylePDC (
24
23
self ,
25
- './demo3-styles .uiss'
24
+ './custom-widget-demo .uiss'
26
25
)
27
26
28
27
self .DrawDrawing (self ._pdc )
@@ -48,47 +47,50 @@ def OnPaint(self, event):
48
47
49
48
def OnMotion (self , event ):
50
49
pnt = event .GetPosition ()
51
- elem_rect = self ._pdc .GetWXRect ('button' )
50
+ elem_rect = self ._pdc .GetWxRect ('button' )
52
51
mouse_pnt = wx .Rect (pnt [0 ], pnt [1 ], 1 , 1 )
53
52
54
53
if mouse_pnt .Intersects (elem_rect ) == True :
55
- self ._pdc .UpdateShapeStyles ('button' , styles = "background-color: #FDFDFD;" )
54
+ self ._pdc .UpdateElem ('button:hover' )
56
55
else :
57
- self ._pdc .UpdateShapeStyles ('button' , styles = "background-color: #F4F4F4;" )
56
+ self ._pdc .UpdateElem ('button' )
58
57
59
58
self .RefreshDemo ()
60
59
61
60
62
61
def OnLeftDown (self , event ):
63
62
pnt = event .GetPosition ()
64
- elem_rect = self ._pdc .GetWXRect ('button' )
63
+ elem_rect = self ._pdc .GetWxRect ('button' )
65
64
66
65
# Create a 1x1 rect for the mouse pointer
67
66
mouse_pnt = wx .Rect (pnt [0 ], pnt [1 ], 1 , 1 )
68
67
69
68
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' )
71
71
72
72
self .RefreshDemo ()
73
73
74
74
def OnLeftUp (self , event ):
75
75
pnt = event .GetPosition ()
76
- elem_rect = self ._pdc .GetWXRect ('button' )
76
+ elem_rect = self ._pdc .GetWxRect ('button' )
77
77
78
78
# Create a 1x1 rect for the mouse pointer
79
79
mouse_pnt = wx .Rect (pnt [0 ], pnt [1 ], 1 , 1 )
80
80
81
81
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' )
83
84
self .ButtonCallback ()
84
85
85
86
self .RefreshDemo ()
86
87
87
88
def DrawDrawing (self , dc ):
88
89
89
90
# 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" )
92
94
93
95
94
96
def RefreshDemo (self ):
@@ -112,3 +114,4 @@ def ButtonCallback(self):
112
114
frame .Show ()
113
115
app .SetTopWindow (frame )
114
116
app .MainLoop ()
117
+
0 commit comments