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 | log.UIKIT_EXEC(name)
task()
uikit.in_idle = False
return len(uikit.idle_tasks) > 0
# adds background color to widget,
# eventually wraps it into a gtk.Window, if it needs a container
@staticmethod
def bg(w, color="", where=["bg"], wrap=1):
""" this method should be called after widget creation, and before .add()ing it to container """
if color:
# wrap unstylable widgets into EventBox
if wrap and not isinstance(w, (gtk.Window, gtk.EventBox)):
wrap = gtk.EventBox()
wrap.add(w)
##########wrap.set_property("visible", True)
w = wrap
# copy style object, modify settings
s = w.get_style().copy()
c = w.get_colormap().alloc_color(color)
for state in (gtk.STATE_NORMAL, gtk.STATE_SELECTED, gtk.STATE_ACTIVE):
s.bg[state] = c
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, size=305, markup=0): |
|
|
<
<
>
|
>
>
<
<
<
|
| 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 | log.UIKIT_EXEC(name)
task()
uikit.in_idle = False
return len(uikit.idle_tasks) > 0
# Adds background color to widget,
# eventually wraps it into a gtk.EventBox, if it needs a container
@staticmethod
def bg(w, color="", where=["bg"], wrap=1):
""" this method should be called after widget creation, and before .add()ing it to container """
if color:
# wrap unstylable widgets into EventBox
if wrap and not isinstance(w, (gtk.Window, gtk.EventBox)):
wrap = gtk.EventBox()
wrap.add(w)
w = wrap
# copy style object, modify settings
try: # Gtk2
c = w.get_colormap().alloc_color(color)
except: # Gtk3
p, c = gtk.gdk.Color.parse(color)
for state in (gtk.STATE_NORMAL, gtk.STATE_SELECTED, gtk.STATE_ACTIVE):
w.modify_bg(state, c)
# return modified or wrapped widget
return w
# Create GtkLabel
@staticmethod
def label(text, size=305, markup=0): |