PyGObject-Tutorial icon indicating copy to clipboard operation
PyGObject-Tutorial copied to clipboard

Menus, Actions

Open buhtz opened this issue 7 years ago • 6 comments

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.

buhtz avatar Apr 21 '18 21:04 buhtz

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.

TingPing avatar Apr 21 '18 21:04 TingPing

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. ;)

buhtz avatar Apr 21 '18 22:04 buhtz

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.

TingPing avatar Apr 21 '18 22:04 TingPing

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?.

buhtz avatar Apr 22 '18 10:04 buhtz

You can create this with Glade.

See method I mentioned:

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

osamuaoki avatar Jul 25 '21 16:07 osamuaoki

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.

osamuaoki avatar Jul 26 '21 13:07 osamuaoki