wapyt 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ import sys
2
+
3
+ from wapyt.cardpanel import CardPanelConfig, CardPanelCardConfig
4
+ from wapyt.layout import Layout, MainWindow, LayoutConfig, CellConfig
5
+ from wapyt.modal import ModalWindow, ModalConfig
6
+
7
+
8
+ class cardpanel_demo(MainWindow):
9
+ layout_config = LayoutConfig(rows=[CellConfig(id="cards", grow=1)])
10
+
11
+ def load_ui(self):
12
+ self._modal = ModalWindow(ModalConfig(title="Add Provider", width=520, height=380))
13
+ self._modal_layout = Layout(LayoutConfig(rows=[CellConfig(id="form", grow=1)]))
14
+ self._modal.set_content(self._modal_layout.layout)
15
+ self._render_modal_form()
16
+
17
+ config = CardPanelConfig(
18
+ title="Data Sources",
19
+ description="A minimal card panel rendered without DHTMLX.",
20
+ search_placeholder="Search connectors…",
21
+ add_button_text="New Source",
22
+ card_columns=3,
23
+ card_height=200,
24
+ card_template={
25
+ "class": "card-card",
26
+ "children": [
27
+ {
28
+ "class": "card-head",
29
+ "children": [
30
+ {"class": "card-icon", "text": "{extra.initial}"},
31
+ {
32
+ "children": [
33
+ {"tag": "h3", "class": "card-title", "text": "{title}"},
34
+ {"tag": "p", "class": "card-sub", "text": "{subtitle}"},
35
+ {"tag": "span", "class": "card-pill", "text": "{pill}"},
36
+ ]
37
+ },
38
+ ],
39
+ },
40
+ {"class": "card-content", "text": "Status: {extra.status}"},
41
+ {
42
+ "class": "card-foot",
43
+ "children": [
44
+ {
45
+ "tag": "button",
46
+ "class": "card-action",
47
+ "text": "View",
48
+ "attrs": {"data-card-action": "view"},
49
+ },
50
+ {
51
+ "tag": "button",
52
+ "class": "card-action",
53
+ "text": "Sync",
54
+ "attrs": {"data-card-action": "sync"},
55
+ },
56
+ ],
57
+ },
58
+ ],
59
+ },
60
+ cards=[
61
+ CardPanelCardConfig(
62
+ id="duckdb",
63
+ title="DuckDB",
64
+ subtitle="Fast OLAP engine",
65
+ pill="Warehouse",
66
+ extra={"status": "Healthy", "initial": "D"},
67
+ ),
68
+ CardPanelCardConfig(
69
+ id="snowflake",
70
+ title="Snowflake",
71
+ subtitle="Elastic cloud analytics",
72
+ pill="Warehouse",
73
+ extra={"status": "Syncing", "initial": "S"},
74
+ ),
75
+ CardPanelCardConfig(
76
+ id="lakehouse",
77
+ title="Lakehouse",
78
+ subtitle="S3 compatible store",
79
+ pill="Lake",
80
+ extra={"status": "Healthy", "initial": "L"},
81
+ ),
82
+ ],
83
+ )
84
+ panel = self.add_cardpanel("cards", config)
85
+ panel.on_card_click(lambda payload: print("Card clicked:", payload))
86
+ panel.on_add(lambda: self._show_modal())
87
+ panel.on_action(lambda payload: self._show_modal(payload.get("cardId")))
88
+
89
+ def _render_modal_form(self, provider_id: str = "", status: str = ""):
90
+ form_html = f"""
91
+ <form style="display:flex;flex-direction:column;gap:12px;">
92
+ <label>Provider ID
93
+ <input type="text" value="{provider_id}" style="width:100%;padding:8px;" />
94
+ </label>
95
+ <label>Status
96
+ <input type="text" value="{status}" style="width:100%;padding:8px;" />
97
+ </label>
98
+ <label>Models<br/>
99
+ <textarea style="width:100%;height:120px;padding:8px;">gpt-4o-mini</textarea>
100
+ </label>
101
+ <div style="display:flex;justify-content:flex-end;gap:8px;">
102
+ <button type="button" style="padding:8px 12px;">Cancel</button>
103
+ <button type="submit" style="padding:8px 12px;background:#2563eb;color:#fff;border:none;border-radius:8px;">Save</button>
104
+ </div>
105
+ </form>
106
+ """
107
+ self._modal_layout.attach_html("form", form_html)
108
+
109
+ def _show_modal(self, provider_id: str = None):
110
+ title = "Add Provider" if not provider_id else f"Configure {provider_id}"
111
+ self._modal.set_title(title)
112
+ self._render_modal_form(provider_id or "", "Healthy")
113
+ self._modal.show()
114
+
115
+
116
+ if __name__ == "__main__" and sys.platform != "emscripten":
117
+ from pytincture import launch_service
118
+
119
+ launch_service(modules_folder=".")