我有一节课,没什么特别的,只是一节普通课:
class WINDOW ():
def __init__ (self, path):
...some unrelated codd...
self.win = newwin(stdscr.win.getmaxyx() [0]-2, stdscr.win.getmaxyx() [1], 0, 0)
self.xmax = self.win.getmaxyx() [1]
self.ymax = self.win.getmaxyx() [0]
def draw(self,flin,fcol):
...code here
i = 0
while i < self.ymax -1:
...more code here...
当我尝试访问“自身.ymax“在while循环中,我得到一个错误,说classs窗口没有atribute ymax。 我做错什么了???你知道吗
编辑: getmaxyx()返回两个值的元组。 这是一个诅咒程序。我用的是python3。你知道吗
编辑2: 更多代码-创建窗口实例:
def main():
global stdscr
stdscr = initscr()
global interface
interface = INTERFACE(stdscr)
interface.wins.append(WINDOW(parseArgv()))
dispatcher()
Parseargv():
def parseArgv():
#arguments are [filename, PathToFileThatThisProgramOpens]
if len(argv) == 1:
return None
else:
return argv[-1]
调用draw():
def SwitchWindow(self):
self.wins[self.currentWindow].empty()
self.currentWindow += 1 #select next window
line = self.wins[self.currentWindow].flin
coll = self.wins[self.currentWindow].fcol
self.wins[self.currentWindow].draw(line,coll)
如果没有完整的代码和回溯,这是不可能的,但我有一些问题的猜测:
...some unrelated codd...
替换的位实际上包含多个代码路径,我们看到的代码只在某些时候执行,因此self.ymax
并不总是初始化的。你知道吗...code here
或...more code here...
在draw()
方法中重新绑定名称self
。你知道吗ymax
在其中一个地方的拼写错误。你知道吗相关问题 更多 >
编程相关推荐