diff options
author | Aylur <[email protected]> | 2024-09-26 00:32:03 +0000 |
---|---|---|
committer | Aylur <[email protected]> | 2024-09-26 00:32:03 +0000 |
commit | 00738c9383472b9fd83d65785215c5a97a58159f (patch) | |
tree | d9f91a890f6a01886496a58f4bc761619f5df09d /examples/py/starter-bar | |
parent | d24e3e39526a88a00ca9e11f168d9c705a21d25a (diff) |
add: python example bar
Diffstat (limited to 'examples/py/starter-bar')
-rw-r--r-- | examples/py/starter-bar/README.md | 7 | ||||
-rw-r--r-- | examples/py/starter-bar/__init__.py | 0 | ||||
-rwxr-xr-x | examples/py/starter-bar/app.py | 27 | ||||
-rw-r--r-- | examples/py/starter-bar/style.css | 4 | ||||
-rw-r--r-- | examples/py/starter-bar/versions.py | 6 | ||||
-rw-r--r-- | examples/py/starter-bar/widget/Bar.py | 48 | ||||
-rw-r--r-- | examples/py/starter-bar/widget/__init__.py | 0 |
7 files changed, 0 insertions, 92 deletions
diff --git a/examples/py/starter-bar/README.md b/examples/py/starter-bar/README.md deleted file mode 100644 index b3a14ce..0000000 --- a/examples/py/starter-bar/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Starter Bar Example - -A starter bar that shows a label and the date. - -> [!NOTE] -> This code is not ideal to work with as it requires too much boilerplate compared to AGS. -> If you want to use python try picking up the [python library](https://github.com/Aylur/astal/tree/feat/python/core/python). diff --git a/examples/py/starter-bar/__init__.py b/examples/py/starter-bar/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/examples/py/starter-bar/__init__.py +++ /dev/null diff --git a/examples/py/starter-bar/app.py b/examples/py/starter-bar/app.py deleted file mode 100755 index 287d0f8..0000000 --- a/examples/py/starter-bar/app.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -import versions -from gi.repository import Astal, Gio -from widget.Bar import Bar -from pathlib import Path - -css = str(Path(__file__).parent.resolve() / "style.css") - - -class App(Astal.Application): - def __init__(self): - super().__init__() - self.acquire_socket() - self.run(None) - - def do_request(self, msg: str, conn: Gio.SocketConnection) -> None: - print(msg) - Astal.write_sock(conn, "hello") - - def do_activate(self) -> None: - self.hold() - self.apply_css(css, True) - for mon in self.get_monitors(): - self.add_window(Bar(mon)) - - -App() diff --git a/examples/py/starter-bar/style.css b/examples/py/starter-bar/style.css deleted file mode 100644 index cb8c712..0000000 --- a/examples/py/starter-bar/style.css +++ /dev/null @@ -1,4 +0,0 @@ -window.Bar { - background-color: #212121; - color: white; -} diff --git a/examples/py/starter-bar/versions.py b/examples/py/starter-bar/versions.py deleted file mode 100644 index a5993be..0000000 --- a/examples/py/starter-bar/versions.py +++ /dev/null @@ -1,6 +0,0 @@ -import gi - -gi.require_version("Astal", "0.1") -gi.require_version("Gtk", "3.0") -gi.require_version("Gdk", "3.0") -gi.require_version("Gio", "2.0") diff --git a/examples/py/starter-bar/widget/Bar.py b/examples/py/starter-bar/widget/Bar.py deleted file mode 100644 index 9071169..0000000 --- a/examples/py/starter-bar/widget/Bar.py +++ /dev/null @@ -1,48 +0,0 @@ -from gi.repository import Astal, Gtk, Gdk, GLib - - -class Time(Astal.Label): - def __init__(self, format="%H:%M:%S"): - super().__init__(visible=True) - self.connect("destroy", self.on_destroy) - self.format = format - self.time = Astal.Time.interval(1000, self.on_tick) - - def on_tick(self): - datetime = GLib.DateTime.new_now_local() - assert datetime - time = datetime.format(self.format) - assert time - self.set_label(time) - - def on_destroy(self, *args, **kwargs): - self.time.cancel() - - -class Bar(Astal.Window): - def __init__(self, monitor: Gdk.Monitor): - super().__init__( - visible=True, - gdkmonitor=monitor, - name="Bar" + str(monitor.get_model()), - anchor=Astal.WindowAnchor.LEFT - | Astal.WindowAnchor.RIGHT - | Astal.WindowAnchor.TOP, - exclusivity=Astal.Exclusivity.EXCLUSIVE, - ) - - Astal.widget_set_class_names(self, ["Bar"]) - start_widget = Astal.Box(visible=True, hexpand=True, halign=Gtk.Align.CENTER) - end_widget = Astal.Box(visible=True, hexpand=True, halign=Gtk.Align.CENTER) - - start_widget.set_children([Astal.Label(visible=True, label="Astal in python")]) - - end_widget.set_children([Time()]) - - self.add( - Astal.CenterBox( - visible=True, - start_widget=start_widget, - end_widget=end_widget, - ) - ) diff --git a/examples/py/starter-bar/widget/__init__.py b/examples/py/starter-bar/widget/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/examples/py/starter-bar/widget/__init__.py +++ /dev/null |