Reworked logic - in progress
This commit is contained in:
parent
efb7b108a5
commit
55515a0825
79
1.0.2/__builtins__.py
Normal file
79
1.0.2/__builtins__.py
Normal file
@ -0,0 +1,79 @@
|
||||
# Python imports
|
||||
import builtins, threading
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from utils.pyautogui_control import ControlMixin
|
||||
|
||||
|
||||
|
||||
# NOTE: Threads WILL NOT die with parent's destruction.
|
||||
def threaded_wrapper(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
||||
return wrapper
|
||||
|
||||
# NOTE: Threads WILL die with parent's destruction.
|
||||
def daemon_threaded_wrapper(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
|
||||
class EndpointRegistry():
|
||||
def __init__(self):
|
||||
self._endpoints = {}
|
||||
|
||||
def register(self, rule, **options):
|
||||
def decorator(f):
|
||||
self._endpoints[rule] = f
|
||||
return f
|
||||
|
||||
return decorator
|
||||
|
||||
def get_endpoints(self):
|
||||
return self._endpoints
|
||||
|
||||
class Pyautogui_Controller(ControlMixin):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
keys_json = {
|
||||
"keys": {
|
||||
"row1": {
|
||||
"pKeys": ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
|
||||
"sKeys": ['~', '@', '#', '$', '%', '&', '-', '_', '(', ')'],
|
||||
},
|
||||
"row2": {
|
||||
"pKeys": ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
|
||||
"sKeys": ['\\', '/', '|', ':', '{', '}', '[', ']', '<', '>'],
|
||||
},
|
||||
"row3": {
|
||||
"pKeys": ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', "'"],
|
||||
"sKeys": ['=', '+', '"', '*', '^', '`', ';', '!', '', ''],
|
||||
},
|
||||
"row4": {
|
||||
"pKeys": ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '?'],
|
||||
"sKeys": ['', '', '', '', '', '', '', '', '', '']
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# NOTE: Just reminding myself we can add to builtins two different ways...
|
||||
# __builtins__.update({"event_system": Builtins()})
|
||||
builtins.app_name = "Mouse Keyboard"
|
||||
builtins.endpoint_registry = EndpointRegistry()
|
||||
builtins.typwriter = Pyautogui_Controller()
|
||||
builtins.threaded = threaded_wrapper
|
||||
builtins.daemon_threaded = daemon_threaded_wrapper
|
||||
builtins.keys_set = keys_json
|
||||
builtins.trace_debug = False
|
||||
builtins.debug = False
|
||||
builtins.app_settings = None
|
3
1.0.2/__init__.py
Normal file
3
1.0.2/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""
|
||||
Base module
|
||||
"""
|
42
1.0.2/__main__.py
Normal file
42
1.0.2/__main__.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
|
||||
# Python imports
|
||||
import argparse, faulthandler, traceback
|
||||
from setproctitle import setproctitle
|
||||
|
||||
import tracemalloc
|
||||
tracemalloc.start()
|
||||
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from app import Application
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
""" Set process title, get arguments, and create GTK main thread. """
|
||||
|
||||
try:
|
||||
# import web_pdb
|
||||
# web_pdb.set_trace()
|
||||
|
||||
setproctitle('Mouse Keyboard')
|
||||
faulthandler.enable() # For better debug info
|
||||
parser = argparse.ArgumentParser()
|
||||
# Add long and short arguments
|
||||
parser.add_argument("--new-tab", "-t", default="", help="Open a file into new tab.")
|
||||
parser.add_argument("--new-window", "-w", default="", help="Open a file into a new window.")
|
||||
|
||||
# Read arguments (If any...)
|
||||
args, unknownargs = parser.parse_known_args()
|
||||
|
||||
Application(args, unknownargs)
|
||||
Gtk.main()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
quit()
|
20
1.0.2/app.py
Normal file
20
1.0.2/app.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Python imports
|
||||
import inspect
|
||||
|
||||
|
||||
# Gtk imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from __builtins__ import *
|
||||
from core.window import Window
|
||||
|
||||
|
||||
|
||||
|
||||
class Application(object):
|
||||
def __init__(self, args, unknownargs):
|
||||
try:
|
||||
Window(args, unknownargs)
|
||||
except Exception as e:
|
||||
raise
|
3
1.0.2/core/__init__.py
Normal file
3
1.0.2/core/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""
|
||||
Core module
|
||||
"""
|
3
1.0.2/core/columns/__init__.py
Normal file
3
1.0.2/core/columns/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .left_column import Left_Column
|
||||
from .keys_column import Keys_Column
|
||||
from .right_column import Right_Column
|
64
1.0.2/core/columns/keys_column.py
Normal file
64
1.0.2/core/columns/keys_column.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.key import Key
|
||||
|
||||
|
||||
|
||||
class KeyboardRowMatchError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Keys_Column(Gtk.Box):
|
||||
"""docstring for Keys_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Keys_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.setup_signals()
|
||||
self.setup_key_buttons()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(1) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_property("homogeneous", True)
|
||||
self.set_hexpand(True)
|
||||
|
||||
def setup_signals(self):
|
||||
pass
|
||||
|
||||
def setup_key_buttons(self):
|
||||
keys = keys_set["keys"]
|
||||
children = keys.keys()
|
||||
|
||||
for child in children:
|
||||
pKeys = keys[child]["pKeys"]
|
||||
sKeys = keys[child]["sKeys"]
|
||||
|
||||
row_box = self.add_row()
|
||||
if len(pKeys) == len(sKeys):
|
||||
for i in range(9):
|
||||
pkey = pKeys[i]
|
||||
sKey = sKeys[i]
|
||||
row_box.add(Key(pkey, sKey))
|
||||
else:
|
||||
raise KeyboardRowMatchError("A row in keys_json has missmatched pKeys and sKeys lengths.")
|
||||
|
||||
row_box = self.add_row()
|
||||
for key in ['Symbols', 'Space', 'Backspace']:
|
||||
row_box.add(Key(key, key))
|
||||
|
||||
def add_row(self):
|
||||
row_box = Gtk.Box()
|
||||
row_box.set_property("homogeneous", True)
|
||||
self.add(row_box)
|
||||
|
||||
return row_box
|
37
1.0.2/core/columns/left_column.py
Normal file
37
1.0.2/core/columns/left_column.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
|
||||
class Left_Column(Gtk.Button):
|
||||
"""docstring for Left_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Left_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.setup_signals()
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_label("Caps")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
key_columns = self.get_parent().get_children()[1]
|
||||
limit = len(key_columns.get_children()) - 1
|
||||
|
||||
for i, row in enumerate(key_columns.get_children()):
|
||||
if not i == limit:
|
||||
for key in row:
|
||||
key.emit("toggle-caps", ())
|
31
1.0.2/core/columns/right_column.py
Normal file
31
1.0.2/core/columns/right_column.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
|
||||
class Right_Column(Gtk.Button):
|
||||
"""docstring for Right_Column."""
|
||||
|
||||
def __init__(self):
|
||||
super(Right_Column, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.setup_signals()
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_label("Enter")
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
typwriter.enter()
|
37
1.0.2/core/container.py
Normal file
37
1.0.2/core/container.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .columns import Left_Column, Keys_Column, Right_Column
|
||||
from .signals_mixin import SignalsMixin
|
||||
|
||||
|
||||
|
||||
class Container(SignalsMixin, Gtk.Box):
|
||||
"""docstring for Container."""
|
||||
|
||||
def __init__(self):
|
||||
super(Container, self).__init__()
|
||||
|
||||
self.setup_custom_event_signals()
|
||||
self.setup_styling()
|
||||
self.add_columns()
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
self.set_orientation(0) # HORIZONTAL = 0, VERTICAL = 1
|
||||
self.set_vexpand(True)
|
||||
|
||||
def setup_signals(self):
|
||||
pass
|
||||
|
||||
def add_columns(self):
|
||||
self.add(Left_Column())
|
||||
self.add(Keys_Column())
|
||||
self.add(Right_Column())
|
17
1.0.2/core/signals_mixin.py
Normal file
17
1.0.2/core/signals_mixin.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from gi.repository import GObject
|
||||
|
||||
|
||||
# Application imports
|
||||
from .widgets.key import Key
|
||||
|
||||
|
||||
|
||||
|
||||
class SignalsMixin:
|
||||
"""docstring for SignalsMixin."""
|
||||
|
||||
def setup_custom_event_signals(self):
|
||||
GObject.signal_new('toggle-caps', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
3
1.0.2/core/widgets/__init__.py
Normal file
3
1.0.2/core/widgets/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""
|
||||
Widgets module
|
||||
"""
|
34
1.0.2/core/widgets/key.py
Normal file
34
1.0.2/core/widgets/key.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class Key(Gtk.Button):
|
||||
def __init__(self, primary = "NULL", secondary = "NULL"):
|
||||
super(Key, self).__init__()
|
||||
|
||||
self._primary_symbol = primary
|
||||
self._secondary_symbol = secondary
|
||||
self._is_upper = False
|
||||
|
||||
self.set_label(self._primary_symbol)
|
||||
|
||||
self.setup_signals()
|
||||
|
||||
|
||||
def toggle_caps(self, widget = None, eve = None):
|
||||
self._is_upper = not self._is_upper
|
||||
self.set_label(self._primary_symbol.upper()) if self._is_upper else self.set_label(self._primary_symbol.lower())
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("released", self._clicked)
|
||||
self.connect("toggle-caps", self.toggle_caps)
|
||||
|
||||
def _clicked(self, widget = None):
|
||||
key = self.get_label().strip()
|
||||
typwriter.type(key)
|
36
1.0.2/core/window.py
Normal file
36
1.0.2/core/window.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from .container import Container
|
||||
|
||||
|
||||
|
||||
class Window(Gtk.ApplicationWindow):
|
||||
"""docstring for Window."""
|
||||
|
||||
def __init__(self, args, unknownargs):
|
||||
super(Window, self).__init__()
|
||||
|
||||
self.setup_styling()
|
||||
self.setup_signals()
|
||||
self.add(Container())
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def setup_styling(self):
|
||||
# self.set_icon_from_file("/usr/share/bulkr/bulkr.png")
|
||||
self.set_title(app_name)
|
||||
self.set_default_size(800, 200)
|
||||
self.set_type_hint(3) # 3 = TOOLBAR
|
||||
self.set_gravity(8) # 5 = CENTER, 8 = SOUTH
|
||||
self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS
|
||||
self.stick()
|
||||
|
||||
def setup_signals(self):
|
||||
self.connect("delete-event", Gtk.main_quit)
|
436
1.0.2/resources/Main_Window.glade
Normal file
436
1.0.2/resources/Main_Window.glade
Normal file
@ -0,0 +1,436 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="commands">
|
||||
<columns>
|
||||
<!-- column-name Commands -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="Main_Window">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="title" translatable="yes">Mouse Board</property>
|
||||
<property name="window-position">center</property>
|
||||
<property name="default-height">260</property>
|
||||
<property name="icon">icon.png</property>
|
||||
<property name="type-hint">toolbar</property>
|
||||
<property name="skip-taskbar-hint">True</property>
|
||||
<property name="skip-pager-hint">True</property>
|
||||
<property name="accept-focus">False</property>
|
||||
<property name="gravity">center</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">520</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="autoTypeField">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="primary-icon-stock">gtk-go-forward</property>
|
||||
<property name="primary-icon-activatable">False</property>
|
||||
<property name="primary-icon-sensitive">False</property>
|
||||
<property name="placeholder-text" translatable="yes">Autotype Field...</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Type</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="typeString" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">10</property>
|
||||
<property name="margin-right">10</property>
|
||||
<property name="label" translatable="yes">Special Characters</property>
|
||||
<attributes>
|
||||
<attribute name="scale" value="1.5"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="specials">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="main_keys">
|
||||
<property name="name">popoutkeyboard</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">10</property>
|
||||
<property name="margin-right">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Del</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton">
|
||||
<property name="label" translatable="yes">Ctrl</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="toggled" handler="tgglCtrl" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton">
|
||||
<property name="label" translatable="yes">Shift</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="toggled" handler="tgglShift" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton">
|
||||
<property name="label" translatable="yes">Alt</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="toggled" handler="tgglAlt" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">PrtSc</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-add</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkTreeView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="model">commands</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Commands</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=3 n-rows=3 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="column-homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Up</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Down</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Left</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Right</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="insert" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">2</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
BIN
1.0.2/resources/icon.png
Normal file
BIN
1.0.2/resources/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
8
1.0.2/resources/stylesheet.css
Normal file
8
1.0.2/resources/stylesheet.css
Normal file
@ -0,0 +1,8 @@
|
||||
/* * {
|
||||
background: rgba(0, 0, 0, 0.14);
|
||||
color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
#popoutkeyboard {
|
||||
background-color: rgba(0, 65, 125, 1);
|
||||
} */
|
3
1.0.2/utils/__init__.py
Normal file
3
1.0.2/utils/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""
|
||||
Utils module
|
||||
"""
|
56
1.0.2/utils/logger.py
Normal file
56
1.0.2/utils/logger.py
Normal file
@ -0,0 +1,56 @@
|
||||
# Python imports
|
||||
import os, logging
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class Logger:
|
||||
"""
|
||||
Create a new logging object and return it.
|
||||
:note:
|
||||
NOSET # Don't know the actual log level of this... (defaulting or literally none?)
|
||||
Log Levels (From least to most)
|
||||
Type Value
|
||||
CRITICAL 50
|
||||
ERROR 40
|
||||
WARNING 30
|
||||
INFO 20
|
||||
DEBUG 10
|
||||
:param loggerName: Sets the name of the logger object. (Used in log lines)
|
||||
:param createFile: Whether we create a log file or just pump to terminal
|
||||
|
||||
:return: the logging object we created
|
||||
"""
|
||||
|
||||
def __init__(self, config_path: str, _ch_log_lvl = logging.CRITICAL, _fh_log_lvl = logging.INFO):
|
||||
self._CONFIG_PATH = config_path
|
||||
self.global_lvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels
|
||||
self.ch_log_lvl = _ch_log_lvl # Prety much the only one we ever change
|
||||
self.fh_log_lvl = _fh_log_lvl
|
||||
|
||||
def get_logger(self, loggerName: str = "NO_LOGGER_NAME_PASSED", createFile: bool = True) -> logging.Logger:
|
||||
log = logging.getLogger(loggerName)
|
||||
log.setLevel(self.global_lvl)
|
||||
|
||||
# Set our log output styles
|
||||
fFormatter = logging.Formatter('[%(asctime)s] %(pathname)s:%(lineno)d %(levelname)s - %(message)s', '%m-%d %H:%M:%S')
|
||||
cFormatter = logging.Formatter('%(pathname)s:%(lineno)d] %(levelname)s - %(message)s')
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(level=self.ch_log_lvl)
|
||||
ch.setFormatter(cFormatter)
|
||||
log.addHandler(ch)
|
||||
|
||||
if createFile:
|
||||
folder = self._CONFIG_PATH
|
||||
file = f"{folder}/application.log"
|
||||
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir(folder)
|
||||
|
||||
fh = logging.FileHandler(file)
|
||||
fh.setLevel(level=self.fh_log_lvl)
|
||||
fh.setFormatter(fFormatter)
|
||||
log.addHandler(fh)
|
||||
|
||||
return log
|
102
1.0.2/utils/pyautogui_control.py
Normal file
102
1.0.2/utils/pyautogui_control.py
Normal file
@ -0,0 +1,102 @@
|
||||
# Python imports
|
||||
import pyautogui
|
||||
|
||||
# Gtk imports
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
# Let piautogui make updates as quick as it can...
|
||||
pyautogui.FAILSAFE = False # If we hit corner, that's ok
|
||||
pyautogui.MINIMUM_DURATION = 0
|
||||
pyautogui.PAUSE = 0
|
||||
|
||||
|
||||
class ControlMixin:
|
||||
|
||||
def type(self, key):
|
||||
pyautogui.typewrite(key)
|
||||
|
||||
|
||||
def enter(self, widget = None, data = None):
|
||||
pyautogui.press("enter")
|
||||
|
||||
|
||||
# def typeString(self, widget = None, data = None):
|
||||
# text = self.autoTypeField.get_text()
|
||||
# for char in text:
|
||||
# self.do_insert(char)
|
||||
#
|
||||
# def insert(self, widget = None, data = None, key = None):
|
||||
# if not key:
|
||||
# key = widget.get_label().strip()
|
||||
#
|
||||
# if self.is_keypress_type(key):
|
||||
# return
|
||||
#
|
||||
# if self.isCapsLockOn:
|
||||
# key = key.upper()
|
||||
#
|
||||
# self.do_insert(key)
|
||||
#
|
||||
#
|
||||
# def do_insert(self, key):
|
||||
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
# self.set_hotkeys()
|
||||
#
|
||||
# pyautogui.typewrite(key)
|
||||
#
|
||||
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
|
||||
# self.unset_hotkeys()
|
||||
#
|
||||
#
|
||||
# def is_keypress_type(self, key):
|
||||
# if key in ["Esc", "Tab", "Space", "Del", "Up", "Down", "Left", "Right", "PrtSc"]:
|
||||
# pyautogui.press(key.lower())
|
||||
# return True
|
||||
#
|
||||
# for i in range(1, 13):
|
||||
# fkey = 'F' + str(i)
|
||||
# if key == fkey:
|
||||
# pyautogui.press(key.lower())
|
||||
# return True
|
||||
#
|
||||
# return False
|
||||
#
|
||||
#
|
||||
# def set_hotkeys(self):
|
||||
# if self.isCtrlOn:
|
||||
# pyautogui.keyDown('ctrl')
|
||||
# if self.isShiftOn:
|
||||
# pyautogui.keyDown('shiftleft')
|
||||
# pyautogui.keyDown('shiftright')
|
||||
# if self.isAltOn:
|
||||
# pyautogui.keyDown('alt')
|
||||
#
|
||||
#
|
||||
# def unset_hotkeys(self):
|
||||
# pyautogui.keyUp('ctrl')
|
||||
# pyautogui.keyUp('shiftleft')
|
||||
# pyautogui.keyUp('shiftright')
|
||||
# pyautogui.keyUp('alt')
|
||||
#
|
||||
#
|
||||
# def toggleCaps(self, widget, data=None):
|
||||
# self.isCapsLockOn = False if self.isCapsLockOn else True
|
||||
#
|
||||
# def tgglCtrl(self, widget, data=None):
|
||||
# self.isCtrlOn = False if self.isCtrlOn else True
|
||||
#
|
||||
# def tgglShift(self, widget, data=None):
|
||||
# self.isShiftOn = False if self.isShiftOn else True
|
||||
#
|
||||
# def tgglAlt(self, widget, data=None):
|
||||
# self.isAltOn = False if self.isAltOn else True
|
||||
#
|
||||
#
|
||||
# def enter(self, widget, data=None):
|
||||
# pyautogui.press("enter")
|
||||
#
|
||||
#
|
||||
# def backspace(self, widget, data=None):
|
||||
# pyautogui.press("backspace")
|
Loading…
Reference in New Issue
Block a user