-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
157 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (c) Kuba Szczodrzyński 2023-12-14. | ||
|
||
from logging import INFO | ||
|
||
import wx | ||
import wx.xrc | ||
|
||
from ltchiptool.util.logging import LoggingHandler | ||
from ltchiptool.util.ltim import LTIM | ||
|
||
from .base.window import BaseWindow | ||
from .panels.log import LogPanel | ||
from .utils import load_xrc_file | ||
from .work.install import InstallThread | ||
|
||
|
||
# noinspection PyPep8Naming | ||
class InstallFrame(wx.Frame, BaseWindow): | ||
def __init__(self, install_kwargs: dict, *args, **kw): | ||
super().__init__(*args, **kw) | ||
|
||
xrc = LTIM.get().get_gui_resource("ltchiptool.xrc") | ||
icon = LTIM.get().get_gui_resource("ltchiptool.ico") | ||
self.Xrc = load_xrc_file(xrc) | ||
|
||
LoggingHandler.get().level = INFO | ||
LoggingHandler.get().exception_hook = self.ShowExceptionMessage | ||
|
||
self.Log = LogPanel(parent=self, frame=self) | ||
# noinspection PyTypeChecker | ||
self.Log.OnDonateClose(None) | ||
|
||
self.install_kwargs = install_kwargs | ||
|
||
self.Bind(wx.EVT_SHOW, self.OnShow) | ||
self.Bind(wx.EVT_CLOSE, self.OnClose) | ||
|
||
self.SetTitle("Installing ltchiptool") | ||
self.SetIcon(wx.Icon(str(icon), wx.BITMAP_TYPE_ICO)) | ||
self.SetSize((1000, 400)) | ||
self.SetMinSize((600, 200)) | ||
self.Center() | ||
|
||
@staticmethod | ||
def ShowExceptionMessage(e, msg): | ||
wx.MessageBox( | ||
message="Installation failed!\n\nRefer to the log window for details.", | ||
caption="Error", | ||
style=wx.ICON_ERROR, | ||
) | ||
|
||
def OnShow(self, *_): | ||
self.InitWindow(self) | ||
self.StartWork(InstallThread(**self.install_kwargs)) | ||
|
||
def OnClose(self, *_): | ||
self.StopWork(InstallThread) | ||
self.Destroy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) Kuba Szczodrzyński 2023-12-14. | ||
|
||
from ltchiptool.util.ltim import LTIM | ||
|
||
from .base import BaseThread | ||
|
||
|
||
class InstallThread(BaseThread): | ||
def __init__(self, **kwargs): | ||
super().__init__() | ||
self.kwargs = kwargs | ||
|
||
def run_impl(self): | ||
LTIM.get().install(**self.kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters