0

I'm trying to draw a canvas in my program using python3, here's my code:

lato=int(input("inserisci la misura in pixel del lato di ogni rettangolino della scacchiera : "))
pannello=tkinter.Canvas(width=200,heigh=200)
pannello.pack()
pannello.mainloop()

the problem is that I'm not able to show the canvas unless I comment the first line of my code, any idea of what the problem is?

Francesco
  • 51
  • 2
  • 8
  • do you get any error when you run it ? `input()` always stops code so other commands have to wait till you press `ENTER`. And if you put text instead of number when `input()` runs then it may gives error because there is `int()`. – furas Nov 13 '19 at 11:56
  • I don't get any error when I run it.. – Francesco Nov 13 '19 at 12:22
  • I don't have problem to run it on Linux - if I only add `import tkitner`. But I would rather create main window using `root = tkinter.Tk()` and then put `Canvas` in window `canvas = tkitner.Canvas(root, ...)` , `canvas.pack()` and run it `root.mainloop()`. – furas Nov 13 '19 at 12:28
  • do you run it from file - `python script.py` - or in some Python shell or in `IDLE` ? `IDLE` uses `tkinter` to display own windows and sometimes it makes problem to run own script which uses `tkinter`. – furas Nov 13 '19 at 12:29
  • @Francesco First you have to understand [Event-driven programming](https://stackoverflow.com/a/9343402/7414759) – stovfl Nov 13 '19 at 12:37

0 Answers0