1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-06 18:33:13 +03:00

Properly name the main UI tk widgets

Unfortunately we can't name the plugin ones, as that's entirely up to their
`plugin_app()` code, and widget names can't be changed after creation.

NB: Each `plugin_hr_X` frame is `grid()`'d to be *before* the plugin in
question, despite being listed *after* in:

    >>> self.w.children['edmarketconnector'].children
This commit is contained in:
Athanasius 2022-12-31 16:08:39 +00:00
parent 80e2aee6bb
commit 0705d56bb4
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -523,15 +523,15 @@ class AppWindow(object):
frame.grid(sticky=tk.NSEW) frame.grid(sticky=tk.NSEW)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
self.cmdr_label = tk.Label(frame) self.cmdr_label = tk.Label(frame, name='cmdr_label')
self.cmdr = tk.Label(frame, compound=tk.RIGHT, anchor=tk.W, name='cmdr') self.cmdr = tk.Label(frame, compound=tk.RIGHT, anchor=tk.W, name='cmdr')
self.ship_label = tk.Label(frame) self.ship_label = tk.Label(frame, name='ship_label')
self.ship = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.shipyard_url, name='ship') self.ship = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.shipyard_url, name='ship')
self.suit_label = tk.Label(frame) self.suit_label = tk.Label(frame, name='suit_label')
self.suit = tk.Label(frame, compound=tk.RIGHT, anchor=tk.W, name='suit') self.suit = tk.Label(frame, compound=tk.RIGHT, anchor=tk.W, name='suit')
self.system_label = tk.Label(frame) self.system_label = tk.Label(frame, name='system_label')
self.system = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.system_url, popup_copy=True, name='system') self.system = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.system_url, popup_copy=True, name='system')
self.station_label = tk.Label(frame) self.station_label = tk.Label(frame, name='station_label')
self.station = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.station_url, name='station') self.station = HyperlinkLabel(frame, compound=tk.RIGHT, url=self.station_url, name='station')
# system and station text is set/updated by the 'provider' plugins # system and station text is set/updated by the 'provider' plugins
# eddb, edsm and inara. Look for: # eddb, edsm and inara. Look for:
@ -560,10 +560,14 @@ class AppWindow(object):
self.station.grid(row=ui_row, column=1, sticky=tk.EW) self.station.grid(row=ui_row, column=1, sticky=tk.EW)
ui_row += 1 ui_row += 1
plugin_no = 0
for plugin in plug.PLUGINS: for plugin in plug.PLUGINS:
appitem = plugin.get_app(frame) appitem = plugin.get_app(frame)
if appitem: if appitem:
tk.Frame(frame, highlightthickness=1).grid(columnspan=2, sticky=tk.EW) # separator plugin_no += 1
tk.Frame(
frame, highlightthickness=1, name=f"plugin_hr_{plugin_no}"
).grid(columnspan=2, sticky=tk.EW) # separator
if isinstance(appitem, tuple) and len(appitem) == 2: if isinstance(appitem, tuple) and len(appitem) == 2:
ui_row = frame.grid_size()[1] ui_row = frame.grid_size()[1]
appitem[0].grid(row=ui_row, column=0, sticky=tk.W) appitem[0].grid(row=ui_row, column=0, sticky=tk.W)
@ -573,8 +577,20 @@ class AppWindow(object):
appitem.grid(columnspan=2, sticky=tk.EW) appitem.grid(columnspan=2, sticky=tk.EW)
# LANG: Update button in main window # LANG: Update button in main window
self.button = ttk.Button(frame, text=_('Update'), width=28, default=tk.ACTIVE, state=tk.DISABLED) self.button = ttk.Button(
self.theme_button = tk.Label(frame, width=32 if sys.platform == 'darwin' else 28, state=tk.DISABLED) frame,
name='update_button',
text=_('Update'),
width=28,
default=tk.ACTIVE,
state=tk.DISABLED
)
self.theme_button = tk.Label(
frame,
name='themed_update_button',
width=32 if sys.platform == 'darwin' else 28,
state=tk.DISABLED
)
ui_row = frame.grid_size()[1] ui_row = frame.grid_size()[1]
self.button.grid(row=ui_row, columnspan=2, sticky=tk.NSEW) self.button.grid(row=ui_row, columnspan=2, sticky=tk.NSEW)