Reworked logic - in progress
This commit is contained in:
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()
|
||||
Reference in New Issue
Block a user