diff options
| author | Franziska Kunsmann <hi@kunsmann.eu> | 2023-01-11 07:33:01 +0100 |
|---|---|---|
| committer | Franziska Kunsmann <hi@kunsmann.eu> | 2023-01-11 07:33:01 +0100 |
| commit | abb5274122fffa81da22a559820875762f549a4c (patch) | |
| tree | af339c6f5bc313f8b6410cea5c2bec6b76af78ac | |
| parent | bb7c63ef130b00003c926b168aee56a3b32eb6e0 (diff) | |
add some styling
| -rw-r--r-- | gui.py | 28 | ||||
| -rw-r--r-- | style.css | 19 | ||||
| -rw-r--r-- | switcher.py | 4 |
3 files changed, 45 insertions, 6 deletions
@@ -3,7 +3,7 @@ import gi gi.require_version('Gtk', '3.0') import logging -from gi.repository import GObject, Gtk +from gi.repository import GObject, Gtk, Gdk BUTTON_SPACING = 10 @@ -12,8 +12,20 @@ class PyATEMSwitcherGui(): def __init__(self, config, switcher): self.log = logging.getLogger('GUI') self.config = config + + cssProvider = Gtk.CssProvider() + cssProvider.load_from_path('style.css') + screen = Gdk.Screen.get_default() + styleContext = Gtk.StyleContext() + styleContext.add_provider_for_screen( + screen, + cssProvider, + Gtk.STYLE_PROVIDER_PRIORITY_USER, + ) + self.window = Gtk.Window() self.window.connect("destroy", Gtk.main_quit) + self.switcher = switcher self.switcher.on_connect(self._switcher_connected) self.switcher.on_connect_attempt(self._switcher_connect_attempt) @@ -25,16 +37,23 @@ class PyATEMSwitcherGui(): self.header.props.title = 'PyATEMSwitcherGui: Idle' self.window.set_titlebar(self.header) - self.buttons = {} self.box = None + self._switcher_disconnected({}) # TODO use connection hooks self._switcher_connected({}) def _button_clicked(self, button, name): # TODO actually do something - self.header.props.title = f'PyATEMSwitcherGui: {name}' self.log.info(f'Button {name} was pressed') + for btn in self.buttons: + ctx = self.buttons[btn].get_style_context() + if btn == name: + self.log.debug(f'{btn}.add_class("selected")') + ctx.add_class('selected') + else: + self.log.debug(f'{btn}.remove_class("selected")') + ctx.remove_class('selected') def _switcher_connected(self, params): self.box = Gtk.FlowBox() @@ -59,13 +78,14 @@ class PyATEMSwitcherGui(): self.window.add(self.box) def _switcher_connect_attempt(self, params): - pass + self.header.props.title = 'PyATEMSwitcherGui: Connecting ...' def _switcher_disconnected(self, params): if self.box is not None: self.window.remove(self.box) self.box = None self.buttons = {} + self.header.props.title = 'PyATEMSwitcherGui: Not connected' def _switcher_ping(self): # TODO actually do something here diff --git a/style.css b/style.css new file mode 100644 index 0000000..45da0e7 --- /dev/null +++ b/style.css @@ -0,0 +1,19 @@ +button { + padding: 1em; + font-size: 1.5em; +} + +button.program { + background: #800000; + color: #FFFFFF; +} + +button.preview { + background: #008000; + color: #FFFFFF; +} + +button.selected { + box-shadow: 0 0 0.3em #800000; + text-shadow: 0 0 0.3em #800000; +} diff --git a/switcher.py b/switcher.py index 4c34a1c..8624839 100644 --- a/switcher.py +++ b/switcher.py @@ -1,7 +1,7 @@ import logging import PyATEMMax -from PyATEMMax.ATEMProtocolEnums import ATEMVideoModeFormats +from PyATEMMax.ATEMProtocolEnums import ATEMVideoModeFormats, ATEMTransitionStyles VIDEO_FORMATS = { f[1:] @@ -98,6 +98,6 @@ class PyATEMSwitcher: def trans(self, input): self.log.debug(f'hehehehe trans({repr(input)})') self.atem.setProgramInputVideoSource( - # TODO mixEffect, + ATEMTransitionStyles.mix, input, ) |
