-1

I am running my performance test on python and I want to call some Tcl commands using Tkinter inside my python script.

Can somebody please help me to write the code,

import Tkinter

root = Tkinter.Tk()

root.tk.eval('puts {printed by tcl}')

I tried simply above example, here when I do root=tkinter.tk() it opens up a window, I just want to execute my command and get the result

2
  • Does this answer your question? Using Python functions in Tkinter.Tcl() Commented Jun 7, 2020 at 14:26
  • Your code works for me. The tcl code is executed and the message is printed. Commented Jun 7, 2020 at 14:44

1 Answer 1

1

The code you have tried will not show any window until you put the root.mainloop(),but you can try something like this,

import tkinter

root = tkinter.Tk()
root.withdraw()

root.tk.eval('puts {printed by tcl}')

root.destroy()
root.mainloop()

here withdraw() will remove the window from the screen without destroying it and then you can perform your tasks and then destroy it at the end of code.

Sign up to request clarification or add additional context in comments.

1 Comment

In my actual code, I have to run a command call "vsi", when I run the command vsi using tclscript, vsi gets executed,Here I get error from tkinter import Tcl tcl= Tcl() tcl.eval('puts {printed by tcl}') tcl.eval('vsi') Error :printed by tcl Traceback (most recent call last): File "./tkex.py", line 5, in <module> tcl.eval('vsi') _tkinter.TclError: invalid command name "vsi" I am seeing above error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.