[pygtk] Some questions on the UIManager and the ActionGroups
John Finlay
finlay at moeraki.com
Fri Aug 11 09:50:16 WST 2006
Nemesis wrote:
> Hi all,
> I'm rewriting my application in order to use the UIManager and the
> ActionGroups. But I have some problems:
>
> 1) I'd like to use the function ActionGroup.add_actions in order to
> populate the actiongroup. It accepts to arguments a list of tuples
> containing the descriptions of the actions and a second value named
> "user_data" that should be the data passed to the callback.
> I need to send data to some of the callback, but I don't know how to
> specify it.
> I tried creating a list of tuples that contains themselves the data,
> something like that:
> [(tuple1, ..., callback),
> (tuple2, ..., callback,data),
> (tuple3, ..., callback)]
>
> but this format is not accepted by add_actions. at the moment I'm using
> a little workaround:
>
> for action in actions:
> if len(action)<7:
> actiongroup.add_actions([action])
> else:
> actiongroup.add_actions([action[0:6]],action[-1])
>
> but I'd like to implement a cleaner (if exists) solution.
>
You could try using a lambda expression for the callback:
lambda w: callback(w, data)
> 2) Is possible to add labels on a Toolbar when you describe it with the
> UIManager?
> Reading the reference seems that the only items I can put on the Toolbar
> are ToolItems and Separator, is that right?
>
Probably the easiest way is to add a Label to a ToolItem and insert that
in the Toolbar without using the UIManager
John
More information about the pygtk
mailing list