PyGObject-Tutorial
PyGObject-Tutorial copied to clipboard
Menus, Actions
It looks like that the currently suggested way to create MenuBars and ToolBars is deprecated?
python-gtk-3-tutorial.readthedocs.io/en/latest/menus.html
https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Action.html#Gtk.Action
How can a new user know how to solve this now? I can not find any example code using the new solution.
It links to the page for the replacements: https://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html
Gio.Action and Gio.Menu. Toolbars aren't deprecated and you can assign Gio.Action's to any button in them.
I don't see this link https://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html on that page https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Action.html#Gtk.Action
Anyway. Menus and Toolbars are not explained. There is only a fancy example about application menus. I have never seen an "application menu" before - kind of exotic? Is this plattform independent?
Where can I find infos (syntax, definitions, ...) about the XML file? I need some more usual stuff like a menubar and a toolbar. ;)
I have never seen an "application menu" before - kind of exotic? Is this plattform independent?
An application menu is just a menu associated with the application. How it appears depends upon your platform.
Where can I find infos (syntax, definitions, ...) about the XML file?
It is poorly documented but:
- https://developer.gnome.org/gio/stable/GMenuModel.html
- https://developer.gnome.org/GMenu/
I need some more usual stuff like a menubar and a toolbar. ;)
I think there is a bit of confusion here. GtkMenuBar and GtkToolBar are not deprecated. GtkAction and GtkUIManager are. GMenu can make menu bars and GAction is just used everywhere.
Of course, there is a lot of confusion. ;)
You wrote yourself that the documentaion is "poor". It is. API Reference is not documentaiton in they way I mean it.
The point is that the concept behind UIManager/GtkBuilder, the XML-string/file and all the possible menus is kind of exotic. So you need to bring this to a new user. The tutorial doesn't - no matter the the UIManager used there is deprecated.
I can add this to my todo list but first I have to understand the concept behind all that myself. ;)
I think this StackOverflow-Question explain my confusion.
Please also see the question How to create PyGObject application with a menubar using Gtk.Builder?.
You can create this with Glade.
See method I mentioned:
- Can't add GtkHeaderBar to window with existing widgets / containers -- GNOME glade issue 499
- Can't add GtkHeaderBar to "Client side window decoration" area -- Debian BTS
In short, use CSD and create Primary menu with popover using Glade with some text editor hacks.
I may write up more on this topic.
Osamu
I finished writing up an example to make .
GTK GUI with PyGObject (9) This page provide HeaderBar with CSD. It uses Glade and describes details.
I have been learning to program with python/Gtk.Template/Glade combination.