Skip to content

Commit

Permalink
[gui] Support user site-packages plugin install GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Mar 9, 2024
1 parent 7ad41da commit 48f90e1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ltchiptool/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, *args, **kw):

windows = [
("flash", FlashPanel),
("plugins", (not ltim.is_bundled) and PluginsPanel),
("plugins", PluginsPanel),
("install", ltim.is_gui_entrypoint and os.name == "nt" and InstallPanel),
("about", AboutPanel),
]
Expand Down
25 changes: 25 additions & 0 deletions ltchiptool/gui/panels/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ltchiptool.gui.utils import on_event, with_event
from ltchiptool.gui.work.plugins import PluginsThread
from ltchiptool.util.lpm import LPM
from ltchiptool.util.ltim import LTIM
from ltctplugin.base import PluginBase

from .base import BasePanel
Expand Down Expand Up @@ -223,6 +224,7 @@ def __init__(self, parent: wx.Window, frame):
self.LoadXRC("PluginsPanel")
self.AddToNotebook("Plugins")

self.ltim = LTIM.get()
self.lpm = LPM.get()
self.model = PluginsDataModel()
self.results: list[LPM.SearchResult] = []
Expand All @@ -242,6 +244,29 @@ def __init__(self, parent: wx.Window, frame):
self.InstallInput = self.BindTextCtrl("input_install")
self.InstallButton = self.BindButton("button_install", self.OnInstallClick)

self.SitePath = self.BindTextCtrl("input_site_path")
self.SiteReason = self.FindStaticText("text_site_reason")

reason = "unknown"
if self.ltim.is_bundled:
if self.ltim.is_windows():
reason = "running Windows .EXE bundle"
elif self.ltim.is_macos():
reason = "running macOS App Bundle"
else:
reason = "running a bundled copy"
elif self.lpm.plugin_site_path:
reason = "path set in sitecustomize.py"
elif self.ltim.is_dev:
reason = "development copy - editable"
elif "site-packages" in __file__:
reason = "installed using pip"

self.SitePath.SetLabelText(
str(self.lpm.plugin_site_path or "Python-default site-packages")
)
self.SiteReason.SetLabel(f"(reason: {reason})")

def OnWorkStopped(self, t: PluginsThread):
super().OnWorkStopped(t)
if t.search:
Expand Down
16 changes: 15 additions & 1 deletion ltchiptool/gui/res/ltchiptool.wxui
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,20 @@
orientation="wxVERTICAL"
var_name="sizer_main_plugins"
flags="wxEXPAND">
<node
class="wxStaticText"
label="Plugins will be installed to:"
borders="wxTOP|wxRIGHT|wxLEFT" />
<node
class="wxTextCtrl"
style="wxTE_READONLY"
var_name="input_site_path"
flags="wxEXPAND" />
<node
class="wxStaticText"
label="(reason: unknown)"
var_name="text_site_reason"
borders="wxBOTTOM|wxRIGHT|wxLEFT" />
<node
class="wxDataViewCtrl"
style="wxDV_HORIZ_RULES"
Expand All @@ -663,7 +677,7 @@
flags="wxEXPAND">
<node
class="wxButton"
label="Download plugins..."
label="Search for plugins..."
var_name="button_download"
flags="wxEXPAND" />
<node
Expand Down
25 changes: 24 additions & 1 deletion ltchiptool/gui/res/ltchiptool.xrc
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,29 @@
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer" name="sizer_main_plugins">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxTOP|wxRIGHT|wxLEFT</flag>
<border>5</border>
<object class="wxStaticText" name="m_staticText">
<label>Plugins will be installed to:</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxTextCtrl" name="input_site_path">
<style>wxTE_READONLY</style>
</object>
</object>
<object class="sizeritem">
<flag>wxBOTTOM|wxRIGHT|wxLEFT</flag>
<border>5</border>
<object class="wxStaticText" name="text_site_reason">
<label>(reason: unknown)</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
Expand All @@ -799,7 +822,7 @@
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxButton" name="button_download">
<label>Download plugins...</label>
<label>Search for plugins...</label>
</object>
</object>
<object class="sizeritem">
Expand Down

0 comments on commit 48f90e1

Please sign in to comment.