From 82ae373c6ef0d943618100966236e97828a6b4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sat, 28 Oct 2023 12:56:46 +0200 Subject: [PATCH] [gui] Add project support link --- gui-win32.spec | 1 + ltchiptool/gui/ko-fi.png | Bin 0 -> 3228 bytes ltchiptool/gui/ltchiptool.wxui | 30 +++++++++++++++++++++++++++++ ltchiptool/gui/ltchiptool.xrc | 34 +++++++++++++++++++++++++++++++++ ltchiptool/gui/panels/log.py | 31 ++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 ltchiptool/gui/ko-fi.png diff --git a/gui-win32.spec b/gui-win32.spec index fcb8a00..130667a 100644 --- a/gui-win32.spec +++ b/gui-win32.spec @@ -27,6 +27,7 @@ a = Analysis( ("ltchiptool/gui/ltchiptool-192x192.png", "."), ("ltchiptool/gui/ltchiptool.ico", "."), ("ltchiptool/gui/ltchiptool.xrc", "."), + ("ltchiptool/gui/ko-fi.png", "."), ("ltchiptool/gui/colors.json", "."), ("pyproject.toml", "."), ] diff --git a/ltchiptool/gui/ko-fi.png b/ltchiptool/gui/ko-fi.png new file mode 100644 index 0000000000000000000000000000000000000000..eb2efbcac3cb5f2fb46b7545763acab817bc5f6d GIT binary patch literal 3228 zcmV;N3}f?&P)kZS69c?t5^FBt4b++e0=EFuU}h9vw$R})X7d)CL(W&4qtus zl`LAcNPs?fDWzoU)T#3P^UuqkJ$ocKH&?D)xgsrKkB9_zhVW1kY1B$dPfzcYWVd$t z`}@nQuf8gId3n;<*yv9DFCwz2qon^$%blN}e}m*UuK4(P`TFaxt$O{tBI4U#($8zT z)~#E2gV=UniHV6)US94_{K+Pn-TFW(BBDhMA3mJ&^77^cJ9g|KDk`ea45W>Xjg*&{ zQ(0L_K|ul8+1c#gy}QNqVPRox-n^MR@4QnVoeM-Lr7pG9%e}NFYG`OMwPs#kp7eE; zm6b_mW~M|%MYY)L)6&x1ZT&G3@xDQN7g1kdF9!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ptool/gui/panels/log.py b/ltchiptool/gui/panels/log.py index 5a67dc9..364b7ff 100644 --- a/ltchiptool/gui/panels/log.py +++ b/ltchiptool/gui/panels/log.py @@ -1,10 +1,12 @@ # Copyright (c) Kuba SzczodrzyƄski 2023-1-8. import logging +import sys import threading import time from logging import INFO, info, log, warning from multiprocessing import Queue +from os.path import dirname, join from queue import Empty import wx @@ -93,6 +95,7 @@ def render_finish(self) -> None: # noinspection PyPep8Naming class LogPanel(BasePanel): log_queue: Queue + donate_closed: bool = False def __init__(self, parent: wx.Window, frame): super().__init__(parent, frame) @@ -117,6 +120,20 @@ def __init__(self, parent: wx.Window, frame): GUIProgressBar.render_finish(GUIProgressBar) setattr(_termui_impl, "ProgressBar", GUIProgressBar) + if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): + donate = join(sys._MEIPASS, "ko-fi.png") + else: + donate = join(dirname(__file__), "..", "ko-fi.png") + + bitmap = self.FindStaticBitmap("bmp_donate") + height = 28 + image = wx.Image(donate) + ratio = image.GetWidth() / image.GetHeight() + image.Rescale(int(ratio * height), height, wx.IMAGE_QUALITY_BICUBIC) + bitmap.SetBitmap(image) + + self.BindButton("button_donate_close", self.OnDonateClose) + def emit_raw(self, log_prefix: str, message: str, color: str): if threading.current_thread() is not threading.main_thread(): # NEVER block worker threads by waiting for main thread availability @@ -145,6 +162,7 @@ def GetSettings(self) -> dict: raw=handler.raw, full_traceback=handler.full_traceback, dump_serial=LoggingStreamHook.is_registered(Serial), + donate_closed=self.donate_closed, ) def SetSettings( @@ -154,6 +172,7 @@ def SetSettings( raw: bool = False, full_traceback: bool = True, dump_serial: bool = False, + donate_closed: bool = False, **_, ): handler = LoggingHandler.get() @@ -181,6 +200,10 @@ def SetSettings( case _ if item.GetItemLabel() == level_name: item.Check() + if donate_closed: + # noinspection PyTypeChecker + self.OnDonateClose(None) + @on_event def OnIdle(self): while True: @@ -189,6 +212,14 @@ def OnIdle(self): except Empty: break + @on_event + def OnDonateClose(self): + self.donate_closed = True + panel: wx.Panel = self.FindWindowByName("panel_donate", self) + panel.Hide() + self.Layout() + self.Update() + def OnClose(self): super().OnClose() LoggingHandler.get().clear_emitters()