def __init__(self, a_config, a_client, a_screen): """ Constructor. a_config is the ConfigParser. a_screen is the Screen. """ ControllerBase.__init__(self) self.__config = a_config self.__client = a_client self.__screen = a_screen
def __init__(self): """ Constructor. """ self.__game_widget = urwid.Text('select a game on the right to begin', align = 'center') new_game_widget = NewGameListItemWidget() self.__stat_widget = urwid.ListBox([ new_game_widget ]) self.__settings_widget = SettingsWidget() btn_cancel = urwid.Button('No') urwid.connect_signal(btn_cancel, 'click', lambda a_btn, a_self: a_self.showSettings() and True, self) btn_accept = urwid.Button('Yes') urwid.connect_signal(btn_accept, 'click', lambda a_btn, a_self: a_self.__newAccount() and True, self) self.__new_acct_widget = urwid.Pile(( ( 'pack', urwid.Text('') ), urwid.Filler(urwid.Text('Unrecognized login. Create new account?', align = 'center'), valign = 'middle'), ( 'pack', urwid.Text('') ), ( 'pack', urwid.Columns(( ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_cancel ), ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_accept ), ( 'weight', 1, urwid.Text('') ), ), dividechars = 1) ), ( 'pack', urwid.Text('') ), )) btn_thanks = urwid.Button("Thanks (for nuthin')") urwid.connect_signal(btn_thanks, 'click', lambda a_btn, a_self: a_self.showMain() and True, self) self.__help_widget = urwid.Pile(( ( 'pack', urwid.Text('') ), urwid.Filler(urwid.Text(Screen.__INSTRUCTIONS), valign = 'middle'), ( 'pack', urwid.Text('') ), ( 'pack', urwid.Columns(( ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_thanks ), ( 'weight', 1, urwid.Text('') ), ), dividechars = 1) ), ( 'pack', urwid.Text('') ), )) game = urwid.Filler(self.__game_widget, valign = 'middle') stat = self.__stat_widget self.__top = urwid.Columns(( ( 'weight', 70, game ), ( 'weight', 30, stat ), )) self.__msg = urwid.Text('not logged in', align = 'center') header = urwid.Pile(( ( 'pack', urwid.Text(( urwid.AttrSpec('underline', 'default'), 'BAlanced HAngMAN' ), align = 'center') ), ( 'pack', urwid.Text('<\u2190 \u2192 \u2191 \u2193> or mouse to navigate, <enter> or click to activate', align = 'center') ), ( 'pack', self.__msg ), ( 'pack', urwid.Divider(u'\u2500') ), )) btn_help = urwid.Button('Help') urwid.connect_signal(btn_help, 'click', lambda a_btn, a_self: self.__showHelp() and True, self) btn_settings = urwid.Button('Settings') urwid.connect_signal(btn_settings, 'click', lambda a_btn, a_self: a_self.showSettings() and True, self) btn_quit = urwid.Button('Quit') urwid.connect_signal(btn_quit, 'click', lambda a_btn: quit() and True) footer = urwid.Pile(( ( 'pack', urwid.Divider(u'\u2500') ), ( 'pack', urwid.Columns(( ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_help ), ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_settings ), ( 'weight', 1, urwid.Text('') ), ( 'weight', 1, btn_quit ), ( 'weight', 1, urwid.Text('') ), ), dividechars = 1) ), ( 'pack', urwid.Text('Copyright (c) 2014, Matt Bogosian.', align = 'center') ), )) base_widget = urwid.Frame(self.__top, header, footer) urwid.WidgetWrap.__init__(self, base_widget) ControllerBase.__init__(self) self.__cheat = False self.connectObject(self.__settings_widget, SettingsWidget.SIG_SETTINGS_ACCEPTED) self.connectObject(self.__settings_widget, SettingsWidget.SIG_SETTINGS_CANCELED) self.connectObject(self.__settings_widget, SettingsWidget.SIG_SETTINGS_MODIFIED) self.connectObject(new_game_widget, NewGameListItemWidget.SIG_NEW_GAME) # More fun: <http://bit.ly/K9ve3C> self.__showPalm('<http://bit.ly/1ebG9oU>')