how to show screen keyboard ubuntu with python

Solutions on MaxInterview for how to show screen keyboard ubuntu with python by the best coders in the world

showing results for - "how to show screen keyboard ubuntu with python"
Greta
09 Sep 2020
1#!/usr/bin/env python3
2import gi
3gi.require_version('Gtk', '3.0')
4from gi.repository import Gtk
5import signal
6import subprocess
7
8class CallKeyboardTest:
9
10    def __init__(self):
11        
12        # window definition
13        window = Gtk.Window(title="Test 123")
14        window.connect('destroy', Gtk.main_quit)
15        # maingrid
16        maingrid = Gtk.Grid()
17        maingrid.set_border_width(12)
18        window.add(maingrid)
19        # two different fields, one is calling the keyboard, the other isn't
20        testfield = Gtk.Entry()
21        testfield.connect('focus-in-event', self.focus_in)
22        testfield.connect('focus-out-event', self.focus_out)
23        otherfield = Gtk.Entry()
24        maingrid.attach(testfield, 0, 0, 1, 1)
25        maingrid.attach(otherfield, 0, 1, 1, 1)
26        window.show_all()
27        Gtk.main()
28        
29    def focus_out(self, entry, event):
30        subprocess.Popen(["pkill", "onboard"])
31
32    def focus_in(self, entry, event):
33        subprocess.Popen("onboard")
34
35    def stop_prefs(self, *args):
36        Gtk.main_quit()
37
38if __name__ == "__main__":
39    CallKeyboardTest()
40
similar questions