[Tutor] text programme in graphical box

Alan Gauld alan.gauld at freenet.co.uk
Wed Dec 29 23:24:39 CET 2004

> root = Tk()
> cv = Canvas(root, width=400, height=300, bg="blue")
> cv.pack()
> mainloop()
> any way what i would like to do is create a programme that would run
my text
> programme from this graphical box

You need to use a Text box not a Canvas. Canvas is for drawing
shapes and displaying images etc.

If you use a Text box you can simply convert your print messages
into insertions into the text box. Alternatrively use a simple
label but change the text each time. That way you only see the
latest message...

Your prompts and inputs can be a label and Text Entry pair,
simply change the contents of the label and read the contents
of the entry box.

Examples of all of this can be found in the GUI and Case Study
topics in my tutorial.

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list