DawnC commited on
Commit
fcac4bd
·
verified ·
1 Parent(s): d03d09e

Update ui_manager.py

Browse files
Files changed (1) hide show
  1. ui_manager.py +32 -26
ui_manager.py CHANGED
@@ -243,24 +243,24 @@ class UIManager:
243
  def create_interface(self):
244
  """Create professional user interface"""
245
 
246
- css = CSSStyles.get_main_css()
247
-
248
- # Gradio 4.x/5.x compatible initialization
249
- blocks_kwargs = {
250
- "title": "SceneWeaver - AI Background Generator",
251
- "theme": gr.themes.Soft()
252
- }
253
-
254
- # Check Gradio version for css parameter compatibility
255
- gradio_version = gr.__version__
256
- major_version = int(gradio_version.split('.')[0])
257
-
258
- if major_version >= 5:
259
- # Gradio 5.x: use head parameter for CSS injection
260
- blocks_kwargs["head"] = f"<style>{css}</style>"
261
  else:
262
- # Gradio 4.x: use css parameter directly
263
- blocks_kwargs["css"] = css
 
 
 
264
 
265
  with gr.Blocks(**blocks_kwargs) as interface:
266
 
@@ -515,12 +515,18 @@ class UIManager:
515
  """Launch the UI interface"""
516
  interface = self.create_interface()
517
 
518
- return interface.launch(
519
- share=share,
520
- debug=debug,
521
- show_error=True,
522
- height=800,
523
- favicon_path=None,
524
- ssl_verify=False,
525
- quiet=False
526
- )
 
 
 
 
 
 
 
243
  def create_interface(self):
244
  """Create professional user interface"""
245
 
246
+ self._css = CSSStyles.get_main_css()
247
+
248
+ # Check Gradio version for API compatibility
249
+ self._gradio_version = gr.__version__
250
+ self._gradio_major = int(self._gradio_version.split('.')[0])
251
+
252
+ # Gradio 5.x: css/theme moved to launch(), Blocks() has minimal params
253
+ # Gradio 4.x: css/theme are in Blocks() constructor
254
+ if self._gradio_major >= 5:
255
+ blocks_kwargs = {
256
+ "title": "SceneWeaver - AI Background Generator"
257
+ }
 
 
 
258
  else:
259
+ blocks_kwargs = {
260
+ "css": self._css,
261
+ "title": "SceneWeaver - AI Background Generator",
262
+ "theme": gr.themes.Soft()
263
+ }
264
 
265
  with gr.Blocks(**blocks_kwargs) as interface:
266
 
 
515
  """Launch the UI interface"""
516
  interface = self.create_interface()
517
 
518
+ # Build launch kwargs based on Gradio version
519
+ launch_kwargs = {
520
+ "share": share,
521
+ "debug": debug,
522
+ "show_error": True,
523
+ "quiet": False
524
+ }
525
+
526
+ # Gradio 5.x: css/theme are passed to launch()
527
+ # Gradio 4.x: these were already set in Blocks()
528
+ if self._gradio_major >= 5:
529
+ launch_kwargs["css"] = self._css
530
+ launch_kwargs["theme"] = gr.themes.Soft()
531
+
532
+ return interface.launch(**launch_kwargs)