在我的比賽,我有兩個模塊,island.py其加載到島嶼我的比賽和第二模塊是gui.py哪場比賽開始前處理GUI部件。我的問題是如何將進度值從island.py模塊發送到在gui.py模塊中創建的進度條編輯:也用加載屏幕的實例訪問其中的進度欄並更改其值。發送進度值進度條蟒蛇
在模塊island.py
def __iter__(self):
total = float(len(self.ground_map))
import game.gui
for i in self.get_coordinates():
yield i
global count
count+=1
progress = (count/total) * 100
game.gui.Gui.set_progress(progress)
global count
count = 0
在模塊gui.py
def show_loading_screen(self):
self._switch_current_widget('loadingscreen', center=True, show=True) # Creates the loading screen and its associated widgets, except the progress bar.
@staticmethod
def set_progress(progress):
# Now I have the progress values, and it will be updated automatically... how can I pass it to the progress bar widget?
# I need to create the progress bar widget here, but to do that I need to have the self instance to give me the current screen that I will create the progress bar for **AND HERE IS THE PROBLEM!!**
def update_loading_screen(progress):
"""updates the widget."""
**self,current**.findChild(name="progressBar")._set_progress(progress)
update_loading_screen(progress)
我怎樣才能讓這個update_loading_screen功能?
你真的應該保留所有的import語句的頂部,除非你'動態導入模塊。 – 2011-04-18 13:04:49