Native gui some more code
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from gi.repository import Gtk
|
||||
|
||||
def init_named_controls(window, builder):
|
||||
ctrltype = {
|
||||
'lbl': 'label',
|
||||
'ent': 'entry',
|
||||
'but': 'button',
|
||||
'cmb': 'combo',
|
||||
'tvw': 'tree',
|
||||
'spi': 'spin',
|
||||
'txt': 'text',
|
||||
'chk': 'check',
|
||||
'opt': 'radio',
|
||||
'vbx': 'vbox',
|
||||
'hbx': 'hbox',
|
||||
'box': 'box',
|
||||
'tbl': 'table',
|
||||
'mnu': 'menu',
|
||||
'img': 'image',
|
||||
'drw': 'area'
|
||||
}
|
||||
for ctrl in ctrltype.values():
|
||||
setattr(window, ctrl, {})
|
||||
for widget in builder.get_objects():
|
||||
if type(widget) in (Gtk.Adjustment, Gtk.CellRendererText, Gtk.TreeSelection):
|
||||
continue
|
||||
widgetname = Gtk.Buildable.get_name(widget)
|
||||
nameparts = widgetname.partition('_')
|
||||
if (not nameparts[0] in ctrltype.keys()) or (not nameparts[2]):
|
||||
continue
|
||||
var = getattr(window, ctrltype[nameparts[0]])
|
||||
var[nameparts[2]] = widget
|
||||
Reference in New Issue
Block a user