394
395
396
397
398
399
400
401
402
403
404
405
406
407 | w.set_style(s)
# probably redundant, but better safe than sorry:
w.modify_bg(gtk.STATE_NORMAL, c)
# return modified or wrapped widget
return w
@staticmethod
def add_menu(menuwidget, label, action):
m = gtk.MenuItem(label)
m.connect("activate", action)
m.show()
menuwidget.add(m)
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
| 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 | w.set_style(s)
# probably redundant, but better safe than sorry:
w.modify_bg(gtk.STATE_NORMAL, c)
# return modified or wrapped widget
return w
# Create GtkLabel
@staticmethod
def label(text):
label = gtk.Label(text)
label.set_property("visible", True)
label.set_line_wrap(True)
label.set_size_request(400, -1)
return label
# Wrap two widgets in horizontal box
@staticmethod
def hbox(w1, w2):
b = gtk.HBox(homogeneous=False, spacing=10)
b.set_property("visible", True)
b.pack_start(w1, expand=False, fill=False)
b.pack_start(w2, expand=True, fill=True)
return b
#
@staticmethod
def add_menu(menuwidget, label, action):
m = gtk.MenuItem(label)
m.connect("activate", action)
m.show()
menuwidget.add(m)
|
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 |
ls = None
def __init__(self, entries):
# prepare widget
gtk.ComboBox.__init__(self)
cell = gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, "text", 1)
# collect entries
self.ls = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
self.set_model(self.ls)
for value in entries:
self.ls.append([value, value])
# activate dropdown of given value
def set_default(self, value):
for index,row in enumerate(self.ls):
if value in row:
self.set_active(index)
pass
# fetch currently selected text entry
def get_active_text(self):
index = self.get_active()
if index >= 0:
return self.ls[index][0]
|
>
|
|
>
>
| 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 |
ls = None
def __init__(self, entries):
# prepare widget
gtk.ComboBox.__init__(self)
self.set_property("visible", True)
cell = gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, "text", 1)
# collect entries
self.ls = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
self.set_model(self.ls)
for value in entries:
self.ls.append([value, value])
# activate dropdown of given value
def set_default(self, value):
for index,row in enumerate(self.ls):
if value in row:
return self.set_active(index)
# add as custom entry
self.ls.append([value, value])
self.set_active(index + 1)
# fetch currently selected text entry
def get_active_text(self):
index = self.get_active()
if index >= 0:
return self.ls[index][0]
|