patchkori 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,40 @@
1
+ from __future__ import annotations
2
+ from abc import ABC, abstractmethod
3
+ from typing import ClassVar
4
+
5
+
6
+ class BaseBioTool(ABC):
7
+ """Abstract base class that every bioinformatics tool plugin must implement."""
8
+
9
+ tool_id: ClassVar[str]
10
+ title: ClassVar[str]
11
+ icon: ClassVar[str] = "🔬"
12
+ description: ClassVar[str] = ""
13
+ order: ClassVar[int] = 100
14
+
15
+ @abstractmethod
16
+ def build_ui(self, is_demo_mode: bool = False) -> None:
17
+ """Construct Gradio components and callbacks inside the active gr.Tab."""
18
+ raise NotImplementedError
19
+
20
+
21
+ class ToolRegistry:
22
+ """Central plugin registry for discovering and mounting Gradio tool modules."""
23
+
24
+ _tools: ClassVar[dict[str, type[BaseBioTool]]] = {}
25
+
26
+ @classmethod
27
+ def register(cls, tool_cls: type[BaseBioTool]) -> type[BaseBioTool]:
28
+ if not getattr(tool_cls, "tool_id", None):
29
+ raise ValueError(f"Tool class {tool_cls.__name__} must define a non-empty `tool_id`.")
30
+ cls._tools[tool_cls.tool_id] = tool_cls
31
+ return tool_cls
32
+
33
+ @classmethod
34
+ def get_tools(cls) -> list[BaseBioTool]:
35
+ sorted_classes = sorted(cls._tools.values(), key=lambda c: (c.order, c.title))
36
+ return [tool_cls() for tool_cls in sorted_classes]
37
+
38
+ @classmethod
39
+ def get_tool_ids(cls) -> list[str]:
40
+ return [t.tool_id for t in cls.get_tools()]
patchkori/ui/theme.py ADDED
@@ -0,0 +1,287 @@
1
+ """
2
+ Eye-Soothing, Colorblind-Safe Theme and Scoped CSS for PatchKori.
3
+ Zero heavy text fills. Pure typography, clean borders, and calm surfaces.
4
+ """
5
+
6
+ from __future__ import annotations
7
+ import gradio as gr
8
+
9
+ CUSTOM_CSS = """
10
+ /* ==========================================================================
11
+ Colorblind-Safe & Eye-Soothing Palette (Zero Violet, Minimal Fills)
12
+ ========================================================================== */
13
+
14
+ /* --- Bright Mode Defaults --- */
15
+ :root {
16
+ --pk-bg: #f8fafc;
17
+ --pk-card-bg: #ffffff;
18
+ --pk-border: #e2e8f0;
19
+ --pk-text-primary: #0f172a;
20
+ --pk-text-secondary: #475569;
21
+ --pk-brand-main: #0f172a;
22
+ --pk-brand-accent: #0d9488;
23
+ --pk-badge-bg: #f0fdfa;
24
+ --pk-badge-text: #0f766e;
25
+ --pk-badge-border: #99f6e4;
26
+ }
27
+
28
+ /* --- Dark Mode Overrides (Deep Slate, Clean Borders, No Fills) --- */
29
+ .dark, :root.dark {
30
+ --pk-bg: #0f172a;
31
+ --pk-card-bg: #1e293b;
32
+ --pk-border: #334155;
33
+ --pk-text-primary: #f8fafc;
34
+ --pk-text-secondary: #94a3b8;
35
+ --pk-brand-main: #f8fafc;
36
+ --pk-brand-accent: #2dd4bf;
37
+ --pk-badge-bg: #134e4a;
38
+ --pk-badge-text: #5eead4;
39
+ --pk-badge-border: #115e59;
40
+ }
41
+
42
+ /* Hide default Gradio footer (removes 'Built with Gradio' and native API link) */
43
+ footer {
44
+ display: none !important;
45
+ }
46
+
47
+ /* ==========================================================================
48
+ Brand & Top Bar
49
+ ========================================================================== */
50
+ .pk-brand-container {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 14px;
54
+ margin-bottom: 6px;
55
+ padding: 6px 0;
56
+ }
57
+
58
+ .pk-brand-text {
59
+ display: flex;
60
+ flex-direction: column;
61
+ }
62
+
63
+ .pk-brand-title {
64
+ font-size: 1.85rem;
65
+ font-weight: 800;
66
+ letter-spacing: -0.03em;
67
+ line-height: 1.1;
68
+ }
69
+
70
+ .pk-logo-accent {
71
+ color: var(--pk-brand-accent);
72
+ }
73
+
74
+ .pk-logo-main {
75
+ color: var(--pk-brand-main);
76
+ }
77
+
78
+ .pk-brand-tagline {
79
+ font-size: 0.85rem;
80
+ font-weight: 500;
81
+ letter-spacing: 0.04em;
82
+ text-transform: uppercase;
83
+ color: var(--pk-text-secondary);
84
+ margin-top: 2px;
85
+ }
86
+
87
+ .pk-top-bar {
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ flex-wrap: wrap;
92
+ gap: 10px;
93
+ margin-bottom: 12px;
94
+ }
95
+
96
+ .pk-mode-badge {
97
+ display: inline-flex;
98
+ align-items: center;
99
+ gap: 6px;
100
+ font-size: 0.82rem;
101
+ font-weight: 600;
102
+ padding: 4px 12px;
103
+ border-radius: 9999px;
104
+ background: var(--pk-badge-bg);
105
+ color: var(--pk-badge-text);
106
+ border: 1px solid var(--pk-badge-border);
107
+ }
108
+
109
+ /* Static API status badge (Clean, no popups or alerts) */
110
+ .pk-api-badge {
111
+ display: inline-flex;
112
+ align-items: center;
113
+ gap: 6px;
114
+ font-size: 0.80rem;
115
+ font-weight: 500;
116
+ padding: 4px 10px;
117
+ border-radius: 6px;
118
+ border: 1px dashed var(--pk-border);
119
+ color: var(--pk-text-secondary);
120
+ user-select: none;
121
+ }
122
+
123
+ /* ==========================================================================
124
+ Colorblind-Safe Icon Accents
125
+ ========================================================================== */
126
+ .pk-icon-teal { stroke: #0d9488; }
127
+ .pk-icon-blue { stroke: #2563eb; }
128
+ .pk-icon-amber { stroke: #d97706; fill: #d97706; }
129
+ .pk-icon-slate { stroke: #64748b; }
130
+
131
+ /* ==========================================================================
132
+ Clean Hierarchy (No Heavy Fills)
133
+ ========================================================================== */
134
+ .pk-section-header {
135
+ display: flex;
136
+ align-items: center;
137
+ gap: 8px;
138
+ font-size: 0.95rem;
139
+ font-weight: 700;
140
+ letter-spacing: -0.01em;
141
+ color: var(--pk-text-primary);
142
+ margin-top: 10px;
143
+ margin-bottom: 8px;
144
+ padding-bottom: 5px;
145
+ border-bottom: 1px solid var(--pk-border);
146
+ }
147
+
148
+ /* Subtle, clean instructions without heavy background color fill */
149
+ .pk-canvas-instructions {
150
+ font-size: 0.84rem;
151
+ line-height: 1.4;
152
+ color: var(--pk-text-secondary);
153
+ margin-bottom: 10px;
154
+ padding-left: 2px;
155
+ }
156
+
157
+ .pk-action-row {
158
+ margin-bottom: 8px !important;
159
+ gap: 10px !important;
160
+ }
161
+
162
+ .pk-image-editor-wrap {
163
+ position: relative;
164
+ border: 1px solid var(--pk-border);
165
+ border-radius: 8px;
166
+ overflow: hidden;
167
+ }
168
+
169
+ /* Metadata Inspection Card - Clean Minimal Table */
170
+ .pk-metadata-card {
171
+ border: 1px solid var(--pk-border);
172
+ border-radius: 8px;
173
+ padding: 14px;
174
+ background: var(--pk-card-bg);
175
+ margin-top: 12px;
176
+ }
177
+
178
+ /* Beautiful, non-breaking level table */
179
+ .pk-table-wrap {
180
+ overflow-x: auto;
181
+ margin-top: 8px;
182
+ margin-bottom: 14px;
183
+ border: 1px solid var(--pk-border);
184
+ border-radius: 6px;
185
+ }
186
+
187
+ .pk-meta-table {
188
+ width: 100%;
189
+ border-collapse: collapse;
190
+ white-space: nowrap;
191
+ font-size: 0.84rem;
192
+ text-align: left;
193
+ }
194
+
195
+ .pk-meta-table th {
196
+ padding: 8px 12px;
197
+ font-weight: 600;
198
+ color: var(--pk-text-primary);
199
+ background: var(--pk-bg);
200
+ border-bottom: 1px solid var(--pk-border);
201
+ white-space: nowrap;
202
+ }
203
+
204
+ .pk-meta-table td {
205
+ padding: 8px 12px;
206
+ border-bottom: 1px solid var(--pk-border);
207
+ color: var(--pk-text-secondary);
208
+ white-space: nowrap;
209
+ }
210
+
211
+ .pk-meta-table tr:last-child td {
212
+ border-bottom: none;
213
+ }
214
+
215
+ .pk-lvl-badge {
216
+ display: inline-block;
217
+ font-weight: 700;
218
+ font-family: var(--font-mono, monospace);
219
+ color: var(--pk-brand-accent);
220
+ }
221
+
222
+ .pk-code-pill {
223
+ font-family: var(--font-mono, monospace);
224
+ background: var(--pk-bg);
225
+ padding: 2px 6px;
226
+ border-radius: 4px;
227
+ border: 1px solid var(--pk-border);
228
+ font-size: 0.80rem;
229
+ color: var(--pk-text-primary);
230
+ white-space: nowrap;
231
+ }
232
+
233
+ /* Details Key-Value Row */
234
+ .pk-details-grid {
235
+ display: flex;
236
+ flex-wrap: wrap;
237
+ gap: 16px;
238
+ margin: 8px 0 12px 0;
239
+ font-size: 0.85rem;
240
+ }
241
+
242
+ .pk-detail-item {
243
+ display: flex;
244
+ align-items: center;
245
+ gap: 6px;
246
+ color: var(--pk-text-secondary);
247
+ }
248
+
249
+ .pk-detail-item strong {
250
+ color: var(--pk-text-primary);
251
+ }
252
+
253
+ /* Channels Pill Cloud */
254
+ .pk-channel-cloud {
255
+ display: flex;
256
+ flex-wrap: wrap;
257
+ gap: 6px;
258
+ margin-top: 6px;
259
+ }
260
+
261
+ .pk-channel-tag {
262
+ font-size: 0.78rem;
263
+ font-family: var(--font-mono, monospace);
264
+ padding: 2px 8px;
265
+ border-radius: 4px;
266
+ background: var(--pk-bg);
267
+ border: 1px solid var(--pk-border);
268
+ color: var(--pk-text-primary);
269
+ white-space: nowrap;
270
+ }
271
+ """
272
+
273
+
274
+ def build_app_theme() -> gr.Theme:
275
+ """
276
+ Constructs an eye-soothing, colorblind-safe theme:
277
+ Teal primary with slate neutrals (clean, resting colors).
278
+ """
279
+ theme = gr.themes.Soft(
280
+ primary_hue="teal",
281
+ secondary_hue="slate",
282
+ neutral_hue="slate",
283
+ radius_size=gr.themes.sizes.radius_md,
284
+ font=[gr.themes.GoogleFont("Inter"), "system-ui", "-apple-system", "sans-serif"],
285
+ font_mono=[gr.themes.GoogleFont("JetBrains Mono"), "ui-monospace", "monospace"],
286
+ )
287
+ return theme
@@ -0,0 +1,5 @@
1
+ """Auto-import all built-in Gradio tool modules so @ToolRegistry.register runs."""
2
+
3
+ from patchkori.ui.tools import pyramidal_cropper
4
+
5
+ __all__ = ["pyramidal_cropper"]