Python
make tabs use preferred positions set by plugin api
Chris Malone29e574629840
diff --git a/plugins/wan2gp-about/plugin.py b/plugins/wan2gp-about/plugin.pyindex 7e234d1..85ab705 100644--- a/plugins/wan2gp-about/plugin.py+++ b/plugins/wan2gp-about/plugin.py@@ -12,7 +12,8 @@ class AboutPlugin(WAN2GPPlugin):self.add_tab(tab_id="about_tab",label="About",- component_constructor=self.create_about_ui+ component_constructor=self.create_about_ui,+ position=7)def create_about_ui(self):diff --git a/plugins/wan2gp-configuration/plugin.py b/plugins/wan2gp-configuration/plugin.pyindex 3101a92..6c9e5b6 100644--- a/plugins/wan2gp-configuration/plugin.py+++ b/plugins/wan2gp-configuration/plugin.py@@ -40,7 +40,8 @@ class ConfigTabPlugin(WAN2GPPlugin):self.add_tab(tab_id="configuration",label="Configuration",- component_constructor=self.create_config_ui+ component_constructor=self.create_config_ui,+ position=2)def create_config_ui(self):@@ -136,6 +137,12 @@ class ConfigTabPlugin(WAN2GPPlugin):label="Enabled Plugins (requires restart)",interactive=not self.args.lock_config)+ self.sort_plugins_alphabetically_choice = gr.Dropdown(+ choices=[("By Position (Default)", False), ("Alphabetically", True)],+ value=self.server_config.get("sort_plugins_alphabetically", False),+ label="Plugin Tab Sorting",+ interactive=not self.args.lock_config+ )with gr.Tab("Outputs"):self.video_output_codec_choice = gr.Dropdown(choices=[("x265 CRF 28 (Balanced)", 'libx265_28'), ("x264 Level 8 (Balanced)", 'libx264_8'), ("x265 CRF 8 (High Quality)", 'libx265_8'), ("x264 Level 10 (High Quality)", 'libx264_10'), ("x264 Lossless", 'libx264_lossless')], value=self.server_config.get("video_output_codec", "libx264_8"), label="Video Codec")@@ -166,7 +173,7 @@ class ConfigTabPlugin(WAN2GPPlugin):fit_canvas_choice, preload_in_VRAM_choice, depth_anything_v2_variant_choice,notification_sound_enabled_choice, notification_sound_volume_choice, max_frames_multiplier_choice,display_stats_choice, video_output_codec_choice, image_output_codec_choice, audio_output_codec_choice,- enabled_plugins_choice, last_resolution_choice) = args+ enabled_plugins_choice, sort_plugins_alphabetically_choice, last_resolution_choice) = argsnew_server_config = {"attention_mode": attention_choice, "transformer_types": transformer_types_choices,@@ -186,6 +193,7 @@ class ConfigTabPlugin(WAN2GPPlugin):"video_output_codec": video_output_codec_choice, "image_output_codec": image_output_codec_choice,"audio_output_codec": audio_output_codec_choice,"enabled_plugins": enabled_plugins_choice,+ "sort_plugins_alphabetically": sort_plugins_alphabetically_choice,"last_model_type": state["model_type"], "last_model_per_family": state["last_model_per_family"],"last_advanced_choice": state["advanced"], "last_resolution_choice": last_resolution_choice,"last_resolution_per_group": state["last_resolution_per_group"],@@ -218,7 +226,8 @@ class ConfigTabPlugin(WAN2GPPlugin):self.enhancer_enabled_choice, self.enhancer_mode_choice, self.mmaudio_enabled_choice, self.fit_canvas_choice,self.preload_in_VRAM_choice, self.depth_anything_v2_variant_choice, self.notification_sound_enabled_choice,self.notification_sound_volume_choice, self.max_frames_multiplier_choice, self.display_stats_choice,- self.video_output_codec_choice, self.image_output_codec_choice, self.audio_output_codec_choice, self.enabled_plugins_choice, resolution+ self.video_output_codec_choice, self.image_output_codec_choice, self.audio_output_codec_choice,+ self.enabled_plugins_choice, self.sort_plugins_alphabetically_choice, resolution]self.apply_btn.click(diff --git a/plugins/wan2gp-downloads/plugin.py b/plugins/wan2gp-downloads/plugin.pyindex 902c1f7..eb9d671 100644--- a/plugins/wan2gp-downloads/plugin.py+++ b/plugins/wan2gp-downloads/plugin.py@@ -22,7 +22,8 @@ class DownloadsPlugin(WAN2GPPlugin):self.add_tab(tab_id="downloads",label="Downloads",- component_constructor=self.create_downloads_ui+ component_constructor=self.create_downloads_ui,+ position=4)def create_downloads_ui(self):diff --git a/plugins/wan2gp-guides/plugin.py b/plugins/wan2gp-guides/plugin.pyindex adc498d..fc84e16 100644--- a/plugins/wan2gp-guides/plugin.py+++ b/plugins/wan2gp-guides/plugin.py@@ -12,7 +12,8 @@ class GuidesPlugin(WAN2GPPlugin):self.add_tab(tab_id="info",label="Guides",- component_constructor=self.create_guides_ui+ component_constructor=self.create_guides_ui,+ position=6)def create_guides_ui(self):diff --git a/plugins/wan2gp-plugin-manager/plugin.py b/plugins/wan2gp-plugin-manager/plugin.pyindex b9a4f61..527ac28 100644--- a/plugins/wan2gp-plugin-manager/plugin.py+++ b/plugins/wan2gp-plugin-manager/plugin.py@@ -22,7 +22,7 @@ class PluginManagerUIPlugin(WAN2GPPlugin):tab_id="plugin_manager_tab",label="Plugins",component_constructor=self.create_plugin_manager_ui,- position=2+ position=3)def _get_js_script_html(self):diff --git a/shared/utils/plugins.py b/shared/utils/plugins.pyindex 0d7636d..a3604eb 100644--- a/shared/utils/plugins.py+++ b/shared/utils/plugins.py@@ -361,10 +361,18 @@ class WAN2GPApplication:plugin_ui = self.plugin_manager.setup_ui()plugin_tabs = plugin_ui.get('tabs', {})- sorted_plugin_tabs = sorted(- plugin_tabs.items(),- key=lambda item: item[1].get('position', -1)- )+ sort_alphabetically = server_config.get("sort_plugins_alphabetically", False)++ if sort_alphabetically:+ sorted_plugin_tabs = sorted(+ plugin_tabs.items(),+ key=lambda item: item[1]['label']+ )+ else:+ sorted_plugin_tabs = sorted(+ plugin_tabs.items(),+ key=lambda item: (item[1].get('position', -1), item[1]['label'])+ )for tab_id, tab_info in sorted_plugin_tabs:with gr.Tab(tab_info['label'], id=f"plugin_{tab_id}"):diff --git a/wgp.py b/wgp.pyindex cf5b031..5311d91 100644--- a/wgp.py+++ b/wgp.py@@ -1827,6 +1827,7 @@ if not Path(server_config_filename).is_file():"profile" : profile_type.LowRAM_LowVRAM,"preload_model_policy": [],"UI_theme": "default",+ "sort_plugins_alphabetically": False,"enabled_plugins": ["wan2gp-gallery", "wan2gp-lora-multipliers-ui", "wan2gp-plugin-manager", "wan2gp-about", "wan2gp-downloads", "wan2gp-guides", "wan2gp-configuration", "wan2gp-video-mask-creator"]}