Main Function Call Fails In Python
I wrote the following code that creates a layout and displays some text in the layout. Next the layout is displayed on the console screen using raw display module from urwid librar
Solution 1:
FormDisplay in your code is not a class but a function, something like this would be more appropriate. Btw, I'd recommend reading up on some of this doc http://docs.python.org/2/tutorial/classes.html
import urwid.raw_display
classFormDisplay(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
])
defmain(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()
Solution 2:
I don't see any separate class. But according to your code, FormDisplay
is a function that return nothing. FormDisplay().main()
equals None.main()
.
Post a Comment for "Main Function Call Fails In Python"