Skip to content

Commit 245e251

Browse files
committed
Refactor UI and engine code to use dynamic widgets instead of static UI widgets
1 parent 17c9cf6 commit 245e251

9 files changed

Lines changed: 1005 additions & 720 deletions

File tree

Core/MainWindow.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,25 +1267,25 @@ async def _fetch_sys():
12671267

12681268
def update_command_preview(self):
12691269
# Aperçu de commande désactivé: widget label_cmd retiré
1270-
# Résumé des options
1270+
# Résumé des options - only check static widgets if they exist
12711271
summary = []
1272-
if self.opt_onefile.isChecked():
1272+
if hasattr(self, "opt_onefile") and self.opt_onefile is not None and self.opt_onefile.isChecked():
12731273
summary.append("Onefile")
1274-
if self.opt_windowed.isChecked():
1274+
if hasattr(self, "opt_windowed") and self.opt_windowed is not None and self.opt_windowed.isChecked():
12751275
summary.append("Windowed")
1276-
if self.opt_noconfirm.isChecked():
1276+
if hasattr(self, "opt_noconfirm") and self.opt_noconfirm is not None and self.opt_noconfirm.isChecked():
12771277
summary.append("Noconfirm")
1278-
if self.opt_clean.isChecked():
1278+
if hasattr(self, "opt_clean") and self.opt_clean is not None and self.opt_clean.isChecked():
12791279
summary.append("Clean")
1280-
if self.opt_noupx.isChecked():
1280+
if hasattr(self, "opt_noupx") and self.opt_noupx is not None and self.opt_noupx.isChecked():
12811281
summary.append("NoUPX")
1282-
if self.opt_debug.isChecked():
1282+
if hasattr(self, "opt_debug") and self.opt_debug is not None and self.opt_debug.isChecked():
12831283
summary.append("Debug")
1284-
if self.opt_auto_install.isChecked():
1284+
if hasattr(self, "opt_auto_install") and self.opt_auto_install is not None and self.opt_auto_install.isChecked():
12851285
summary.append("Auto-install modules")
1286-
if self.icon_path:
1286+
if hasattr(self, "icon_path") and self.icon_path:
12871287
summary.append("Icone")
1288-
if self.output_dir_input.text().strip():
1288+
if hasattr(self, "output_dir_input") and self.output_dir_input is not None and self.output_dir_input.text().strip():
12891289
summary.append(f"Sortie: {self.output_dir_input.text().strip()}")
12901290
# Widget options_summary supprimé; plus de mise à jour de résumé visuel
12911291

@@ -1358,19 +1358,17 @@ def set_controls_enabled(self, enabled):
13581358
except Exception:
13591359
pass
13601360
self.venv_button.setEnabled(enabled)
1361-
self.output_dir_input.setEnabled(enabled)
1362-
# Désactive toutes les cases à cocher d'options
1363-
for checkbox in [
1364-
self.opt_onefile,
1365-
self.opt_windowed,
1366-
self.opt_noconfirm,
1367-
self.opt_clean,
1368-
self.opt_noupx,
1369-
self.opt_main_only,
1370-
self.opt_debug,
1371-
self.opt_auto_install,
1372-
self.opt_silent_errors,
1373-
]:
1361+
# Enable/disable static output_dir_input if it exists
1362+
if hasattr(self, "output_dir_input") and self.output_dir_input is not None:
1363+
self.output_dir_input.setEnabled(enabled)
1364+
# Désactive toutes les cases à cocher d'options (only if they exist)
1365+
checkbox_list = []
1366+
for name in ["opt_onefile", "opt_windowed", "opt_noconfirm", "opt_clean",
1367+
"opt_noupx", "opt_main_only", "opt_debug", "opt_auto_install",
1368+
"opt_silent_errors"]:
1369+
if hasattr(self, name) and getattr(self, name) is not None:
1370+
checkbox_list.append(getattr(self, name))
1371+
for checkbox in checkbox_list:
13741372
checkbox.setEnabled(enabled)
13751373
# Rafraîchir visuellement l'état grisé de tous les contrôles sensibles
13761374
try:

Core/engines_loader/registry.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,25 @@ def available_engines() -> list[str]:
165165
def bind_tabs(gui) -> None:
166166
"""Create tabs for all registered engines that expose create_tab and store indexes.
167167
Robust to individual engine failures and avoids raising to the UI layer.
168+
Also handles hiding the Hello tab when engines are available.
168169
"""
169170
try:
170171
tabs = getattr(gui, "compiler_tabs", None)
171172
if not tabs:
172173
return
174+
175+
# Get the Hello tab if it exists
176+
hello_tab = getattr(gui, "tab_hello", None)
177+
hello_tab_index = -1
178+
if hello_tab is not None:
179+
try:
180+
hello_tab_index = tabs.indexOf(hello_tab)
181+
except Exception:
182+
hello_tab_index = -1
183+
184+
# Track if any engine created a tab
185+
any_engine_tab_created = False
186+
173187
for eid in list(_ORDER):
174188
try:
175189
engine = create(eid)
@@ -181,6 +195,7 @@ def bind_tabs(gui) -> None:
181195
pair = res(gui)
182196
if not pair:
183197
continue
198+
any_engine_tab_created = True
184199
widget, label = pair
185200
try:
186201
existing = tabs.indexOf(widget)
@@ -202,11 +217,37 @@ def bind_tabs(gui) -> None:
202217
except Exception:
203218
# keep UI responsive even if a plugin tab fails
204219
continue
220+
221+
# Hide the Hello tab if any engine has created a tab
222+
if any_engine_tab_created and hello_tab_index >= 0:
223+
try:
224+
tabs.tabBar().hideTab(hello_tab_index)
225+
except Exception:
226+
pass
205227
except Exception:
206228
# Swallow to avoid breaking app init
207229
pass
208230

209231

232+
def show_hello_tab(gui) -> None:
233+
"""Show the Hello tab when no engines are available."""
234+
try:
235+
tabs = getattr(gui, "compiler_tabs", None)
236+
if not tabs:
237+
return
238+
hello_tab = getattr(gui, "tab_hello", None)
239+
if hello_tab is not None:
240+
try:
241+
idx = tabs.indexOf(hello_tab)
242+
if idx >= 0:
243+
tabs.tabBar().showTab(idx)
244+
tabs.setCurrentIndex(idx)
245+
except Exception:
246+
pass
247+
except Exception:
248+
pass
249+
250+
210251
def apply_translations(gui, tr: dict) -> None:
211252
"""Propagate i18n translations to all engines that expose 'apply_i18n(gui, tr)'."""
212253
try:

0 commit comments

Comments
 (0)