Skip to content

Commit ccf73e2

Browse files
add python path as preferences
1 parent 0f1b0d6 commit ccf73e2

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

kratos.gid/scripts/Controllers/Preferences.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
</combobox>
2121
<entrywithbutton name="debug_folder" label="Debug path" variable="debug_folder" buttonimage="folder.png" variablemanager='Kratos::ManagePreferences' buttonfunction="OpenBrowserForDirectory" help='Path to the kratos debug folder. This is placed in the launch.json file for debugging' />
2222
<comboboxframe name="launch_configuration" label="Launch configuration" variable="launch_configuration" variablemanager='Kratos::ManagePreferences' help='' >
23-
<option value='Launch via pip' label='Launch via pip'/>
24-
<option value='Launch local compiled version' label='Launch local compiled version'/>
23+
<option value='Launch via pip' label='Launch via pip' setactivate="python_path"/>
24+
<option value='Launch local compiled version' label='Launch local compiled version' setactivate="python_path"/>
2525
<option value='Docker' label='Docker' setactivate="docker_image" />
2626
<!-- <option value='Custom...' label='Custom...'/> -->
2727

28+
<entrywithbutton name="python_path" variable="python_path" label="Python path (exe)" variablemanager='Kratos::ManagePreferences' help='Path to python.exe' buttonimage="folder.png" buttonfunction="GetPythonPath"/>
2829
<entry name="docker_image" variable="docker_image" label="Docker image" variablemanager='Kratos::ManagePreferences' help='Name of the Kratos Docker image'/>
2930
</comboboxframe>
3031
</labelframe>

kratos.gid/scripts/Controllers/PreferencesWindow.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ proc Kratos::ManagePreferences { cmd name {value ""}} {
3838
"docker_image" {
3939
set ret "fjgarate/kratos-run"
4040
}
41+
"python_path" {
42+
set ret [Kratos::GetDefaultPythonPath]
43+
}
4144
default {
4245
set ret 0
4346
}

kratos.gid/scripts/Utils.tcl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ proc Kratos::RegisterEnvironment { } {
152152
#do not save preferences starting with flag gid.exe -c (that specify read only an alternative file)
153153
if { [GiD_Set SaveGidDefaults] } {
154154
variable kratos_private
155-
set vars_to_save [list DevMode echo_level mdpa_format debug_folder allow_logs launch_configuration]
155+
set vars_to_save [list DevMode echo_level mdpa_format debug_folder allow_logs launch_configuration python_path docker_image]
156156
set preferences [dict create]
157157
foreach v $vars_to_save {
158158
if {[info exists kratos_private($v)]} {
@@ -199,7 +199,7 @@ proc Kratos::LoadEnvironment { } {
199199
# W $data
200200
# Close the file
201201
close $fp
202-
202+
203203
# Preferences are written in json format
204204
foreach {k v} [write::json2dict $data] {
205205
# W "$k $v"
@@ -322,3 +322,16 @@ proc Kratos::IsDeveloperMode {} {
322322
return $is_dev
323323
}
324324

325+
proc Kratos::GetFilePath { var_name type_names_extensions } {
326+
set file [MessageBoxGetFilename file read "Get file" "" $type_names_extensions]
327+
# set filename [MessageBoxGetFilename file read [_ "Read HDF5 Vibez file"] {} {{{HDF5 Vibez} {.h5 }} {{All files} {.*}}} {} $multiple [list [_ "Import options"] Vibez::MoreImportOptions]]
328+
return $file
329+
}
330+
331+
if { ![GidUtils::IsTkDisabled] } {
332+
proc xmlprograms::GetPythonPath { baseframe variable } {
333+
set $variable [Kratos::GetFilePath ::Kratos(python_path) {{{python path} {.exe }} {{All files} {.*}}}]
334+
return variable
335+
}
336+
}
337+

0 commit comments

Comments
 (0)