def __init__(self, name, title, equipped, icon, client, hit, dam, arm, desc=""): self.client = client self.name = name self.title = title icon = Graphic(path=['icons', icon]) title = Label(self.title) stats = HorizontalContainer([ Label(str(dam), color=[255, 100, 100, 255]), Label(str(hit), color=[100, 100, 255, 255]), Label(str(arm), color=[100, 255, 100, 255]), ]) button_text = 'Equip ' if equipped: button_text = 'Remove' equip_button = Button(label=button_text, is_pressed=equipped, on_press=self.equip) use_button = OneTimeButton(label='Use', on_release=self.use) drop_button = OneTimeButton(label='Drop', on_release=self.confirm_drop) HorizontalContainer.__init__( self, [icon, title, stats, equip_button, use_button, drop_button], align=HALIGN_LEFT)
def __init__(self, options, labels=None, max_height=400, align=VALIGN_TOP, on_select=None): Selector.__init__(self, options, labels, on_select=on_select, selected=options[0]) OneTimeButton.__init__(self) self.max_height = max_height self.align = align self._pulldown_menu = None
def __init__(self, client, inventory): self.client = client invitems = [] for name, value in inventory.items(): title = value['title'] equipped = value['equipped'] icon = value['icon'] hit = value['hit'] dam = value['dam'] arm = value['arm'] invitems.append( Frame(InventoryItem(name, title, equipped, icon, self.client, hit, dam, arm), is_expandable=True)) self.close_button = OneTimeButton(label='Close', on_release=self.close) self.inventory_list = Scrollable(height=256, width=512, is_fixed_size=True, content=VerticalContainer( invitems, align=HALIGN_LEFT)) self.inventory_container = VerticalContainer( [self.inventory_list, self.close_button]) Manager.__init__(self, Frame(self.inventory_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True, anchor=ANCHOR_BOTTOM_RIGHT)
def __init__(self, client, inventory=[]): self.client = client invitems = [] for name, value in inventory.items(): title = value['title'] icon = value['icon'] dam = value['dam'] hit = value['hit'] arm = value['arm'] gold = value['value'] invitems.append( Frame(ContainerItem(name, title, icon, self.client, dam, hit, arm, gold), is_expandable=True)) self.container_inventory_list = Scrollable(height=256, width=512, is_fixed_size=True, content=VerticalContainer( invitems, align=HALIGN_LEFT)) self.exit_button = OneTimeButton(label='Close', on_release=self.close) self.inventory_container = HorizontalContainer( [self.container_inventory_list, self.exit_button]) Manager.__init__(self, Frame(self.inventory_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self, name, title, icon, client, dam, hit, arm, gold, desc=""): self.client = client self.name = name self.title = title icon = Graphic(path=['icons', icon]) title = Label(self.title) gold = Label("%sg" % gold, color=[230, 244, 68, 255]) stats = HorizontalContainer([ Label(str(dam), color=[255, 100, 100, 255]), Label(str(hit), color=[100, 100, 255, 255]), Label(str(arm), color=[100, 255, 100, 255]), ]) take_button = OneTimeButton(label='Take', on_release=self.take) HorizontalContainer.__init__(self, [icon, title, gold, stats, take_button], align=HALIGN_LEFT)
def manager(self): Manager(Label(""), window=self, batch=self.batch, theme=getTheme()) Manager(Frame(self.document), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_TOP_RIGHT, offset=(-10, -75), is_movable=False) Manager(HorizontalContainer([ OneTimeButton(label="Guardar", on_release=self.saveGame), OneTimeButton(label="Volver", on_release=self.onclose) ]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_BOTTOM_RIGHT, offset=(-50, 15), is_movable=False) self.document.set_text("")
def __init__(self, client): self.client = client self.login_button = OneTimeButton(label="Login", on_release=self.login) self.username_field = TextInput("") self.password_field = TextInput("") self.login_container = VerticalContainer( [self.login_button, self.username_field, self.password_field]) Manager.__init__(self, Frame(self.login_container), window=self.client.window, theme=UI_THEME)
def __init__(self, client, name, title, dialog): self.client = client self.name = name title = Label(title, font_size=12) dialog = pyglet.text.decode_text(dialog) document = Document(dialog, width=300, height=100) accept_button = OneTimeButton(label="Ok, I'll do it!", on_release=self.accept) reject_button = OneTimeButton(label="No, Thanks.", on_release=self.reject) text_container = VerticalContainer([title, document]) button_container = HorizontalContainer([accept_button, reject_button]) quest_container = VerticalContainer([text_container, button_container]) Manager.__init__(self, Frame(quest_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def __init__(self, client): self.client = client self.connect_button = OneTimeButton(label="Connect", on_release=self.connect) self.server_field = TextInput("localhost") self.port_field = TextInput("10000") self.connect_container = VerticalContainer( [self.connect_button, self.server_field, self.port_field]) Manager.__init__(self, Frame(self.connect_container, path='connectFrame'), window=self.client.window, theme=UI_THEME)
def manager(self): self.managerList += [ Manager(HorizontalContainer( [OneTimeButton(label="Continuar", on_release=self.nextWindow)]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_BOTTOM_RIGHT, offset=(-80, 5), is_movable=False) ] self.managerList += [ Manager(VerticalContainer([ Checkbox(label="El CPU Inicia ", on_press=self.setCPUStarts, is_pressed=self.CPUStarts), Checkbox(label="El CPU es blancas", on_press=self.setCPUPlayWhite, is_pressed=self.CPUPlayWhite), Label(""), Label("Enroque de negras"), Checkbox(label="Lado de la Reina ", on_press=self.setBlackQueenCastling, is_pressed=self.blackQueenCastling), Checkbox(label="Lado del Rey ", on_press=self.setBlackKingCastling, is_pressed=self.blackKingCastling), Label(""), Label("Enroque de blancas"), Checkbox(label="Lado de la Reina ", on_press=self.setWhiteQueenCastling, is_pressed=self.whiteQueenCastling), Checkbox(label="Lado del Rey ", on_press=self.setWhiteKingCastling, is_pressed=self.whiteKingCastling) ]), window=self, batch=self.batch, theme=getTheme(), anchor=ANCHOR_RIGHT, offset=(-50, -95), is_movable=False) ]
def __init__(self, client): self.client = client self.message_container = VerticalContainer(content=[], align=HALIGN_LEFT) self.messages = Scrollable(height=100, width=300, is_fixed_size=True, content=self.message_container) self.text_input = TextInput("", length=20, max_length=256) self.send_button = OneTimeButton("Send", on_release=self.submit_message) self.enter_field = HorizontalContainer( [self.text_input, self.send_button]) self.chat_window = VerticalContainer([self.messages, self.enter_field]) Manager.__init__(self, Frame(self.chat_window, path='chatFrame'), window=self.client.window, theme=UI_THEME, is_movable=True, anchor=ANCHOR_BOTTOM_LEFT)
def __init__(self, client, quests): self.client = client quest_list = [] for quest in quests: quest_title = Label(quest['title']) quest_container = HorizontalContainer([quest_title]) quest_list.append(quest_container) close_button = OneTimeButton(label="Close", on_release=self.close) quest_container = VerticalContainer(quest_list) button_container = HorizontalContainer([close_button]) questlog_container = VerticalContainer( [quest_container, button_container]) Manager.__init__(self, Frame(questlog_container, is_expandable=True), window=self.client.window, theme=UI_THEME, is_movable=True)
def delete(self): self._delete_pulldown_menu() OneTimeButton.delete(self)
theme = Theme(json.load(j), resources_path='theme/') # Set up a Manager manager = Manager( VerticalContainer( [ # ... Label(binding=Binding(context=model, path="title")), # ... VerticalContainer([ # ... Label(binding=Binding( template="$message", context=model, path="message")), # ... Button("Button 1", on_press=model.set_title(".")), OneTimeButton("Button 2", on_release=model.click), Button("Button 3"), LabelFactory(model, "message") ]) ], align=pyglet_gui_constants.HALIGN_RIGHT, padding=5), window=win, batch=batch, theme=theme) def draw(key: str, value: object): batch.draw() # print("manager: draw")
def load_graphics(self): if self._selected: self.label = self._options[self._selected].label else: self.label = '' OneTimeButton.load_graphics(self)
def __init__(self, *, window, **kwargs): self.vertex_list = None batch = pyglet.graphics.Batch() controller.window = window controller.manager = self with open('theme/theme.json') as f: theme = Theme(load(f), resources_path='./theme') super().__init__(VerticalContainer([ Frame( Wrapper( VerticalContainer([ SectionHeader("Map Tablet to MIDI outputs"), HorizontalContainer([ Label("Controller tablet"), binding_devices.bind( Dropdown(controller.tablet_names), 'tablet'), ]), HorizontalContainer([ Label("Map pointer"), bind_tablet_key.bind( Dropdown(controller.tablet_cursor_names), 'cursor'), Label("with"), Label("active button"), bind_tablet_key.bind( Dropdown(controller.tablet_button_names), 'button'), Label("as:") ]), GridContainer([ [ bind_tablet_x.bind(Button("X"), 'enabled'), Label("to channel"), bind_tablet_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_x.widget( HorizontalContainer([ Label("for"), bind_tablet_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_x.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_x.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_tablet_y.bind(Button("Y"), 'enabled'), Label("to channel"), bind_tablet_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_y.widget( HorizontalContainer([ Label("for"), bind_tablet_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_y.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_y.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_tablet_p.bind(Button("Pressure"), 'enabled'), Label("to channel"), bind_tablet_p.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_tablet_p.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_tablet_p.widget( HorizontalContainer([ Label("for"), bind_tablet_p.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_tablet_p.bind(TextInput(), 'range_from'), Label("to"), bind_tablet_p.bind(TextInput(), 'range_to'), Label("threshold"), bind_tablet_p.bind( HorizontalSlider(min_value=0.0, max_value=1.0, steps=20), 'threshold'), ], ]), ]))), Frame( Wrapper( VerticalContainer([ SectionHeader("Map Mouse to MIDI outputs"), HorizontalContainer([ Label("Map mouse with active button"), bind_mouse_key.bind( Dropdown(controller.mouse_button_names), 'button'), Label("as:"), ]), GridContainer([ [ bind_mouse_x.bind(Button("X"), 'enabled'), Label("to channel"), bind_mouse_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_x.widget( HorizontalContainer([ Label("for"), bind_mouse_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_x.bind(TextInput(), 'range_from'), Label("to"), bind_mouse_x.bind(TextInput(), 'range_to'), Label("threshold"), bind_mouse_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], [ bind_mouse_y.bind(Button("Y"), 'enabled'), Label("to channel"), bind_mouse_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_y.widget( HorizontalContainer([ Label("for"), bind_mouse_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_y.bind(TextInput(), 'range_from'), Label("to"), bind_mouse_y.bind(TextInput(), 'range_to'), Label("threshold"), bind_mouse_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'threshold'), ], ]), HorizontalContainer([ Label("Map mouse wheel as:"), ]), GridContainer([ [ bind_mouse_wheel_x.bind( Button("X"), 'enabled'), Label("to channel"), bind_mouse_wheel_x.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_wheel_x.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_wheel_x.widget( HorizontalContainer([ Label("for"), bind_mouse_wheel_x.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_wheel_x.bind( TextInput(), 'range_from'), Label("to"), bind_mouse_wheel_x.bind( TextInput(), 'range_to'), Label("step"), bind_mouse_wheel_x.bind(TextInput(), 'step'), Label("value"), bind_mouse_wheel_x.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'value'), bind_mouse_wheel_x.bind( Checkbox('pull back'), 'pull_back'), ], [ bind_mouse_wheel_y.bind( Button("Y"), 'enabled'), Label("to channel"), bind_mouse_wheel_y.bind( Dropdown(controller.midi_channels), 'channel'), Label("as"), HorizontalContainer([ bind_mouse_wheel_y.bind( Dropdown( controller.midi_message_types), 'message_type'), bind_mouse_wheel_y.widget( HorizontalContainer([ Label("for"), bind_mouse_wheel_y.bind( Dropdown(controller. midi_control_types), 'control_type'), ], hidden=True), 'control_group'), ]), Label("ranging from"), bind_mouse_wheel_y.bind( TextInput(), 'range_from'), Label("to"), bind_mouse_wheel_y.bind( TextInput(), 'range_to'), Label("step"), bind_mouse_wheel_y.bind(TextInput(), 'step'), Label("value"), bind_mouse_wheel_y.bind( HorizontalSlider(min_value=0.0, max_value=100.0, steps=20), 'value'), bind_mouse_wheel_y.bind( Checkbox('pull back'), 'pull_back'), ], ]), ]))), HorizontalContainer([ binding_buttons.bind(Button(label="Tablet Input On"), 'tablet_on'), binding_buttons.bind(Button(label="Mouse Input On"), 'mouse_on'), Button(label="Fullscreen", on_press=controller.toggle_fullscreen), OneTimeButton('All Notes Off', on_release=controller.midi_all_notes_off), OneTimeButton('Hide', on_release=controller.toggle_gui) ]), Frame( Wrapper( VerticalContainer([ SectionHeader("Output Device"), GridContainer([ [ Label("Output MIDI port"), binding_devices.bind( Dropdown(controller.midi_ports), 'output_midi_port_name'), ], ]), HorizontalContainer([ binding_buttons.bind( Button(label="MIDI Output On"), 'midi_output_on'), binding_buttons.bind(Button(label="Log Output"), 'log_output_on'), binding_buttons.bind(Button(label="Log Input"), 'log_input_on'), ]), ]))), Frame( Wrapper( VerticalContainer([ SectionHeader("Status"), Label("Input:", bold=True), binding_labels.bind(Label("---"), 'touch_status'), binding_labels.bind(Label("---"), 'mouse_status'), Label("Output:", bold=True), binding_labels.bind(Label("---"), 'output_status'), ]))), ]), theme=theme, window=window, batch=batch, **kwargs) controller.start_listen_bindings() controller.update_widgets() @window.event def on_resize(width, height): controller.clear_scale_cache() controller.note_labels.clear() controller.calculate_grid() # if __debug__: # fps_display = pyglet.clock.ClockDisplay() @window.event def on_draw(): window.clear() if self.vertex_list: self.vertex_list.draw(pyglet.gl.GL_QUADS) if controller.gui_visible: batch.draw() for label in controller.note_labels: label.draw() # if __debug__: # fps_display.draw() @window.event def on_text(text): controller.on_keyboard_input(text)
def setUp(self): TestPygletGUI.setUp(self) self.button = OneTimeButton(label="test") GenericButtonTest.setUp(self)
def load_graphics(self): self.label = self._options[self._selected].label OneTimeButton.load_graphics(self)
"unchecked": { "image": { "source": "checkbox.png" } } } }, resources_path='../theme/') def f(y): print("\nholaMundo\n" + str(y)) # Set up a Manager Manager(VerticalContainer([ Button(label="Persistent button", on_press=f), OneTimeButton(label="One time button"), Checkbox(label="Checkbox"), GroupButton(group_id='1', label="Group 1:Button 1"), GroupButton(group_id='1', label="Group 1:Button 2"), GroupButton(group_id='2', label="Group 2:Button 1"), GroupButton(group_id='2', label="Group 2:Button 2"), GroupButton(group_id='2', label="Group 2:Button 3"), ]), window=window, batch=batch, theme=theme) pyglet.app.run()
def unload_graphics(self): OneTimeButton.unload_graphics(self) self._delete_pulldown_menu()
def __init__(self, client, stats): self.client = client # Stats Container title = Label("%s" % (stats['title']), font_size=12) level = Label("%s" % (stats['level']), font_size=12) title_container = HorizontalContainer([title, level], align=HALIGN_LEFT) # HorizontalContainer hp_icon = Graphic(path=['icons', 'heart']) hp = Label("%s/%s" % (stats['hp'][0], stats['hp'][1]), font_size=10) hp_container = HorizontalContainer([hp_icon, hp], align=HALIGN_LEFT) # HorizontalContainer mp_icon = Graphic(path=['icons', 'potionBlue']) mp = Label("%s/%s" % (stats['mp'][0], stats['mp'][1]), font_size=10) mp_container = HorizontalContainer([mp_icon, mp], align=HALIGN_LEFT) # HorizontalContainer gold_icon = Graphic(path=['icons', 'coin']) gold = Label("%s" % stats['gold'], color=[255, 255, 255, 255], font_size=12) gold_container = HorizontalContainer([gold_icon, gold], align=HALIGN_LEFT) # HorizontalContainer dam_icon = Graphic(path=['icons', 'dagger']) dam = Label("%s" % stats['dam'], color=[255, 100, 100, 255], font_size=10) dam_container = HorizontalContainer([dam_icon, dam], align=HALIGN_LEFT) hit_icon = Graphic(path=['icons', 'x']) hit = Label("%s" % stats['hit'], color=[100, 100, 255, 255], font_size=12) hit_container = HorizontalContainer([hit_icon, hit], align=HALIGN_LEFT) arm_icon = Graphic(path=['icons', 'shieldSmall']) arm = Label("%s" % stats['arm'], color=[100, 255, 100, 255], font_size=12) arm_container = HorizontalContainer([arm_icon, arm], align=HALIGN_LEFT) inv_button = OneTimeButton(label='Inventory', on_release=self.inventory) quest_button = OneTimeButton(label='Quest Log', on_release=self.questlog) logout_button = OneTimeButton(label='Logout', on_release=self.logout) #self.character_window = VerticalContainer([title, hp_icon, hp, mp_icon, mp, gold_icon, gold, dam, hit, arm, inv_button, quest_button, logout_button]) self.character_window = VerticalContainer([ title_container, hp_container, mp_container, gold_container, dam_container, hit_container, arm_container, inv_button, quest_button, logout_button ], align=HALIGN_LEFT) Manager.__init__(self, Frame(self.character_window), window=self.client.window, theme=UI_THEME, is_movable=False, anchor=ANCHOR_TOP_RIGHT)
def __init__(self, element, count, on_click=None): self.element = element self.count = count self.update_label() OneTimeButton.__init__(self, self.label) self._on_click = on_click