[Solved] Seems like python is partial


1> Why can’t i remove from tkinter
import* from the last_function file..
cause anyway it’s got that on the top
of the file that’s calling it
right.Why do i get an error saying
IntVar() not defined

The Python “import” follows the same scoping rules as the rest of the Python language. By “import” at the top of your second files does not make the Tkinter namespace available to the last_function.py module. Tkinter also needs to be imported there.

2>why do i have to pass mixer as a
parameter in the function? can the
function not inherit it directly from
import pygame.mixerthat’s on top of
the file calling it? WHAT I MEAN TO
SAY IS. THERE ARE TKINTER COMPONENTS
ALSO BEING USED,BUT I DON’T PASS
TKINTER AS A PARAMETER.. DO I!! then
why is there this.. selective
parameter assignment??

With the way you have this coded, you need to pass mixer because you are modifying it in your second file with:

mixer.init()

If you reimported mixer in your last_function.py, you would be getting another instance of mixer and not the one previously imported. There is nothing selective about this since both of your files have the Tkinter namespace imported.

You should try and re-factor this code to avoid having to import Tkinter into two modules and having to init mixer in one module and pass it to another.

1

solved Seems like python is partial