python中主函数调用_python中主函数调用失败

你的代码中的FormDisplay不是一个类而是一个函数,类似这样的方法更合适。顺便说一句,我建议你仔细阅读一下这篇文章http://docs.python.org/2/tutorial/classes.htmlimport urwid.raw_display

class FormDisplay(object):

def __init__(self):

self.ui = urwid.raw_display.Screen()

self.palette = ui.register_palette([

('Field', 'dark green, bold', 'black'), # information fields, Search: etc.

('Info', 'dark green', 'black'), # information in fields

('Bg', 'black', 'black'), # screen background

('InfoFooterText', 'white', 'dark blue'), # footer text

('InfoFooterHotkey', 'dark cyan, bold', 'dark blue'), # hotkeys in footer text

('InfoFooter', 'black', 'dark blue'), # footer background

('InfoHeaderText', 'white, bold', 'dark blue'), # header text

('InfoHeader', 'black', 'dark blue'), # header background

('BigText', RandomColor(), 'black'), # main menu banner text

('GeneralInfo', 'brown', 'black'), # main menu text

('LastModifiedField', 'dark cyan, bold', 'black'), # Last modified:

('LastModifiedDate', 'dark cyan', 'black'), # info in Last modified:

('PopupMessageText', 'black', 'dark cyan'), # popup message text

('PopupMessageBg', 'black', 'dark cyan'), # popup message background

('SearchBoxHeaderText', 'light gray, bold', 'dark cyan'), # field names in the search box

('SearchBoxHeaderBg', 'black', 'dark cyan'), # field name background in the search box

('OnFocusBg', 'white', 'dark magenta') # background when a widget is focused

])

def main(self):

#self.view = ui.run_wrapper(formLayout)

self.view = formLayout()

self.ui.start()

self.loop = urwid.MainLoop(self.view, self.palette, unhandled_input=self.unhandled_input)

self.loop.run()

if __name__ = "__main__":

form = FormDisplay()

form.main()

你可能感兴趣的:(python中主函数调用)