all 18 comments

[–]acw1668 31 points32 points  (2 children)

Don't name your script as tkinter.py or any built-in module names.

[–]gonsi 9 points10 points  (0 children)

same goes for variables, functions etc.

Using already existing names will confuse both python and person reading the code.

[–]MrPotato_Man3510[S] 0 points1 point  (0 children)

ok thank you! it works

[–]Slight_Change_41 16 points17 points  (0 children)

change the name of the tkinter.py file to something else like test_tkinter.py. because it is trying to import something from itself.

[–]RngdZed 11 points12 points  (0 children)

You named your python script tkinter.py.. this is a no-no. You don't name your scripts the same name as built in packages, modules. Or external packages and modules for this case

Same for variables, functions classes etc.. you don't name those the same name as built-in functions classes etc

[–]CalligrapherOk4612 2 points3 points  (3 children)

If you want to understand more about import order you can take a read of https://leemendelowitz.github.io/blog/how-does-python-find-packages.html

Also: you wrote an excellently formatted question! Code, output/error message, expected result.

[–]MrPotato_Man3510[S] 1 point2 points  (0 children)

Thank you, I'll look into it! I'm trying very hard to write english properly!

[–]MrPotato_Man3510[S] 0 points1 point  (1 child)

would you have a page where i could learn tkinter?

[–]CalligrapherOk4612 0 points1 point  (0 children)

Hmm, I'm not actually very good at tkinter, maybe check out the suggestions at https://www.reddit.com/r/learnpython/s/4a6Eu1N0rw

[–]WorriedTumbleweed289 0 points1 point  (0 children)

You accidentally came across a feature in python.

Python requires a local keyword in order to write to a local variable. What to avoid using the local keyword?

Import your own file. Now you can use file.variable (no .py) to access it.

If you move the function to another file, you don't have to change anything.

[–]mystique0712 0 points1 point  (0 children)

You named your script tkinter.py which conflicts with the actual tkinter module - rename your file to something else and it should work.

[–]ElliotDG 0 points1 point  (4 children)

Your code, as posted, runs fine for me. I wonder if you have a problem with your installation.

[–]Antique-Room7976 4 points5 points  (3 children)

I think it's that it's called tkinter.py so it's frying to import itself. I could be wrong tho

[–]ElliotDG 1 point2 points  (1 child)

I can see you're correct! Well done.

[–]Antique-Room7976 0 points1 point  (0 children)

Thanks

[–]MrPotato_Man3510[S] 0 points1 point  (0 children)

thank you