Skip to content

Commit 5ef31b0

Browse files
Install python in windows
1 parent 9c6e490 commit 5ef31b0

3 files changed

Lines changed: 43 additions & 14 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@echo off
2+
3+
@REM
4+
cd %1
5+
6+
rem --Download python installer
7+
rem Curl is included in windows since 2018
8+
curl -ss "https://www.python.org/ftp/python/3.9.9/python-3.9.9-amd64.exe" -o python-installer.exe
9+
10+
rem --Install python
11+
python-installer.exe /quiet InstallAllUsers=1 PrependPath=1
12+
del python-installer.exe
13+
14+
pause

kratos.gid/scripts/Launch.tcl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ proc Kratos::InstallAllPythonDependencies { } {
55

66
# Check if python is installed
77
if {[pythonVersion] <= 0} {
8-
if {os eq "win"} {
9-
VisitWeb "https://www.microsoft.com/es-es/p/python-39/9p7qfqmjrfp7"
8+
if {$os eq "win"} {
9+
package require gid_cross_platform
10+
gid_cross_platform::run_as_administrator [file join $::Kratos::kratos_private(Path) exec install_python.win.bat ] [lindex [Kratos::GetLaunchConfigurationFile] 0]
1011
} {
1112
exec "sudo apt-get install python3.9"
1213
}
1314
}
1415

1516
# Check if pip is installed
17+
# W [exec python -m pip --version]
1618

1719
# Install pip packages
1820
}
@@ -30,7 +32,19 @@ proc Kratos::pythonVersion {{pythonExecutable "python"}} {
3032

3133

3234
proc Kratos::CheckDependencies { } {
33-
if {[pythonVersion] <= 0} {error "Python not installed on this system. Please install python 3 manually or click on menu Kratos > Install dependencies"}
35+
if {[pythonVersion] <= 0} {
36+
set msgBox_type yesno
37+
# -do_not_ask_again 1 -do_not_ask_again_key "kratos_install_python"
38+
set reply [tk_messageBox -icon warning -type $msgBox_type -parent .gid \
39+
-message "Python 3 not installed on this system. Do you want Kratos to install it?" \
40+
-title [_ "Missing python"]]
41+
if {[string equal $reply "yes"]} {
42+
Kratos::InstallAllPythonDependencies
43+
}
44+
if {[string equal $reply "cancel"]} {
45+
46+
}
47+
}
3448

3549
}
3650

kratos.gid/scripts/Menus.tcl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ proc Kratos::CreatePreprocessModelTBar { {type "DEFAULT INSIDELEFT"} } {
4343
Kratos::ToolbarAddItem "Stop" "stop.png" {Utilities CancelProcess} [= "Cancel process"]
4444
Kratos::ToolbarAddItem "SpacerApp1" "" "" ""
4545
if {[info exists kratos_private(UseFiles)] && $kratos_private(UseFiles) == 1} {
46-
Kratos::ToolbarAddItem "Files" "files.png" [list -np- spdAux::LaunchFileWindow] [= "File handler window"]
46+
Kratos::ToolbarAddItem "Files" "files.png" [list -np- spdAux::LaunchFileWindow] [= "File handler window"]
4747
}
48-
Kratos::ToolbarAddItem "Examples" "losta.png" [list -np- ::Examples::StartWindow [apps::getActiveAppId]] [= "Examples window"]
48+
Kratos::ToolbarAddItem "Examples" "losta.png" [list -np- ::Examples::StartWindow [apps::getActiveAppId]] [= "Examples window"]
4949
Kratos::ToolbarAddItem "SpacerApp2" "" "" ""
50-
50+
5151
set app_items_toolbar [apps::ExecuteOnCurrentApp CustomToolbarItems]
5252
if {$app_items_toolbar < 1} {
5353
Kratos::ToolbarDeleteItem "SpacerApp"
@@ -83,25 +83,25 @@ proc Kratos::CreatePreprocessModelTBar { {type "DEFAULT INSIDELEFT"} } {
8383
lappend commslist [dict get $kratos_private(MenuItems) $item code]
8484
lappend helpslist [dict get $kratos_private(MenuItems) $item tex]
8585
}
86-
86+
8787
set KBitmapsNames(0) $iconslist
8888
set KBitmapsCommands(0) $commslist
8989
set KBitmapsHelp(0) $helpslist
90-
90+
9191
set prefix Pre
9292
set name KPreprocessModelbar
9393
set procname ::Kratos::CreatePreprocessModelTBar
9494
set kratos_private(ToolBars,PreprocessModelTBar) [CreateOtherBitmaps ${name} [= "Kratos toolbar"] KBitmapsNames KBitmapsCommands KBitmapsHelp $dir $procname $type $prefix]
95-
95+
9696
AddNewToolbar [= "Kratos toolbar"] ${prefix}${name}WindowGeom $procname
9797
}
9898
}
9999

100100
proc Kratos::EndCreatePreprocessTBar {} {
101101
variable kratos_private
102-
102+
103103
set name KPreprocessModelbar
104-
104+
105105
ReleaseToolbar ${name}
106106
if {[info exists kratos_private(ToolBars,PreprocessModelTBar)]} {
107107
destroy $kratos_private(ToolBars,PreprocessModelTBar)
@@ -151,6 +151,7 @@ proc Kratos::ChangeMenus { } {
151151
if {[GidUtils::VersionCmp "14.1.4d"] <0 } { set cmd [list ChangeVariables kratos_preferences] } {set cmd [list PreferencesWindow kratos_preferences]}
152152
GiDMenu::InsertOption "Kratos" [list "Kratos preferences" ] [incr pos] PRE $cmd "" "" replace =
153153
GiDMenu::InsertOption "Kratos" [list "View current log" ] [incr pos] PREPOST [list Kratos::ViewLog] "" "" replace =
154+
GiDMenu::InsertOption "Kratos" [list "Install python and dependencies" ] [incr pos] PREPOST [list Kratos::InstallAllPythonDependencies] "" "" replace =
154155
GiDMenu::InsertOption "Kratos" [list "About Kratos" ] [incr pos] PREPOST [list Kratos::About] "" "" replace =
155156
GidChangeDataLabel "Data units" ""
156157
GidChangeDataLabel "Interval" ""
@@ -165,14 +166,14 @@ proc Kratos::ChangeMenus { } {
165166
GiDMenu::InsertOption "Help" [list [_ "Visit %s web" Kratos]] end PREPOST [list VisitWeb "http://www.cimne.com/kratos"] "" "" insertafter
166167
GiDMenu::InsertOption "Help" [list [_ "Do you want to develop Kratos?"]] end PREPOST [list VisitWeb "https://github.com/KratosMultiphysics"] "" "" insertafter
167168
}
168-
169+
169170
GiDMenu::UpdateMenus
170171
}
171172

172173
proc Kratos::About {} {
173174
Splash
174175
}
175-
176+
176177

177178
proc Kratos::Splash { } {
178179
variable kratos_private
@@ -190,6 +191,6 @@ proc Kratos::Splash { } {
190191

191192
.splash.lv configure -font $fnt -background white -foreground black -relief solid -borderwidth 1 -padx 12 -pady 3
192193
update
193-
194+
194195
GiD_Set SplashWindow $prev_splash_state
195196
}

0 commit comments

Comments
 (0)