Drawing on tkinter canvas from command line
<p>I read some tutorial (basic) on tkinter and learned how to create a mainloop and add gui elements to that. Also learned how to bind actions to button widgets.</p>

<p>Now I would like to do this: </p>

<ol>
<li>launch the tkinter canvas</li>
<li>be able to read command from the console and update the canvas after those commands.</li>
</ol>

<p>example:
I write command with arguments on the console and some graphics elements is being added to the canvas (and canvas is updated after).</p>

<p>Is something possible, maybe threding related?
Can you point me in one direction which you think is the most reasonable to follow?</p>

<p>Here's a simple demo of grabbing user input from the console via the standard <code>input</code> function. This technique is a little clunky, since we have to explicitly tell Tkinter to fetch the input string by clicking on a Button (or some other GUI event), but that might not be a big deal for your application.</p>

<pre><code>import tkinter as tk

root = tk.Tk()
stuff = tk.StringVar()
display = tk.Label(root, textvariable=stuff)
display.pack()

def get_input():
    s = input("CMD: ")
    stuff.set(s)

tk.Button(root, text="Get input", command=get_input).pack()
root.mainloop()
</code></pre>

<p>When you click on the <code>"Get input"</code> Button, the "CMD: " prompt will be printed in the console window. Once the input is entered, the string is copied to the Label. Bad Thingsâ¢ will happen if you click the button again before the input line is entered. :)</p>

python canvas tkinter