def OnClick1(self,event):
song='maid.mp3'
aplayer(song, play1 , 1, 0)
play1 is a global variable that is modified in another module. But the value of play1 is still the initial one which is 0. How to format the variable play1?
def OnClick1(self,event):
song='maid.mp3'
aplayer(song, play1 , 1, 0)
play1 is a global variable that is modified in another module. But the value of play1 is still the initial one which is 0. How to format the variable play1?
I might be misunderstanding you question, but in Python global variables can be read, but not set, by default. If you want to modify the global variable you need to first declare it as global, then you can set it:
play1 = 1
def some_function():
global play1
play1 = #your value here, which will change the global value
If the problem is just that the other module isn't accessing the global variable (which it won't) you can try attaching the variable to the __builtin__ module, so you can access or modify it from any module by just doing:
import __builtin__
__builtin__.play1 = #new value
That's it - it should now be a cross-module global variable.
play1? Could you provide a more complete version of your code?play1 You should do it with returned value: play1 = aplayer(song,1,0)