1
1
from __future__ import unicode_literals
2
- import types
3
2
4
3
try :
5
4
import tkinter as tk
8
7
9
8
from .builderobject import *
10
9
10
+
11
11
#
12
12
# tkinter widgets
13
13
#
14
+
15
+
14
16
class TKToplevel (BuilderObject ):
15
17
class_ = tk .Toplevel
16
18
container = True
@@ -31,7 +33,7 @@ class TKToplevel(BuilderObject):
31
33
'vertically' : (False , True ),
32
34
'none' : (False , False )
33
35
}
34
-
36
+
35
37
def realize (self , parent ):
36
38
args = self ._get_init_args ()
37
39
master = parent .get_child_master ()
@@ -40,7 +42,7 @@ def realize(self, parent):
40
42
else :
41
43
self .widget = self .class_ (master , ** args )
42
44
return self .widget
43
-
45
+
44
46
def _set_property (self , target_widget , pname , value ):
45
47
method_props = ('geometry' , 'overrideredirect' , 'title' )
46
48
if pname in method_props :
@@ -63,7 +65,8 @@ def _set_property(self, target_widget, pname, value):
63
65
else :
64
66
super (TKToplevel , self )._set_property (target_widget , pname , value )
65
67
66
- register_widget ('tk.Toplevel' , TKToplevel , 'Toplevel' , ('Containers' , 'tk' , 'ttk' ))
68
+ register_widget ('tk.Toplevel' , TKToplevel ,
69
+ 'Toplevel' , ('Containers' , 'tk' , 'ttk' ))
67
70
68
71
69
72
class TKFrame (BuilderObject ):
@@ -99,7 +102,8 @@ class TKLabelFrame(BuilderObject):
99
102
'text' , 'takefocus' , 'width' ]
100
103
#TODO: Add helper so the labelwidget can be configured on GUI
101
104
102
- register_widget ('tk.LabelFrame' , TKLabelFrame , 'LabelFrame' , ('Containers' , 'tk' ))
105
+ register_widget ('tk.LabelFrame' , TKLabelFrame ,
106
+ 'LabelFrame' , ('Containers' , 'tk' ))
103
107
104
108
105
109
class TKEntry (EntryBaseBO ):
@@ -114,7 +118,7 @@ class TKEntry(EntryBaseBO):
114
118
'selectborderwidth' , 'selectforeground' , 'show' , 'state' ,
115
119
'takefocus' , 'textvariable' , 'validate' , 'validatecommand' ,
116
120
'invalidcommand' , 'width' , 'wraplength' , 'xscrollcommand' ,
117
- 'text' , # < text is a custom property
121
+ 'text' , # < text is a custom property
118
122
'validatecommand_args' ,
119
123
'invalidcommand_args' ]
120
124
command_properties = ('validatecommand' , 'invalidcommand' ,
@@ -156,7 +160,7 @@ class TKCheckbutton(BuilderObject):
156
160
157
161
158
162
class TKListbox (BuilderObject ):
159
- class_ = tk .Listbox
163
+ class_ = tk .Listbox
160
164
container = False
161
165
properties = ['activestyle' , 'background' , 'borderwidth' , 'cursor' ,
162
166
'disabledforeground' , 'exportselection' , 'font' ,
@@ -167,7 +171,8 @@ class TKListbox(BuilderObject):
167
171
'yscrollcommand' ]
168
172
command_properties = ('xscrollcommand' , 'yscrollcommand' )
169
173
170
- register_widget ('tk.Listbox' , TKListbox , 'Listbox' , ('Control & Display' , 'tk' ))
174
+ register_widget ('tk.Listbox' , TKListbox ,
175
+ 'Listbox' , ('Control & Display' , 'tk' ))
171
176
172
177
173
178
class TKText (BuilderObject ):
@@ -182,20 +187,19 @@ class TKText(BuilderObject):
182
187
'selectborderwidth' , 'selectforeground' , 'spacing1' ,
183
188
'spacing2' , 'spacing3' , 'state' , 'tabs' , 'takefocus' ,
184
189
'undo' , 'width' , 'wrap' , 'xscrollcommand' , 'yscrollcommand' ,
185
- 'text' ] # <- text is a custom property.
190
+ 'text' ] # <- text is a custom property.
186
191
command_properties = ('xscrollcommand' , 'yscrollcommand' )
187
192
188
193
def _set_property (self , target_widget , pname , value ):
189
194
if pname == 'text' :
190
195
target_widget .insert ('0.0' , value )
191
196
else :
192
- super (TKText , self )._set_property (target_widget ,pname , value )
197
+ super (TKText , self )._set_property (target_widget , pname , value )
193
198
194
199
195
200
register_widget ('tk.Text' , TKText , 'Text' , ('Control & Display' , 'tk' , 'ttk' ))
196
201
197
202
198
-
199
203
class TKPanedWindow (PanedWindow ):
200
204
class_ = tk .PanedWindow
201
205
allowed_children = ('tk.PanedWindow.Pane' ,)
@@ -223,7 +227,8 @@ class TKMenubutton(BuilderObject):
223
227
def add_child (self , bobject ):
224
228
self .widget .configure (menu = bobject .widget )
225
229
226
- register_widget ('tk.Menubutton' , TKMenubutton , 'Menubutton' , ('Control & Display' , 'tk' ,))
230
+ register_widget ('tk.Menubutton' , TKMenubutton ,
231
+ 'Menubutton' , ('Control & Display' , 'tk' ,))
227
232
228
233
229
234
class TKMessage (BuilderObject ):
@@ -309,7 +314,8 @@ def configure(self):
309
314
self .properties ['to' ] = str (to )
310
315
super (TKSpinbox , self ).configure ()
311
316
312
- register_widget ('tk.Spinbox' , TKSpinbox , 'Spinbox' , ('Control & Display' , 'tk' ))
317
+ register_widget ('tk.Spinbox' , TKSpinbox ,
318
+ 'Spinbox' , ('Control & Display' , 'tk' ))
313
319
314
320
315
321
class TKMenu (BuilderObject ):
@@ -362,7 +368,7 @@ class TKMenuitem(BuilderObject):
362
368
'background' , 'bitmap' , 'columnbreak' , 'command' , 'compound' ,
363
369
'font' , 'foreground' , 'hidemargin' , 'image' , 'label' , 'state' ,
364
370
'underline' ,
365
- 'command_id_arg' , # << custom property !!
371
+ 'command_id_arg' , # << custom property !!
366
372
]
367
373
command_properties = ('command' ,)
368
374
allow_bindings = False
@@ -391,7 +397,6 @@ def configure(self):
391
397
def layout (self ):
392
398
pass
393
399
394
-
395
400
def _create_callback (self , cpname , callback ):
396
401
command = callback
397
402
include_id = self .properties .get ('command_id_arg' , 'False' )
@@ -425,7 +430,6 @@ def realize(self, parent):
425
430
master .add (tk .CASCADE , ** item_properties )
426
431
return self .widget
427
432
428
-
429
433
def configure (self ):
430
434
pass
431
435
@@ -471,7 +475,7 @@ class TKMenuitemSeparator(TKMenuitem):
471
475
command_properties = tuple ()
472
476
473
477
register_widget ('tk.Menuitem.Separator' , TKMenuitemSeparator ,
474
- 'Menuitem.Separator' , ('Pygubu Helpers' ,'tk' , 'ttk' ))
478
+ 'Menuitem.Separator' , ('Pygubu Helpers' , 'tk' , 'ttk' ))
475
479
476
480
477
481
class TKPanedWindowPane (PanedWindowPane ):
0 commit comments