在我的比赛,我有两个模块,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