I'm trying to run tcl script from python, tcl script requires command line arguments to execute, when I source the tcl file from python, it then shows the error says
tclsh.eval('source "test.tcl"' )
_tkinter.TclError: can't read "::argv": no such variable
I've done many searches, majority of them asks how to pass arguments to python in tcl.
python code
import tkinter
import sys
tclsh.eval('source "test.tcl"' )
if __name__ == '__main__':
print("hi")
tcl code
puts [lindex $::argv 0]
Is there anyway for me pass python arguments to tcl ?
or
not pass arguments and still compile ?
since if I compile tcl script only without arguments, it still compiles
Note:
In tkinter documentation it says tkinter.Tk is
The Tk class is instantiated without arguments
Is there a way to instantiated with arguments ?
Sol:
tclsh.eval('set argv [list]')
tclsh.eval('set argc 0')
I tried to set a global variable and it works for me under python 3.6