@@ -198,53 +198,54 @@ def init_ui(self):
198198 from PySide6 .QtGui import QPixmap
199199 from PySide6 .QtWidgets import QApplication
200200
201- project_dir = os .path .abspath (os .path .dirname (sys .argv [0 ]))
202- # Choose logo based on effective theme from QSS when available; fallback to system scheme
203- try :
204- app = QApplication .instance ()
205- css = app .styleSheet () if app else ""
206- if css :
207- eff_mode = "dark" if _is_qss_dark (css ) else "light"
208- else :
209- eff_mode = _detect_system_color_scheme ()
210- except Exception :
211- eff_mode = "light"
212- candidates = [
213- (
214- os .path .join (project_dir , "logo" , "sidebar_logo2.png" )
215- if eff_mode == "dark"
216- else os .path .join (project_dir , "logo" , "sidebar_logo.png" )
217- ),
218- os .path .join (project_dir , "logo" , "sidebar_logo.png" ),
219- os .path .join (project_dir , "logo" , "sidebar_logo2.png" ),
220- ]
221- logo_path = None
222- for p in candidates :
223- if os .path .exists (p ):
224- logo_path = p
225- break
226- if logo_path :
227- pixmap = QPixmap (logo_path )
228- target_size = 200
229- self .sidebar_logo .setPixmap (
230- pixmap .scaled (
231- target_size ,
232- target_size ,
233- Qt .AspectRatioMode .KeepAspectRatio ,
234- Qt .TransformationMode .SmoothTransformation ,
235- )
236- )
237- self .sidebar_logo .setToolTip ("PyCompiler" )
201+ if self .sidebar_logo :
202+ project_dir = os .path .abspath (os .path .dirname (sys .argv [0 ]))
203+ # Choose logo based on effective theme from QSS when available; fallback to system scheme
238204 try :
239- self .sidebar_logo .setContentsMargins (13 , 0 , 0 , 0 )
240- except Exception :
241- pass
242- else :
243- self .sidebar_logo .setText ("PyCompiler" )
244- try :
245- self .sidebar_logo .setContentsMargins (12 , 0 , 0 , 0 )
205+ app = QApplication .instance ()
206+ css = app .styleSheet () if app else ""
207+ if css :
208+ eff_mode = "dark" if _is_qss_dark (css ) else "light"
209+ else :
210+ eff_mode = _detect_system_color_scheme ()
246211 except Exception :
247- pass
212+ eff_mode = "light"
213+ candidates = [
214+ (
215+ os .path .join (project_dir , "logo" , "sidebar_logo2.png" )
216+ if eff_mode == "dark"
217+ else os .path .join (project_dir , "logo" , "sidebar_logo.png" )
218+ ),
219+ os .path .join (project_dir , "logo" , "sidebar_logo.png" ),
220+ os .path .join (project_dir , "logo" , "sidebar_logo2.png" ),
221+ ]
222+ logo_path = None
223+ for p in candidates :
224+ if os .path .exists (p ):
225+ logo_path = p
226+ break
227+ if logo_path :
228+ pixmap = QPixmap (logo_path )
229+ target_size = 200
230+ self .sidebar_logo .setPixmap (
231+ pixmap .scaled (
232+ target_size ,
233+ target_size ,
234+ Qt .AspectRatioMode .KeepAspectRatio ,
235+ Qt .TransformationMode .SmoothTransformation ,
236+ )
237+ )
238+ self .sidebar_logo .setToolTip ("PyCompiler" )
239+ try :
240+ self .sidebar_logo .setContentsMargins (13 , 0 , 0 , 0 )
241+ except Exception :
242+ pass
243+ else :
244+ self .sidebar_logo .setText ("PyCompiler" )
245+ try :
246+ self .sidebar_logo .setContentsMargins (12 , 0 , 0 , 0 )
247+ except Exception :
248+ pass
248249 self .btn_select_files = self .ui .findChild (QPushButton , "btn_select_files" )
249250 self .btn_remove_file = self .ui .findChild (QPushButton , "btn_remove_file" )
250251 self .btn_build_all = self .ui .findChild (QPushButton , "btn_build_all" )
0 commit comments