def __init__(self, app, **kwargs): kwargs["id"] = "choose_name" super(ChooseName, self).__init__(app, **kwargs) self.text = "Type your name:" name = Input(id="name_input", type="text", value=self.app.player.name, onkeydown="sock.send('key_down ' + evt.keyCode + ' ' + name_input.value)") self.app.js._events["key_down"] = self.key_down self.put(name) enter = Button(id="enter", onclick="sock.send('enter ' + name_input.value)") self.app.js._events["enter"] = self.enter enter.text = "enter" self.put(enter) back = Button(id="back", onclick="sock.send('back')") self.app.js._events["back"] = self.back back.text = "back" self.put(back)
def __init__(self, app, **kwargs): kwargs["id"] = "credits" super(Credits, self).__init__(app, **kwargs) self.text = "<p>%s<p>" % CREDITS.replace("\n", "<br>") back = Button(id="back", onclick="sock.send('back')") self.app.js._events["back"] = self.back back.text = "back" self.put(back)
def __init__(self, app, buttons, **kwargs): super(Menu, self).__init__(app, **kwargs) self.buttons = buttons for button_name, action in buttons: button_id = button_name.lower().replace(" ", "_") button = Button(id=button_id, onclick="sock.send('%s')" % action.__name__) self.app.js._events[action.__name__] = action button.text = button_name self.put(button)
def __init__(self, app, **kwargs): kwargs["id"] = "normal_game_lobby" super(NormalGameLobby, self).__init__(app, **kwargs) NormalGameLobby.players.append(self.app.player) message_box = Div(id="message_box") self.put(message_box) player_list = Div(id="player_list") self.put(player_list) message = Input(id="message_input", type="text", onkeydown="sock.send('key_down ' + evt.keyCode + ' ' + message_input.value)") self.app.js._events["key_down"] = self.key_down self.put(message) back = Button(id="back", onclick="sock.send('back')") self.app.js._events["back"] = self.back back.text = "back" self.put(back)