4646 ContentDialogButton ,
4747 FontIcon ,
4848 Grid ,
49+ HyperlinkButton ,
4950 InfoBar ,
5051 MenuFlyout ,
5152 MenuFlyoutItem ,
@@ -106,10 +107,14 @@ def show(self):
106107 page_title = content .find_name ("PageTitle" ).as_ (TextBlock )
107108 select_bar_label = content .find_name ("SelectBarLabel" ).as_ (TextBlock )
108109 bar_selector = content .find_name ("BarSelector" ).as_ (ComboBox )
110+ add_widget_button = content .find_name ("AddWidgetButton" ).as_ (Button )
111+ add_widget_text = content .find_name ("AddWidgetText" ).as_ (TextBlock )
109112 self ._sections_panel = content .find_name ("SectionsPanel" ).as_ (StackPanel )
110113
111114 page_title .text = t ("widgets_title" )
112115 select_bar_label .text = t ("bars_selection" )
116+ add_widget_text .text = t ("widgets_add" )
117+ add_widget_button .add_click (lambda s , e : self ._show_add_widget_dialog (None ))
113118
114119 self ._create_sections ()
115120
@@ -582,12 +587,22 @@ def _show_edit_widget_dialog(self, widget_name, position):
582587 if not widget :
583588 warning (f"Widget not found: { widget_name } " )
584589 return
590+
591+ # Get doc_link from registry by matching type_path
592+ widget_type = widget .get ("type" , "unknown" )
593+ doc_link = ""
594+ for wid , info in self ._widget_registry .items ():
595+ if info .type_path == widget_type :
596+ doc_link = getattr (info , "doc_link" , "" )
597+ break
598+
585599 self ._show_widget_editor_dialog (
586600 widget_name = widget_name ,
587- widget_type = widget . get ( "type" , "unknown" ) ,
601+ widget_type = widget_type ,
588602 options = widget .get ("options" , {}),
589603 position = position ,
590604 is_new = False ,
605+ doc_link = doc_link ,
591606 )
592607
593608 def _show_new_widget_dialog (self , widget_info , position ):
@@ -607,9 +622,10 @@ def _show_new_widget_dialog(self, widget_info, position):
607622 options = widget_info ["defaults" ].copy () if widget_info ["defaults" ] else {},
608623 position = position ,
609624 is_new = True ,
625+ doc_link = widget_info .get ("doc_link" , "" ),
610626 )
611627
612- def _show_widget_editor_dialog (self , widget_name , widget_type , options , position , is_new ):
628+ def _show_widget_editor_dialog (self , widget_name , widget_type , options , position , is_new , doc_link = "" ):
613629 """Show dialog to edit or create a widget's options using Monaco editor.
614630
615631 Args:
@@ -618,6 +634,7 @@ def _show_widget_editor_dialog(self, widget_name, widget_type, options, position
618634 options: Widget options dict
619635 position: Bar position ("left", "center", "right") or None
620636 is_new: True if creating new widget, False if editing existing
637+ doc_link: URL to widget documentation (optional)
621638 """
622639 try :
623640 self ._app ._loading = True
@@ -650,6 +667,7 @@ def _show_widget_editor_dialog(self, widget_name, widget_type, options, position
650667 name_input = dialog_content .find_name ("NameInput" ).as_ (TextBox )
651668 name_error = dialog_content .find_name ("NameError" ).as_ (TextBlock )
652669 type_text = dialog_content .find_name ("TypeText" ).as_ (TextBlock )
670+ docs_link = dialog_content .find_name ("DocsLink" ).as_ (HyperlinkButton )
653671 options_label = dialog_content .find_name ("OptionsLabel" ).as_ (TextBlock )
654672 webview = dialog_content .find_name ("EditorWebView" ).as_ (WebView2 )
655673 loading_overlay = dialog_content .find_name ("LoadingOverlay" ).as_ (Grid )
@@ -658,6 +676,13 @@ def _show_widget_editor_dialog(self, widget_name, widget_type, options, position
658676 type_text .text = widget_type
659677 options_label .text = t ("widgets_options" )
660678
679+ # Set up docs link if available
680+ if doc_link :
681+ docs_link_text = dialog_content .find_name ("DocsLinkText" ).as_ (TextBlock )
682+ docs_link_text .text = t ("widgets_docs_link" )
683+ docs_link .add_click (lambda s , e , url = doc_link : __import__ ("webbrowser" ).open (url ))
684+ docs_link .visibility = Visibility .VISIBLE
685+
661686 # Name validation state
662687 editor_state_name = {"valid" : True , "original_name" : widget_name }
663688
@@ -929,6 +954,7 @@ def _setup_widget_data(self):
929954 "description" : info .description ,
930955 "type_path" : info .type_path ,
931956 "defaults" : getattr (info , "defaults" , {}),
957+ "doc_link" : getattr (info , "doc_link" , "" ),
932958 }
933959 )
934960 all_widgets .sort (key = lambda x : (x ["category" ], x ["name" ]))
0 commit comments