Jak pokazać klawiaturę ekranową Ubuntu z Pythonem
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import signal
import subprocess
class CallKeyboardTest:
def __init__(self):
# window definition
window = Gtk.Window(title="Test 123")
window.connect('destroy', Gtk.main_quit)
# maingrid
maingrid = Gtk.Grid()
maingrid.set_border_width(12)
window.add(maingrid)
# two different fields, one is calling the keyboard, the other isn't
testfield = Gtk.Entry()
testfield.connect('focus-in-event', self.focus_in)
testfield.connect('focus-out-event', self.focus_out)
otherfield = Gtk.Entry()
maingrid.attach(testfield, 0, 0, 1, 1)
maingrid.attach(otherfield, 0, 1, 1, 1)
window.show_all()
Gtk.main()
def focus_out(self, entry, event):
subprocess.Popen(["pkill", "onboard"])
def focus_in(self, entry, event):
subprocess.Popen("onboard")
def stop_prefs(self, *args):
Gtk.main_quit()
if __name__ == "__main__":
CallKeyboardTest()
Tough Tern