← Back to team overview

quickly-talk team mailing list archive

Re: Enhancements for gtk.Builder

 

The branch did contain both. autosignals reads the function name and
processes it, the proposal was to read name and decoration and process
both.

Currently the debate seems to be between

def on_menu_foo_activate(widget):
    do something
on_toolbar_button_foo_activate=on_menu_foo_activate

or

@ui('toolbar_button_foo', 'activate)
def on_menu_foo_activate(widget):
    do something

Both assuming automatic connection. This depends on whether "do
something" takes many lines of code or few. Best practice points at
"do something" being few lines because complex code is best in a
non-gui class with unittests. If so post decoration seems adequate.

Confining the auto connect to name suffers if widget names do not map
to a python name.
BuilderGlue mangles widget names but with function decorations does not need to.

However I think non-python widget names are best excluded from auto
connection and simply logged as unusable e.g. something like

If pyname != name: #  e.g. "1st choice button"
    debug('%s cannot be auto-connected' % name)

Name mangling creates unpredictable effects . For instance
widgets names  "1group", "2group", "3group"
 and
handler = _group_clicked_event(...)

gives use a group handler, but also triggers a bug.



References