/
bunnysuite_gui.py
631 lines (538 loc) · 31.4 KB
/
bunnysuite_gui.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#! /usr/bin/env python
#
# GUI module generated by PAGE version 4.7
# In conjunction with Tcl version 8.6
# Aug 17, 2016 09:40:46 AM
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = 0
except ImportError:
import tkinter.ttk as ttk
py3 = 1
import gui_support, tooltip
def vp_start_gui(save=None, deselected=[]):
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
root.resizable(0,0)
gui_support.set_Tk_var()
top = Bunnysuite (root)
gui_support.init(root, top, save=save, deselected=deselected)
root.mainloop()
w = None
def create_Bunnysuite(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
gui_support.set_Tk_var()
top = Bunnysuite (w)
gui_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Bunnysuite():
global w
w.destroy()
w = None
class Bunnysuite:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
self.style = ttk.Style()
#if sys.platform == "win32":
# self.style.theme_use('winnative')
self.style.configure('.',background=_bgcolor)
self.style.configure('.',foreground=_fgcolor)
self.style.configure('.',font="TkDefaultFont")
self.style.map('.',background=
[('selected', _compcolor), ('active',_ana2color)])
top.geometry("450x690+755+34")
top.title("Bunnysuite 1.0")
top.configure(background="#d9d9d9")
top.configure(highlightbackground="#d9d9d9")
top.configure(highlightcolor="black")
### Framework selection ###
self.frameworksFrame = ttk.Frame(top)
self.frameworksFrame.place(relx=0.04, rely=0.03, relheight=0.2
, relwidth=0.92)
self.frameworksFrame.configure(relief=GROOVE,
borderwidth="2",
width=405)
self.frameworksLabel = ttk.Label(self.frameworksFrame)
self.frameworksLabel.place(relx=0.02, rely=0.05, height=19, width=86)
self.frameworksLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''Frameworks''')
self.possibleFrameworksLabel = ttk.Label(self.frameworksFrame)
self.possibleFrameworksLabel.place(relx=0.02, rely=0.2, height=19
, width=56)
self.possibleFrameworksLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''possible''')
self.possibleFrameworksList = ScrolledListBox(self.frameworksFrame)
self.possibleFrameworksList.place(relx=0.02, rely=0.37, relheight=0.56
, relwidth=0.4)
self.possibleFrameworksList.configure(background="white",
disabledforeground="#a3a3a3",
font="TkFixedFont",
foreground="black",
highlightbackground="#d9d9d9",
highlightcolor="#d9d9d9",
selectbackground="#c4c4c4",
selectforeground="black",
selectmode=EXTENDED,
width=10)
self.chosenFrameworksLabel = ttk.Label(self.frameworksFrame)
self.chosenFrameworksLabel.place(relx=0.59, rely=0.22, height=19
, width=56)
self.chosenFrameworksLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''chosen''')
self.chosenFrameworksList = ScrolledListBox(self.frameworksFrame)
self.chosenFrameworksList.place(relx=0.57, rely=0.37, relheight=0.56
, relwidth=0.4)
self.chosenFrameworksList.configure(background="white",
disabledforeground="#a3a3a3",
font="TkFixedFont",
foreground="black",
highlightbackground="#d9d9d9",
highlightcolor="#d9d9d9",
selectbackground="#c4c4c4",
selectforeground="black",
selectmode=EXTENDED,
width=10)
self.chooseButton = ttk.Button(self.frameworksFrame)
self.chooseButton.place(relx=0.46, rely=0.44, height=25, width=24)
self.chooseButton.configure(command=gui_support.cmdChoose,
text='''>''')
tooltip.createToolTip(self.chooseButton, "include selected frameworks in the test")
self.unchooseButton = ttk.Button(self.frameworksFrame)
self.unchooseButton.place(relx=0.46, rely=0.67, height=25, width=24)
self.unchooseButton.configure(command=gui_support.cmdUnchoose,
text='''<''')
tooltip.createToolTip(self.unchooseButton, "exclude selected frameworks from the test")
### Modifier selection ###
self.modifierFrame = ttk.Frame(top)
self.modifierFrame.place(relx=0.04, rely=0.25, relheight=0.3
, relwidth=0.92)
self.modifierFrame.configure(borderwidth="2",
relief=GROOVE,
width=425)
self.modifiersLabel = ttk.Label(self.modifierFrame)
self.modifiersLabel.place(relx=0.34, rely=0.03, height=19, width=79)
self.modifiersLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''Test modifiers''')
self.style.map('TCheckbutton',background=
[('selected', _bgcolor), ('active',_ana2color)])
self.checkAnimation = ttk.Checkbutton(self.modifierFrame)
self.checkAnimation.place(relx=0.34, rely=0.15, relwidth=0.21
, relheight=0.0, height=21)
self.checkAnimation.configure(variable=gui_support.animation,
onvalue="animation",
offvalue="",
text='''animation''')
tooltip.createToolTip(self.checkAnimation, "Each bunny is initialized with a random speed value in X and Y direction. Once a bunny reaches the border of the screen, its direction is reversed. It is also affected by gravity. Both X and Y speed have a max value. With each frame the position of each bunny is updated according to its speed. This gives the illusion of a jumping animation.")
self.checkScaled = ttk.Checkbutton(self.modifierFrame)
self.checkScaled.place(relx=0.34, rely=0.55, relwidth=0.19, relheight=0.0
, height=21)
self.checkScaled.configure(variable=gui_support.scaled,
onvalue="scaled",
offvalue="",
text='''scaled''')
tooltip.createToolTip(self.checkScaled, "Bunnies are initialized with scaled width and height, each by a random value between 0.2 and 5.")
self.checkRandom = ttk.Checkbutton(self.modifierFrame)
self.checkRandom.place(relx=0.34, rely=0.35, relwidth=0.21, relheight=0.0
, height=21)
self.checkRandom.configure(variable=gui_support.random,
onvalue="random",
offvalue="",
text='''random''')
tooltip.createToolTip(self.checkRandom, "Bunnies are initialized with a random position.")
self.checkRotation = ttk.Checkbutton(self.modifierFrame)
self.checkRotation.place(relx=0.34, rely=0.25, relwidth=0.2
, relheight=0.0, height=21)
self.checkRotation.configure(variable=gui_support.rotation,
onvalue="rotation",
offvalue="",
text='''rotation''')
tooltip.createToolTip(self.checkRotation, "Bunnies rotate clockwise by 1 degree each frame.")
self.checkMultitexture = ttk.Checkbutton(self.modifierFrame)
self.checkMultitexture.place(relx=0.66, rely=0.15, relwidth=0.24,
relheight=0.0, height=21)
self.checkMultitexture.configure(variable=gui_support.multitexture,
onvalue="multitexture",
offvalue="",
text='''multitexture''')
tooltip.createToolTip(self.checkMultitexture, "Adds two different colored bunnies to the texture pool.")
self.checkTexturechange = ttk.Checkbutton(self.modifierFrame)
self.checkTexturechange.place(relx=0.66, rely=0.55, relwidth=0.26
, relheight=0.0, height=21)
self.checkTexturechange.configure(variable=gui_support.texturechange,
onvalue="texturechange",
offvalue="",
text='''texturechange''')
tooltip.createToolTip(self.checkTexturechange, "With each frame each bunny changes its texture randomly to one of the available textures.")
self.checkAlpha = ttk.Checkbutton(self.modifierFrame)
self.checkAlpha.place(relx=0.66, rely=0.25, relwidth=0.2, relheight=0.0
, height=21)
self.checkAlpha.configure(variable=gui_support.alpha,
onvalue="alpha",
offvalue="",
text='''alpha''')
tooltip.createToolTip(self.checkAlpha, "Adds texture with lots of alpha values to the texture pool.")
self.checkHd = ttk.Checkbutton(self.modifierFrame)
self.checkHd.place(relx=0.66, rely=0.35, relwidth=0.2, relheight=0.0
, height=21)
self.checkHd.configure(variable=gui_support.hdtexture,
onvalue="hdtexture",
offvalue="",
text='''hdtexture''')
tooltip.createToolTip(self.checkHd, "Adds high resolution texture to the texture pool. The texture is downscaled before rendering.")
self.checkTeleport = ttk.Checkbutton(self.modifierFrame)
self.checkTeleport.place(relx=0.34, rely=0.45, relwidth=0.2
, relheight=0.0, height=21)
self.checkTeleport.configure(variable=gui_support.teleport)
self.checkTeleport.configure(onvalue="teleport",
offvalue="",
text='''teleport''')
tooltip.createToolTip(self.checkTeleport, "Bunnies are drawn each frame at a new, random position.")
self.checkPulsation = ttk.Checkbutton(self.modifierFrame)
self.checkPulsation.place(relx=0.34, rely=0.65, relwidth=0.2
, relheight=0.0, height=21)
self.checkPulsation.configure(variable=gui_support.pulsation,
onvalue="pulsation",
offvalue="",
text='''pulsation''')
tooltip.createToolTip(self.checkPulsation, "With each frame, the scale of each bunny is changed (initial growth +0.1). Once the scale >=5 or <=0.2, the growth rate is multiplied by -1.")
self.checkTinted = ttk.Checkbutton(self.modifierFrame)
self.checkTinted.place(relx=0.34, rely=0.75, relwidth=0.16, relheight=0.0
, height=21)
self.checkTinted.configure(variable=gui_support.tinted,
onvalue="tinted",
offvalue="",
text='''tinted''',
width=64)
tooltip.createToolTip(self.checkTinted, "Each bunny is initialized with its texture tinted in a random non transparent color.")
self.checkColorchange = ttk.Checkbutton(self.modifierFrame)
self.checkColorchange.place(relx=0.34, rely=0.85, relwidth=0.25
, relheight=0.0, height=21)
self.checkColorchange.configure(variable=gui_support.colorchange,
onvalue="colorchange",
offvalue="",
text='''colorchange''',
width=101)
tooltip.createToolTip(self.checkColorchange, "Each frame each bunny is tinted in a new random color.")
self.checkThin = ttk.Checkbutton(self.modifierFrame)
self.checkThin.place(relx=0.66, rely=0.45, relwidth=0.16, relheight=0.0
, height=21)
self.checkThin.configure(variable=gui_support.thin,
onvalue="thin",
offvalue="",
text='''thin''')
tooltip.createToolTip(self.checkThin, "Adds an alternative bunny texture to the texture pool.")
self.checkBunnies = ttk.Checkbutton(self.modifierFrame)
self.checkBunnies.place(relx=0.02, rely=0.15, relwidth=0.21
, relheight=0.0, height=21)
self.checkBunnies.configure(state=DISABLED,
variable=gui_support.bunnies,
command=gui_support.cmdUpdateTextureModifiers,
onvalue="bunnies",
offvalue="",
text='''bunnies''')
tooltip.createToolTip(self.checkBunnies, "Draws bunnies.")
self.checkRectangles = ttk.Checkbutton(self.modifierFrame)
self.checkRectangles.place(relx=0.02, rely=0.25, relwidth=0.24
, relheight=0.0, height=21)
self.checkRectangles.configure(variable=gui_support.rectangles,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="rectangles",
offvalue="",
text='''rectangles''')
tooltip.createToolTip(self.checkRectangles, "Draws rectangles of size 26 * 37.")
self.checkCircles = ttk.Checkbutton(self.modifierFrame)
self.checkCircles.place(relx=0.02, rely=0.35, relwidth=0.19
, relheight=0.0, height=21)
self.checkCircles.configure(variable=gui_support.circles,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="circles",
offvalue="",
text='''circles''')
tooltip.createToolTip(self.checkCircles, "Draws circles of random color with radius 13. Not affected by rotation (duh).")
self.checkTriangles = ttk.Checkbutton(self.modifierFrame)
self.checkTriangles.place(relx=0.02, rely=0.45, relwidth=0.21
, relheight=0.0, height=21)
self.checkTriangles.configure(variable=gui_support.triangles,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="triangles",
offvalue="",
text='''triangles''')
tooltip.createToolTip(self.checkTriangles, "Draws triangles of random color.")
self.checkLines = ttk.Checkbutton(self.modifierFrame)
self.checkLines.place(relx=0.02, rely=0.55, relwidth=0.16, relheight=0.0
, height=21)
self.checkLines.configure(variable=gui_support.lines,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="lines",
offvalue="",
text='''lines''')
tooltip.createToolTip(self.checkLines, "Draws lines of random color.")
self.checkPoints = ttk.Checkbutton(self.modifierFrame)
self.checkPoints.place(relx=0.02, rely=0.65, relwidth=0.21
, relheight=0.0, height=21)
self.checkPoints.configure(variable=gui_support.points,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="points",
offvalue="",
text='''points''')
tooltip.createToolTip(self.checkPoints, "Draws points (single pixels) of random color. Not affected by rotation and scale (duh).")
self.checkTexts = ttk.Checkbutton(self.modifierFrame)
self.checkTexts.place(relx=0.02, rely=0.75, relwidth=0.16, relheight=0.0
, height=21)
self.checkTexts.configure(variable=gui_support.texts,
command=gui_support.cmdUpdateBunniesCheckbox,
onvalue="texts",
offvalue="",
text='''texts''')
tooltip.createToolTip(self.checkTexts, "Draws 'Hello World!'. Not affected by rotation and scale.")
self.textureLabel = ttk.Label(self.modifierFrame)
self.textureLabel.place(relx=0.66, rely=0.03, height=19, width=116)
self.textureLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''Texture modifiers''')
self.flavoursLabel = ttk.Label(self.modifierFrame)
self.flavoursLabel.place(relx=0.02, rely=0.03, height=19, width=116)
self.flavoursLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''Flavour modifiers''')
self.checkNoOutput = ttk.Checkbutton(self.modifierFrame)
self.checkNoOutput.place(relx=0.66, rely=0.85, relwidth=0.26
, relheight=0.0, height=21)
self.checkNoOutput.configure(variable=gui_support.no_output,
onvalue="no_output",
offvalue="",
text='''no_output''')
tooltip.createToolTip(self.checkNoOutput, "Disables drawing. All calculations are still done, allowing to estimate the influence of the CPU on the result.")
### Arguments selection ###
self.argumentsFrame = ttk.Frame(top)
self.argumentsFrame.place(relx=0.04, rely=0.57, relheight=0.25
, relwidth=0.92)
self.argumentsFrame.configure(borderwidth="2",
relief=GROOVE,
width=425)
self.minBunniesLabel = ttk.Label(self.argumentsFrame)
self.minBunniesLabel.place(relx=0.02, rely=0.06, height=19, width=90)
self.minBunniesLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''min bunnies''')
tooltip.createToolTip(self.minBunniesLabel, "the amount of bunnies the test starts with")
self.minBunniesScale = ttk.Scale(self.argumentsFrame)
self.minBunniesScale.place(relx=0.29, rely=0.06, relwidth=0.38
, relheight=0.0, height=26)
self.minBunniesScale.configure(command=gui_support.cmdMinBunnies,
variable=gui_support.minBunnies,
to="100000",
length="150")
self.minBunniesEntry = ttk.Entry(self.argumentsFrame)
self.minBunniesEntry.place(relx=0.76, rely=0.07, relheight=0.14
, relwidth=0.21)
self.minBunniesEntry.configure(textvariable=gui_support.minBunniesEntry,
validate="all",
validatecommand=(root.register(gui_support.validateMinBunnies), '%P', '%V'),
width=86,
cursor="xterm")
self.maxBunniesLabel = ttk.Label(self.argumentsFrame)
self.maxBunniesLabel.place(relx=0.02, rely=0.23, height=19, width=86)
self.maxBunniesLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''max bunnies''')
tooltip.createToolTip(self.maxBunniesLabel, "the amount of bunnies at which the test terminates")
self.maxBunniesScale = ttk.Scale(self.argumentsFrame)
self.maxBunniesScale.place(relx=0.29, rely=0.23, relwidth=0.38
, relheight=0.0, height=26)
self.maxBunniesScale.configure(command=gui_support.cmdMaxBunnies,
variable=gui_support.maxBunnies,
to="100000",
value="20000",
length="150")
self.maxBunniesEntry = ttk.Entry(self.argumentsFrame)
self.maxBunniesEntry.place(relx=0.76, rely=0.24, relheight=0.14
, relwidth=0.21)
self.maxBunniesEntry.configure(textvariable=gui_support.maxBunniesEntry,
validate="all",
validatecommand=(root.register(gui_support.validateMaxBunnies), '%P', '%V'),
width=86,
cursor="xterm")
self.stepSizeLabel = ttk.Label(self.argumentsFrame)
self.stepSizeLabel.place(relx=0.02, rely=0.4, height=19, width=56)
self.stepSizeLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''step size''')
tooltip.createToolTip(self.stepSizeLabel, "the amount of bunnies that is added each step")
self.stepSizeScale = ttk.Scale(self.argumentsFrame)
self.stepSizeScale.place(relx=0.29, rely=0.4, relwidth=0.38
, relheight=0.0, height=26)
self.stepSizeScale.configure(command=gui_support.cmdStepSize,
variable=gui_support.stepSize,
from_="1",
to="10000",
value="1000",
length="150")
self.stepSizeEntry = ttk.Entry(self.argumentsFrame)
self.stepSizeEntry.place(relx=0.76, rely=0.41, relheight=0.14
, relwidth=0.21)
self.stepSizeEntry.configure(textvariable=gui_support.stepSizeEntry,
validate="all",
validatecommand=(root.register(gui_support.validateStepSize), '%P', '%V'),
width=86,
cursor="xterm")
self.repetitionsLabel = ttk.Label(self.argumentsFrame)
self.repetitionsLabel.place(relx=0.02, rely=0.57, height=19, width=60)
self.repetitionsLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''repetitions''')
tooltip.createToolTip(self.maxBunniesLabel, "the amount of times each step is repeated before new bunnies are added (the render time is still measured for each frame and averaged at the end of the step)")
self.repetitionsScale = ttk.Scale(self.argumentsFrame)
self.repetitionsScale.place(relx=0.29, rely=0.57, relwidth=0.38
, relheight=0.0, height=26)
self.repetitionsScale.configure(command=gui_support.cmdRepetitions,
variable=gui_support.repetitions,
from_="1",
to="100",
value="10",
length="150")
self.repetitionsEntry = ttk.Entry(self.argumentsFrame)
self.repetitionsEntry.place(relx=0.76, rely=0.58, relheight=0.12
, relwidth=0.21)
self.repetitionsEntry.configure(textvariable=gui_support.repetitionsEntry,
validate="all",
validatecommand=(root.register(gui_support.validateRepetitions), '%P', '%V'),
width=86,
cursor="xterm")
self.resolutionLabel = ttk.Label(self.argumentsFrame)
self.resolutionLabel.place(relx=0.02, rely=0.8, height=19, width=77)
self.resolutionLabel.configure(background=_bgcolor,
foreground="#000000",
relief=FLAT,
text='''resolution''',
width=77)
self.resCombobox = ttk.Combobox(self.argumentsFrame)
self.resCombobox.place(relx=0.29, rely=0.8, relheight=0.14
, relwidth=0.68)
self.resCombobox.configure(textvariable=gui_support.resolution,
background="#000000",
state="readonly",
values=["640x480","800x600","1280x720","1680x1050","1920x1080"])
### Presets selection ###
self.presetsFrame = ttk.Frame(top)
self.presetsFrame.place(relx=0.04, rely=0.84, relheight=0.08
, relwidth=0.92)
self.presetsFrame.configure(relief=GROOVE,
borderwidth="2",
width=425)
self.presetsCheckbox = ttk.Checkbutton(self.presetsFrame)
self.presetsCheckbox.place(relx=0.02, rely=0.31, relwidth=0.2
, relheight=0.0, height=21)
self.presetsCheckbox.configure(variable=gui_support.presets,
command=gui_support.cmdTogglePresets,
text='''Use presets''')
self.presetsCombobox = ttk.Combobox(self.presetsFrame)
self.presetsCombobox.place(relx=0.29, rely=0.30, relheight=0.40
, relwidth=0.38)
self.presetsCombobox.configure(state=DISABLED,
textvariable=gui_support.presetsCombobox,
width=153,
validate="key",
validatecommand=(root.register(gui_support.validatePreset), '%P'),
postcommand=gui_support.updatePresets)
self.presetsCombobox.bind("<<ComboboxSelected>>", gui_support.presetSelection)
self.saveButton = ttk.Button(self.presetsFrame)
self.saveButton.place(relx=0.76, rely=0.27, height=25, width=86)
self.saveButton.configure(command=gui_support.cmdSave,
text='''Save''',
state=DISABLED)
self.runButton = ttk.Button(top)
self.runButton.place(relx=0.38, rely=0.94, height=25, width=116)
self.runButton.configure(command=gui_support.cmdRun,
text='''Run''')
# The following code is added to facilitate the Scrolled widgets.
class AutoScroll(object):
'''Configure the scrollbars for a widget.'''
def __init__(self, master):
try:
vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
except:
pass
hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
#self.configure(yscrollcommand=self._autoscroll(vsb),
# xscrollcommand=self._autoscroll(hsb))
try:
self.configure(yscrollcommand=self._autoscroll(vsb))
except:
pass
self.configure(xscrollcommand=self._autoscroll(hsb))
self.grid(column=0, row=0, sticky='nsew')
try:
vsb.grid(column=1, row=0, sticky='ns')
except:
pass
hsb.grid(column=0, row=1, sticky='ew')
master.grid_columnconfigure(0, weight=1)
master.grid_rowconfigure(0, weight=1)
# Copy geometry methods of master (taken from ScrolledText.py)
if py3:
methods = Pack.__dict__.keys() | Grid.__dict__.keys() \
| Place.__dict__.keys()
else:
methods = Pack.__dict__.keys() + Grid.__dict__.keys() \
+ Place.__dict__.keys()
for meth in methods:
if meth[0] != '_' and meth not in ('config', 'configure'):
setattr(self, meth, getattr(master, meth))
@staticmethod
def _autoscroll(sbar):
'''Hide and show scrollbar as needed.'''
def wrapped(first, last):
first, last = float(first), float(last)
if first <= 0 and last >= 1:
sbar.grid_remove()
else:
sbar.grid()
sbar.set(first, last)
return wrapped
def __str__(self):
return str(self.master)
def _create_container(func):
'''Creates a ttk Frame with a given master, and use this new frame to
place the scrollbars and the widget.'''
def wrapped(cls, master, **kw):
container = ttk.Frame(master)
return func(cls, container, **kw)
return wrapped
class ScrolledListBox(AutoScroll, Listbox):
'''A standard Tkinter Text widget with scrollbars that will
automatically show/hide as needed.'''
@_create_container
def __init__(self, master, **kw):
Listbox.__init__(self, master, **kw)
AutoScroll.__init__(self, master)
if __name__ == '__main__':
vp_start_gui()