我有main.py文件和uiwidgets.py中的一些UI類的主應用程序。當事件發生時,Python返回類的值
在main.py我:
import uiwidgets as uiw
uiw.MultiColumnListbox(header, data)
def doSomething(self, n)
do something with n
在uiwidgets.py我:
class MultiColumnListbox(object):
def __init__(self, header, data):
self.header=header
self.data=data
...
self.tree.bind("<Double-Button-1>", self.OnClick)
def OnClick(self, event):
global return_index
item = self.tree.identify('item',event.x,event.y)
if item is not "":
return_index = (int((item[1:4]),16) - 1)
n = self.data[return_index][0]
我需要從類返回n值在main.py當用戶點擊小部件。我能怎麼做?
從主要進口DoSomething的; doSomething(n) – wong2
以這種方式我有一個循環依賴導入與錯誤「ImportError:無法導入名稱'doSomething'」 – gaiapac