0

I read this tutorial- https://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html

It says in the first para -

Gtk.Application encompasses many repetitive tasks that a modern application needs such as handling multiple instances, D-Bus activation, opening files, command line parsing, startup/shutdown, menu management, window management, and more.

How do I do startup/shutdown, window management and menu management using Gtk.Application? I could not find any tutorials, examples or API documentation. Can anyone suggest how to do this? I am using Python 2.7.14 and Pygobject(pygi-aio-3.24.1_rev1-setup). Thank in Advance.

Rohit S
  • 518
  • 5
  • 16
  • I have multiple windows which reside in multiple glade files which are expected to be loaded as needed. – Rohit S Jan 07 '18 at 08:23
  • On the previous question, you said you don't want the app to appear to switch windows. Is this still true, or are you dealing with a different problem? – theGtknerd Jan 07 '18 at 13:32
  • Nope same problem. I am taking change = switch meaning here. I dont want it look like different window opened. Just want it to change windows like any normal simple application. Nothing more. – Rohit S Jan 07 '18 at 14:49
  • Ok, it seems like you are used to something different than Gtk. In Gtk, if you change windows, it will look exactly that. Now, like JoseFonte said in Gtk chat, you can switch widgets within a Gtk window. But a GtkApplication is not going to help you do that. – theGtknerd Jan 08 '18 at 00:13

1 Answers1

1

startup/shutdown means to start or shut down the app. Which makes it easier to launch your app by double clicking a file that would normally be used in said app. Simple example

menu management This can create a global, identical menu for all windows within your GtkApplication. It can also make Mac menus easier. Since it looks like you are using Windows, this won't really help you. docs

window management You can control and monitor which windows are opened or being used, and then reopen those windows next time your app is launched. docs

Some of these features can be used for other purposes, but most GtkApplication features only are useful for advanced programming requirements.

theGtknerd
  • 3,647
  • 1
  • 13
  • 34
  • I saw the documentation you linked. But it is not making any sense. Specifically for one there is a function to add window but there is no direct function to show a specific window. Then do I show window with just show() method by getting that specific window? Is this correct way to use it? I couldnt figure out myself and also didnt find any examples where this particular point is covered. – Rohit S Jan 08 '18 at 13:20
  • You probably won't find examples, as I have yet to see somebody need/use it. It is there for edge cases. Yes, I assume after you get the window object, you would show() it. – theGtknerd Jan 08 '18 at 14:12
  • Ok. I will try that approach. – Rohit S Jan 08 '18 at 17:01
  • check [GNOME HowDoI](https://wiki.gnome.org/HowDoI/) and GtkWindow [present](https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-present) / [present_with_time](https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-present-with-time) – José Fonte Jan 09 '18 at 13:38