Keyboard Shortcuts in Gmoccapy

More
1 year 7 months ago - 1 year 7 months ago #324403 by HansU
Weird that it works with a small modification in a minimal running example but not in gmoccapy:

Code:
import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk, Gdk class ToggleButtonApp(Gtk.Window):     def __init__(self):         super().__init__(title="Toggle Button Example")         self.set_default_size(200, 100)         self.tbtn_turtle_jog = Gtk.ToggleButton(label="Button is OFF")         self.tbtn_turtle_jog.connect("toggled", self.on_chk_turtle_jog_toggled)         self.add(self.tbtn_turtle_jog)         self.connect("key-press-event", self.on_key_press)     def on_chk_turtle_jog_toggled(self, button):         if button.get_active():             button.set_label("Button is ON")         else:             button.set_label("Button is OFF")     def on_key_press(self, widget, event):         keyname = Gdk.keyval_name(event.keyval)         if keyname == "r" or keyname == "R":             self.tbtn_turtle_jog.set_active(not self.tbtn_turtle_jog.get_active())             return True  # Stop further processing of the event win = ToggleButtonApp() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()


Maybe you have some time to play around and figure it out if it is important for you.
Last edit: 1 year 7 months ago by HansU.

Please Log in or Create an account to join the conversation.

Moderators: newbynobi, HansU
Time to create page: 0.281 seconds
Powered by Kunena Forum