I have a tcl proc that takes 3 arguments. Two are strings and the other is another tcl proc. Basically:
proc handler_sub {data}{
[<Do more stuff with data>]
}
proc handler {stringone stringtwo otherfunction} {
[<Do stuff with stringone and stringtwo, send output to otherfunction>]
}
.randomwidget handler -stringone $randomstrring -stringtwo $anotherrandomstrring -otherfunction handler_sub
Now, I need to call the handler
proc from tkinter.
I have tried this:
import tkinter
root = tkinter.Tk()
randomwidget = SomeCustomWidget(root)
def handler_sub(data):
#Do some python magic
randomwidget.tk.call(randomwidget._w, "handler", "-stringone", randomstrring, "-stringtwo", anotherrandomstrring, "-otherfunction", handler_sub)
randomwidget.pack()
root.mainloop()
But the handler_sub
function is not getting called (no error codes are returned, either). It seems that the two strings are passed to tcl without any issues, though.
Basically, I need to pass a python function to tcl code, somewhat like how I can set a python function to be called when a tk.Button
is pressed. I'm sure that it is possible, but I can't figure out how to do it.
Any insights would be highly appreciated.