Category : gtk

I have a Python script, which displays images on a projector without user interaction. It calls OpenCV functions, which are using GTK backend. It runs just fine locally. When I try to run it remotely with ssh, I’m getting Can’t initialize GTK backend error: cv2.error: OpenCV(4.5.3) /tmp/pip-wheel-xjhn4aom/opencv-contrib-python_db9bf2c2b8dd41b592a48d20aac72627/opencv/modules/highgui/src/window_gtk.cpp:635: error: (-2:Unspecified error) Can’t initialize GTK backend in ..

Read more

I need to run a Python function by using GLib without freezing/interupting the GTK3 GUI. GLib.timeout_add(millisecond, function_name) is not adequate. More control is needed in my code. But it gives a warning and it does not repeat the function in every seconds when the following code is used: import gi gi.require_version(‘Gtk’, ‘3.0’) from gi.repository import ..

Read more

In this example, I’m trying to add another button (or any widget) every time a button is pressed. from gi.repository import Gtk class ButtonWindow(Gtk.Window): def __init__(self): super().__init__(title="Button Demo") self.hbox = Gtk.HBox() self.add(self.hbox) button = Gtk.Button.new_with_label("Click Me") button.connect("clicked", self.on_clicked) self.hbox.pack_start(button, False, True, 0) def on_clicked(self, button): print("This prints…") button = Gtk.Button.new_with_label("Another button") self.hbox.pack_start(button, False, True, 0) ..

Read more

I want to keep the application running in the background even when all it’s windows are closed. Is there a function or something to do this? I couldn’t find an answer on SO. Here is my code: import gi import sys gi.require_version("Gtk", "3.0") from gi.repository import Gtk class App(Gtk.Application): """The application manager.""" def __init__(self, *args, ..

Read more