move remaining styles/constants to constants.py

main
Ilya Zhuravlev 2020-10-16 15:28:52 -04:00
parent 347fa7c421
commit adb4a354ee
3 changed files with 12 additions and 4 deletions

View File

@ -2,7 +2,13 @@ KEY_WIDTH = 40
KEY_HEIGHT = KEY_WIDTH
KEY_SPACING = 4
KEYCODE_BTN_WIDTH = 50
KEYCODE_BTN_HEIGHT = KEYCODE_BTN_WIDTH
WINDOW_WIDTH, WINDOW_HEIGHT = 1024, 768
LAYER_BTN_STYLE = "border: 1px solid black; padding: 5px"
ACTIVE_LAYER_BTN_STYLE = "border: 1px solid black; padding: 5px; background-color: black; color: white"
KEY_NORMAL_STYLE = "background-color:white; border: 1px solid black"
KEY_ACTIVE_STYLE = "background-color:black; color: white; border: 1px solid black"

View File

@ -5,7 +5,8 @@ from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QVBoxLayout
from clickable_label import ClickableLabel
from keycodes import keycode_label, keycode_tooltip
from constants import KEY_WIDTH, KEY_SPACING, KEY_HEIGHT, LAYER_BTN_STYLE, ACTIVE_LAYER_BTN_STYLE
from constants import KEY_WIDTH, KEY_SPACING, KEY_HEIGHT, LAYER_BTN_STYLE, ACTIVE_LAYER_BTN_STYLE, KEY_NORMAL_STYLE, \
KEY_ACTIVE_STYLE
from util import tr
@ -114,9 +115,9 @@ class KeyboardContainer(QWidget):
text = keycode_label(code)
tooltip = keycode_tooltip(code)
for widget in widgets:
widget.setStyleSheet('background-color:white; border: 1px solid black')
widget.setStyleSheet(KEY_NORMAL_STYLE)
if widget == self.selected_key:
widget.setStyleSheet('background-color:black; color: white; border: 1px solid black')
widget.setStyleSheet(KEY_ACTIVE_STYLE)
widget.setText(text)
widget.setToolTip(tooltip)

View File

@ -1,6 +1,7 @@
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QTabWidget, QWidget, QPushButton
from constants import KEYCODE_BTN_WIDTH, KEYCODE_BTN_HEIGHT
from flowlayout import FlowLayout
from keycodes import KEYCODES_BASIC, KEYCODES_ISO, KEYCODES_MACRO, KEYCODES_LAYERS, KEYCODES_SPECIAL, keycode_tooltip
from util import tr
@ -38,7 +39,7 @@ class TabbedKeycodes(QTabWidget):
for keycode in keycodes:
btn = QPushButton(keycode.label)
btn.setFixedSize(50, 50)
btn.setFixedSize(KEYCODE_BTN_WIDTH, KEYCODE_BTN_HEIGHT)
btn.setToolTip(keycode_tooltip(keycode.code))
btn.clicked.connect(lambda st, k=keycode: self.keycode_changed.emit(k.code))
layout.addWidget(btn)