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 0000000..eb2efbc Binary files /dev/null and b/ltchiptool/gui/ko-fi.png differ diff --git a/ltchiptool/gui/ltchiptool.wxui b/ltchiptool/gui/ltchiptool.wxui index f4f022e..a56643a 100644 --- a/ltchiptool/gui/ltchiptool.wxui +++ b/ltchiptool/gui/ltchiptool.wxui @@ -166,6 +166,36 @@ border_size="0" flags="wxEXPAND" proportion="1" /> + + + + + + + #FFFFFF + + wxEXPAND + 5 + + + + wxHORIZONTAL + + wxRIGHT|wxLEFT|wxALIGN_CENTER + 5 + + 48,32 + + + + wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER + 5 + + + + https://ko-fi.com/kuba2k2 + + + + + wxALL + 5 + + 1 + + + + + diff --git a/ltchiptool/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()