@@ -52,12 +52,13 @@ class DocumentationFrame: # pylint: disable=too-few-public-methods
52
52
functionality to open these links in a web browser.
53
53
"""
54
54
55
- def __init__ (self , root : tk .Widget , local_filesystem , current_file : str ) -> None :
55
+ def __init__ (self , root : tk .Widget , local_filesystem : LocalFilesystem , current_file : str ) -> None :
56
56
self .root = root
57
57
self .local_filesystem = local_filesystem
58
58
self .current_file = current_file
59
59
self .documentation_frame : ttk .LabelFrame
60
60
self .documentation_labels : dict [str , ttk .Label ] = {}
61
+ self .auto_open_var = tk .BooleanVar (value = bool (ProgramSettings .get_setting ("auto_open_doc_in_browser" )))
61
62
self .__create_documentation_frame ()
62
63
63
64
def __create_documentation_frame (self ) -> None :
@@ -84,9 +85,32 @@ def __create_documentation_frame(self) -> None:
84
85
label .grid (row = i , column = 0 , sticky = "w" )
85
86
show_tooltip (label , descriptive_tooltips [i ])
86
87
87
- # Create labels for the second column with the documentation links
88
- self .documentation_labels [text ] = ttk .Label (documentation_grid )
89
- self .documentation_labels [text ].grid (row = i , column = 1 , sticky = "w" )
88
+ if i == 3 :
89
+ bottom_frame = ttk .Frame (documentation_grid )
90
+ bottom_frame .grid (row = i , column = 1 , sticky = "ew" ) # ew to stretch horizontally
91
+
92
+ self .documentation_labels [text ] = ttk .Label (bottom_frame )
93
+ self .documentation_labels [text ].pack (side = tk .LEFT , fill = "x" , expand = True )
94
+ auto_open_checkbox = ttk .Checkbutton (
95
+ bottom_frame ,
96
+ text = _ ("Automatically open documentation links in browser" ),
97
+ variable = self .auto_open_var ,
98
+ command = lambda : ProgramSettings .set_setting ("auto_open_doc_in_browser" , self .auto_open_var .get ()),
99
+ )
100
+ show_tooltip (
101
+ auto_open_checkbox ,
102
+ _ (
103
+ "Automatically open all the above documentation links in a browser\n "
104
+ "whenever the current intermediate parameter file changes"
105
+ ),
106
+ )
107
+ auto_open_checkbox .pack (side = tk .LEFT , expand = False )
108
+ else :
109
+ # Create labels for the second column with the documentation links
110
+ self .documentation_labels [text ] = ttk .Label (documentation_grid )
111
+ self .documentation_labels [text ].grid (row = i , column = 1 , sticky = "ew" )
112
+ documentation_grid .columnconfigure (0 , weight = 0 )
113
+ documentation_grid .columnconfigure (1 , weight = 1 )
90
114
91
115
# Dynamically update the documentation text and URL links
92
116
self .update_documentation_labels (self .current_file )
@@ -111,6 +135,14 @@ def update_documentation_labels(self, current_file: str) -> None:
111
135
mandatory_text , mandatory_url = self .local_filesystem .get_documentation_text_and_url (current_file , "mandatory" )
112
136
self .__update_documentation_label (_ ("Mandatory:" ), mandatory_text , mandatory_url , False )
113
137
138
+ if self .auto_open_var .get ():
139
+ if wiki_url :
140
+ webbrowser_open (url = wiki_url , new = 0 , autoraise = False )
141
+ if external_tool_url :
142
+ webbrowser_open (url = external_tool_url , new = 0 , autoraise = False )
143
+ if blog_url :
144
+ webbrowser_open (url = blog_url , new = 0 , autoraise = True )
145
+
114
146
def __update_documentation_label (self , label_key , text , url , url_expected = True ) -> None :
115
147
label = self .documentation_labels [label_key ]
116
148
if url :
0 commit comments