I am having problems with Tkinter

The following programme is supposed to draw a line, but I don’t see it.

from tkinter import *
root = Tk()
canvas = Canvas()

root.geometry("500x500")
root.mainloop()
tkinter.colorchooser

canvas.create_line(15, 25, 200, 25, width=15)
canvas.pack()

What am I missing?

You’re not drawing the line and adding the canvas until after mainloop returns, which happens when you close the window.

Minimal example:

from tkinter import *

root = Tk()
root.geometry("500x500")
canvas = Canvas(root)  
canvas.pack()
canvas.create_line(15, 25, 200, 25, width=15)
#root.mainloop()

When run from an IDLE editor, omit the mainloop call and one can interactively enter more tkinter statements in Shell at the >>> prompt. A great way to explore the effect of different functions.

That’s what the problem was. the root.mainloop() was in the wrong place.
Thank you for the help.

Now, how do I draw functions like: y = sin(x)?

Plot points with create_text or multipoint line with create_line(x1, y1, …, xn, yn).