|
7 | 7 | import queue |
8 | 8 | import sys |
9 | 9 | import threading |
| 10 | +import webbrowser |
10 | 11 | from pathlib import Path |
11 | 12 | from typing import Any |
12 | 13 |
|
| 14 | +from .__version__ import __version__ |
13 | 15 | from .exceptions import NoDataFoundError, OsmsgError |
14 | 16 | from .pipeline import RunConfig, run |
15 | 17 |
|
16 | 18 | UTC = dt.UTC |
17 | 19 | FORMATS = ["parquet", "csv", "json", "markdown"] |
| 20 | +ABOUT_LINKS = [ |
| 21 | + ("Star osmsg on GitHub", "https://github.com/osgeonepal/osmsg"), |
| 22 | + ("Report a bug or request a feature", "https://github.com/osgeonepal/osmsg/issues"), |
| 23 | + ("Sponsor the developer", "https://github.com/sponsors/kshitijrajsharma"), |
| 24 | +] |
18 | 25 | PRESETS = ["Last hour", "Last day", "Last week", "Last month", "Last year", "All time"] |
19 | 26 | _PRESET_DELTAS = { |
20 | 27 | "Last hour": dt.timedelta(hours=1), |
@@ -109,6 +116,7 @@ def __init__(self) -> None: |
109 | 116 | from tkinter import filedialog, scrolledtext, ttk |
110 | 117 |
|
111 | 118 | self._tk = tk |
| 119 | + self._ttk = ttk |
112 | 120 | self._filedialog = filedialog |
113 | 121 | self.events: queue.Queue = queue.Queue() |
114 | 122 | self.out_dir = str(Path.home() / "osmsg") |
@@ -164,8 +172,26 @@ def __init__(self) -> None: |
164 | 172 |
|
165 | 173 | self.log = scrolledtext.ScrolledText(frame, width=70, height=14, state="disabled") |
166 | 174 | self.log.grid(row=10, column=0, columnspan=4, sticky="nsew") |
| 175 | + |
| 176 | + ttk.Button(frame, text="About", command=self._show_about).grid(row=11, column=0, pady=(6, 0), sticky="w") |
| 177 | + ttk.Label(frame, text="A project of OSGeo Nepal").grid(row=11, column=1, columnspan=3, pady=(6, 0), sticky="e") |
167 | 178 | self.root.after(120, self._drain) |
168 | 179 |
|
| 180 | + def _show_about(self) -> None: |
| 181 | + tk, ttk = self._tk, self._ttk |
| 182 | + win = tk.Toplevel(self.root) |
| 183 | + win.title("About osmsg") |
| 184 | + box = ttk.Frame(win, padding=16) |
| 185 | + box.grid(sticky="nsew") |
| 186 | + ttk.Label(box, text=f"osmsg {__version__}", font=("", 12, "bold")).grid(sticky="w") |
| 187 | + ttk.Label(box, text="OpenStreetMap Stats Generator").grid(sticky="w") |
| 188 | + ttk.Label(box, text="A project of OSGeo Nepal").grid(sticky="w", pady=(0, 10)) |
| 189 | + for text, url in ABOUT_LINKS: |
| 190 | + link = ttk.Label(box, text=text, foreground="#1a73e8", cursor="hand2") |
| 191 | + link.grid(sticky="w", pady=2) |
| 192 | + link.bind("<Button-1>", lambda _event, target=url: webbrowser.open(target)) |
| 193 | + ttk.Button(box, text="Close", command=win.destroy).grid(sticky="e", pady=(12, 0)) |
| 194 | + |
169 | 195 | def _apply_preset(self, name: str) -> None: |
170 | 196 | start, end = preset_range(name) |
171 | 197 | self.vars["start"].set(_fmt(start)) |
|
0 commit comments