36
36
37
37
38
38
class UIStyleApp (wx .App ):
39
+ """ Wrapper of ``wx.App``
40
+
41
+ :param file: path to stylesheet for the Native Widget API styling
42
+
43
+ Please refer to the wxPython docs for the rest of the params.
44
+ """
39
45
def __init__ (self , file , redirect = False , filename = None , useBestVisual = False , clearSigInt = True ):
40
46
wx .App .__init__ (self , redirect , filename , useBestVisual , clearSigInt )
41
47
@@ -52,6 +58,10 @@ def ParsedStyles(self):
52
58
53
59
54
60
class UIStyleFrame (wx .Frame ):
61
+ """ Wrapper of ``wx.Frame``
62
+
63
+ Supported properties: ``background-color``
64
+ """
55
65
def __init__ (self , parent , id = - 1 , title = "" , pos = wx .DefaultPosition ,
56
66
size = wx .DefaultSize , style = wx .DEFAULT_FRAME_STYLE , name = "frame" ):
57
67
wx .Frame .__init__ (self , parent , id , title , pos , size , style , name )
@@ -78,7 +88,7 @@ def ConfigureStyle(self):
78
88
""" Configures the styling of the frame.
79
89
80
90
:returns: a boolean value of whether the styling could be applied.
81
- """
91
+ """
82
92
styles_dict = MergeParsedStyles (
83
93
self .GetName (),
84
94
wx .GetApp ().ParsedStyles ,
@@ -91,9 +101,12 @@ def ConfigureStyle(self):
91
101
92
102
93
103
class UIStylePanel (wx .Panel ):
104
+ """ Wrapper of ``wx.Panel``
105
+
106
+ Supported properties: ``background-color``
107
+ """
94
108
def __init__ (self , parent , id = - 1 , pos = wx .DefaultPosition ,
95
- size = wx .DefaultSize , style = wx .TAB_TRAVERSAL | wx .NO_BORDER ,
96
- name = wx .PanelNameStr ):
109
+ size = wx .DefaultSize , style = wx .TAB_TRAVERSAL | wx .NO_BORDER , name = "panel" ):
97
110
wx .Panel .__init__ (self , parent , id , pos , size , style , name )
98
111
99
112
self .default_properties = {
@@ -128,23 +141,46 @@ def ConfigureStyle(self):
128
141
129
142
uiss_background_color = self .CleanProperty (styles_dict ["background-color" ])
130
143
return self .SetBackgroundColour (wx .Colour (uiss_background_color ))
131
-
144
+
132
145
133
-
134
-
135
- #
136
- # class StaticText(wx.StaticText):
137
- # def __init__(self, parent, id=-1, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name=wx.StaticTextNameStr):
138
- # super(StaticText, self).__init__(parent, id, label, pos, size, style, name)
146
+ class UIStyleStaticText (wx .StaticText ):
147
+ """ Wrapper of ``wx.StaticText``
139
148
149
+ Supported properties: ``background-color``, ``color``
150
+ """
151
+ def __init__ (self , parent , id = - 1 , label = "" , pos = wx .DefaultPosition , size = wx .DefaultSize , style = 0 , name = "static-text" ):
152
+ wx .StaticText .__init__ (self , parent , id , label , pos , size , style , name )
140
153
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
154
+ self .default_properties = {
155
+ "background-color" : "transparent" ,
156
+ "color" : "transparent" ,
157
+ }
158
+ self .current_styles = self .default_properties
159
+
160
+ try :
161
+ self .ConfigureStyle ()
162
+ except KeyError :
163
+ print (
164
+ """UISTYLELANG: Styling was not declared for the UIStyleStaticText with the id of '{}'.
165
+ Please declare it in the stylesheet.""" .format (self .GetName ())
166
+ )
167
+ except Exception as error :
168
+ print (error )
169
+
170
+ def CleanProperty (self , prop ):
171
+ return wx .GetApp ().lang_parser .clean_property (prop )
172
+
173
+ def ConfigureStyle (self ):
174
+ """ Configures the styling of the static text. """
175
+
176
+ styles_dict = MergeParsedStyles (
177
+ self .GetName (),
178
+ wx .GetApp ().ParsedStyles ,
179
+ self .current_styles
180
+ )
181
+
182
+ uiss_background_color = self .CleanProperty (styles_dict ["background-color" ])
183
+ uiss_color = self .CleanProperty (styles_dict ["color" ])
184
+
185
+ self .SetBackgroundColour (wx .Colour (uiss_background_color ))
186
+ self .SetForegroundColour (wx .Colour (uiss_color ))
0 commit comments