pygobject

How to change the layout of a Gtk application on fullscreen?

别等时光非礼了梦想. 提交于 2020-01-03 10:07:19
问题 I'm developing another image viewer using Python and Gtk and the viewer is currently very simple: it consists of a GtkWindow with a GtkTreeView on the left side displaying the list of my images, and a GtkImage on the right side, displaying the actual image. So far, so good. Now, I would like to go fullscreen, and display only the image with a black background, etc. I can see several ways of doing this: I can hide() the window, and display a big GtkImage instead, but I'm loosing all the stuff

Update a Gtk.ProgressBar from another thread or process

青春壹個敷衍的年華 提交于 2020-01-02 14:09:13
问题 I have a GUI with a progressbar. It should show the progress of the work a second thread does. I would like to have something like an event the thread can send to the GUIs progressbar immediatly on each step of the work. But I don't see how this could be done. Python itself offers a Event class for threading situations. But it would block the GUI main thread because of the Event.wait() methode. How does it change the situaton and possible solutions if the second thread is a process? My

Use of the Gtk.GLArea in Pygobject GTK3

家住魔仙堡 提交于 2020-01-01 18:39:18
问题 The documentation for use of the python wrappers for GTk3 are somewhat limited. I have found several of the common widget examples. I am trying to use the Gtk.GLArea widget. The API documentation is for C and I have not had much luck guessing the equivalent python calls to use this widget. In the example the widget is created using the following C code: // create a GtkGLArea instance GtkWidget *gl_area = gtk_gl_area_new (); g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL); Then

How to install PyGObject with Python 3 support

独自空忆成欢 提交于 2020-01-01 10:43:29
问题 I've been trying to install PyGObject using a variety of methods. First, using apt-get but that only installs it for Python 2.x. Next I attempted to compile it myself but I have been having problems getting it to compile for Python 3. Does anyone know how to install it? 回答1: First you need to install python3 and the development headers. Then you need to tell configure to use python3: PYTHON=python3 ./configure Compile and install normally make make install You should then be able to use

How to change/switch windows using Gtk.Application Gtk+3 Glade Python?

烂漫一生 提交于 2019-12-25 12:38:26
问题 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

Construct class from superclass instance

风流意气都作罢 提交于 2019-12-24 11:44:56
问题 So you have some function, say Gtk.Builder.get_object() , which returns some widget. In our case a Gtk.Window() . I have a subclass of Gtk.Window() which adds some signal handlers. class Window(Gtk.Window): Is it possible to use the widget returned by Gtk.Builder.get_object() to construct Window() ? I think it should be using __new__() or something, but I can't figure it out. 回答1: I think using __new__ is exactly what you want to be doing. If you can set the __class__ attribute of the

How can I retrieve from a GTK Builder the name of an object? [duplicate]

核能气质少年 提交于 2019-12-24 04:32:46
问题 This question already has answers here : Python GTK+ widget name (3 answers) Closed 6 years ago . How do I get the name of a Gtk.Widget retrieved from a Builder object? I specifically mean the name seen in Glade (eg: button1 ), not the name of the class ( GtkWindow ). This question is exactly the same as this one, but for Python with GObject introspection. 回答1: You can't use the get_name method inherited from Gtk.Widget . Instead, you have to use the get_name method defined in Gtk.Buildable ,

How can I retrieve from a GTK Builder the name of an object? [duplicate]

ε祈祈猫儿з 提交于 2019-12-24 04:32:13
问题 This question already has answers here : Python GTK+ widget name (3 answers) Closed 6 years ago . How do I get the name of a Gtk.Widget retrieved from a Builder object? I specifically mean the name seen in Glade (eg: button1 ), not the name of the class ( GtkWindow ). This question is exactly the same as this one, but for Python with GObject introspection. 回答1: You can't use the get_name method inherited from Gtk.Widget . Instead, you have to use the get_name method defined in Gtk.Buildable ,

Programatically add new menu items to menu item PyGObject?

萝らか妹 提交于 2019-12-24 03:53:26
问题 I had this set up in wxPython, but now I'm rewriting it for GTK3/PyGObject, and I'm kind of lost here. Basically, my code scans through a directory, and adds the names of files to a menu item. I can't get it to work in PyGObject. Here is the current code: # Populate profiles menu profileMenu = self.builder.get_object("profilesMenu") profiles = os.listdir("/etc/netctl/") # Iterate through profiles directory, and add to "Profiles" Menu # for i in profiles: if os.path.isfile("/etc/netctl/" + i):

Gtk ComboBox width based on contents

半腔热情 提交于 2019-12-23 21:00:31
问题 I'm dynamically populating the options to a GTK3 ComboBox that has an Entry. Some the options can be quite long, and I'd like to be able to make the ComboBox wider if there are wide items in my model. Is there a way to do this? (It would be especially nice if the combobox could be expanded automatically but with an upper limit that could be set.) 来源: https://stackoverflow.com/questions/11975230/gtk-combobox-width-based-on-contents