def setup(gui, group): # Create a VBox container, which will arrange any widgets we give it into a # vertical column. Center-align it, otherwise the column will take up the # full height of the window and put too much space between our widgets. vbox = glooey.VBox() vbox.alignment = 'center' # Create a widget to pose a question to the user using the "title" text # style, then add it to the top of the vbox. title = MyTitle("What...is your favorite color?") vbox.add(title) # Create several buttons with different answers to the above question, then # add each one to the vbox in turn. buttons = [ MyButton("Blue.", "Right, off you go."), MyButton("Blue. No yel--", "Auuuuuuuugh!"), MyButton("I don't know that!", "Auuuuuuuugh!"), ] for button in buttons: vbox.add(button) # Finally, add the vbox to the GUI. It's always best to make this the last # step, because once a widget is attached to the GUI, updating it or any of # its children becomes much more expensive. gui.add(vbox)
def __init__(self, position): super().__init__() self.position = position self.add_back(Slot()) self.vbox = glooey.VBox() self.top = ScrollBox() self.bottom = glooey.HBox() self.bottom.set_padding(5) # Add widgets to Top grid = Grid() grid[0, 0] = Text("Widget Name:") grid[1, 0] = self.name_input = TextInput() self.top.add(grid) #Add widgets to Bottom self.bottom.add(self.CancelButton()) self.bottom.add(self.ConfirmButton()) self.vbox.add(self.top, 'expand') self.vbox.add(self.bottom, 30) self.add(self.vbox)
def __init__(self, interface): super().__init__() self.interface = interface self.vbox = glooey.VBox() self.vbox.add(LabelWhite("Hello world")) self.vbox.add(glooey.Placeholder()) self._attach_child(self.vbox)
def build(cls, ui): container = glooey.VBox(0) container.alignment = 'center' title = Text("Loading Map") container.add(title) return container
def displayGUI(): class StatusLabel(glooey.Label): custom_font_name = "Calibri" custom_font_size = 12 custom_color = "0080ff" class ArmButton(glooey.Button): if alarm.system_armed: class Base(glooey.Image): custom_image = pyglet.resource.image('Button2.png') elif not alarm.system_armed: class Base(glooey.Image): custom_image = pyglet.resource.image('Button3.png') class DoorStatusLabel(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" class TemperatureData(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" class Clock(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" sensor_status_Vbox = glooey.VBox() for key in DEVICES: sensor = DEVICES[DataReader.device_id] sensor_status_label = DoorStatusLabel( f"{sensor}:{DataReader.door_stat}") sensor_status_Vbox.add(sensor_status_label) right_panel = glooey.VBox() # Add to grid grid = glooey.HBox() grid.add(sensor_status_Vbox) # Left Panel grid.add(glooey.placeholder()) # Center Panel grid.add(right_panel) # Right Panel gui.add(grid)
def drawGameModeGrid(): grid = ChoiceGrid() box = glooey.VBox( ) #The grid had to be put in a box, because the grid wouldn't stop aligning itself to the left of the screen box.alignment = 'fill bottom' box.add(grid) grid.add(1, 0, EndOfRoundButton("Local 1v1", '1v1')) grid.add(1, 1, EndOfRoundButton("Endurance", 'endurance')) gui.add(box)
def drawPlayAgainGrid(): grid = ChoiceGrid() box = glooey.VBox( ) #The grid had to be put in a box, because the grid wouldn't stop aligning itself to the left of the screen box.alignment = 'fill bottom' box.add(grid) grid.add(1, 0, EndOfRoundButton("Play Again", 'Play Again')) grid.add(1, 1, EndOfRoundButton("Change Game Mode", 'Change Game Mode')) gui.add(box)
def drawADGrid(rows, columns): grid = ChoiceGrid() box = glooey.VBox( ) #The grid had to be put in a box, because the grid wouldn't stop aligning itself to the left of the screen box.alignment = 'fill bottom' box.add(grid) grid.add(1, 0, WeaponButton("Offensively", 'offense')) grid.add(1, 1, WeaponButton("Defensively", 'defense')) gui.add(box)
def createGui(self, elapsed_time): vbox = glooey.VBox() vbox.alignment = 'center' if (elapsed_time == None): vbox.add(MyButton("START GAME")) else: vbox.add(MyLabel(f"You took: {round(elapsed_time,2)}s to finish!")) vbox.add(MyButton("PLAY AGAIN")) self.gui.add(vbox)
def __init__(self): super().__init__() self.username = InputBox() self.password = InputBox() self.password.push_handlers( on_unfocus=lambda w: print(f"password: ***************")) self.serverIP = InputBox() self.serverPort = InputBox() self.serverIP.push_handlers( on_unfocus=lambda w: print(f"serverIP: '{w.text}'")) self.serverPort.push_handlers( on_unfocus=lambda w: print(f"serverPort: '{w.text}'")) self.grid = glooey.Grid(0, 0, 0, 0) self.padding = 16 self.titleLabel = glooey.Label("Cataclysm: Looming Darkness") self.grid[0, 1] = self.titleLabel self.grid[1, 0] = glooey.Label("Username:"******"password:"******"Server IP:") self.grid[4, 1] = self.serverIP self.grid[5, 0] = glooey.Label("Server Port:") self.grid[5, 1] = self.serverPort with open("client.json") as f: client_data = json.load(f) self.username.text = client_data["username"] self.password.text = client_data["password"] self.serverList = client_data["serverList"] connectButton = ConnectButton("Connect") self.grid[6, 1] = connectButton serverListScrollBox = CustomScrollBox() serverListScrollBox.size_hint = 100, 100 vbox_for_serverlist = glooey.VBox(0) for server in self.serverList: _button = ServerListButton(server) # sets the active server to the one you press. _button.push_handlers(on_click=self.set_host_and_port_InputBoxes) vbox_for_serverlist.add(_button) serverListScrollBox.add(vbox_for_serverlist) self.grid[6, 0] = serverListScrollBox self.add(self.grid)
def __init__(self, interface): super().__init__() self.interface = interface self.vbox = glooey.VBox() self.input_display = GameTileDisplay(interface, "A") self.tile_display = GameTileDisplay(interface, "A") self.vbox.add(self.input_display) self.vbox.add(self.tile_display) self._attach_child(self.vbox) self.input_string = ""
def drawWeaponGrid(rows, columns, objs): x = 0 grid = ChoiceGrid() box = glooey.VBox( ) #The grid had to be put in a box, because the grid wouldn't stop aligning itself to the left of the screen box.alignment = 'fill bottom' box.add(grid) for i in range(rows): for j in range(columns): grid.add(i, j, WeaponButton(objects[objs[x]]['name'], objs[x])) x += 1 gui.add(box)
def build(cls, ui): container = glooey.VBox(0) container.alignment = 'center' title = Text("Creating Map") container.add(title) button = Button('Start Game') button.push_handlers(on_click=ui.lazy_emit('game:create')) container.add(button) return container
def __init__(self, interface): super().__init__() self.interface = interface self.vbox = glooey.VBox() self.game_board_hbox = GameBoardWidget(interface) self.game_input = GameInputWidget(interface) self.game_options = GameOptionsWidget(interface, self) self.vbox.add(self.game_board_hbox) self.vbox.add(self.game_input) self.vbox.add(self.game_options) self._attach_child(self.vbox)
def __init__(self, label, information): super().__init__() self.label = label self.information = information self.label_label = MenuLabel(label) self.info_label = MenuLabel(information) self.vbox = glooey.VBox() self.vbox.add(self.label_label) self.vbox.add(self.info_label) self._attach_child(self.vbox)
def __init__(self, interface): super().__init__() self.interface = interface title = TitleLabel("SWUG 0.1") untimed_btn = MenuButton("Untimed") retries_btn = MenuButton("Retries") timed_btn = MenuButton("Timed") timed_retries_btn = MenuButton("Timed + Retries") def update_timer(source): self.interface.time_remaining -= 1 if self.interface.time_remaining <= 0: self.interface.view_events.end() self.interface.on_end() def handle_untimed_btn(source): self.interface.view_events.create(GameMode.UNTIMED, 5) self.interface.state = DesktopStates.game def handle_retries_btn(source): self.interface.view_events.create(GameMode.RETRIES, 5) self.interface.state = DesktopStates.game def handle_timed_btn(source): self.interface.view_events.create(GameMode.TIMED, 5) self.interface.time_remaining = 60 pyglet.clock.schedule_interval(update_timer, 1) self.interface.state = DesktopStates.game def handle_timed_retries_btn(source): self.interface.view_events.create(GameMode.TIMED_RETRIES, 5) self.interface.time_remaining = 60 pyglet.clock.schedule_interval(update_timer, 1) self.interface.state = DesktopStates.game untimed_btn.push_handlers(on_click=handle_untimed_btn) retries_btn.push_handlers(on_click=handle_retries_btn) timed_btn.push_handlers(on_click=handle_timed_btn) timed_retries_btn.push_handlers(on_click=handle_timed_retries_btn) menu_hbox = glooey.HBox() menu_hbox.add(untimed_btn) menu_hbox.add(retries_btn) menu_hbox.add(timed_btn) menu_hbox.add(timed_retries_btn) vbox = glooey.VBox() vbox.add(title) vbox.add(menu_hbox) self._attach_child(vbox)
def __init__(self, title=None): super().__init__() self._vbox = glooey.VBox() self._title = self.Title(title or self.custom_text) self._header = self.Header() self._body = self.Body() self._header.add(self._title) self._vbox.add(self._header, 0) self._vbox.add(self._body) self._attach_child(self._vbox) self.color = self.custom_color
def click_menu_open(self, menu_open): # open a input box for the user to select a self.folder_name self.folderList = CustomScrollBox() self.folderList.size_hint = 100, 400 vbox_for_folderList = glooey.VBox(0) for folder in os.listdir('./planes/'): _button = GenericButton(folder) # sets the active server to the one you press. _button.push_handlers(on_click=lambda w: self.click_open_button(w.text)) vbox_for_folderList.add(_button) self.folderList.add(vbox_for_folderList) self.yesNoDialog = YesNoDialog() self.yesNoDialog.add(self.folderList) self.yesNoDialog.open(self.get_parent())
def load_menu_batch(self): ''' Loads all of the items for the main menu GUI This is done via glooey ''' menu_gui = glooey.Gui(self, batch=self.batches["menu_batch"], group=self.gui_group) v_container = glooey.VBox() v_container.alignment = "center" v_container.add(Title("Platformer")) v_container.add(MenuButton("Play", self.play)) v_container.add(MenuButton("Exit", self.exit_game)) menu_gui.add(v_container)
def fill_character_list(self, list_of_characters): character_list_scroll_box = CustomScrollBox() character_list_scroll_box.size_hint = 100, 100 self.vbox_for_characterlist = glooey.VBox(0) # add the create new character button first then add the list the of characters for the user. self.create_button = CreateNewCharacterButton() # add the first button self.vbox_for_characterlist.add(self.create_button) # add the character buttons for character in list_of_characters: _decoded = decode_packet(character, keys=True) _button = CharacterListButton(_decoded["name"]) _button.push_handlers(on_click=self.select_character) self.vbox_for_characterlist.add(_button) character_list_scroll_box.add(self.vbox_for_characterlist) self.grid[2, 0] = character_list_scroll_box
def execute(self): """Draw Options Menu""" self.d.gui.clear() vbox = glooey.VBox() self.d.gui.add(vbox) hbox = HBox() hbox2 = HBox() hbox3 = HBox() vbox.add(hbox) vbox.add(hbox2) vbox.add(hbox3) hbox.add(OptionsTitleLabel()) hbox2.add(DifficultyLabel()) hbox3.add(OptionsBackLabel()) self.d.fsm.set_state('OPTIONS')
def execute(self): """Draw Main Menu""" self.d.gui.clear() vbox = glooey.VBox() self.d.gui.add(vbox) hbox = HBox() hbox2 = HBox() hbox3 = HBox() vbox.add(hbox) vbox.add(hbox2) vbox.add(hbox3) hbox.add(StartLabel()) hbox2.add(OptionsLabel()) hbox3.add(ExitLabel()) self.d.fsm.set_state('MENU')
def displayGUI(): # Open a Window window = pyglet.window.Window(width=800, height=480) # fullscreen=True gui = glooey.Gui(window) class StatusLabel(glooey.Label): custom_font_name = "Calibri" custom_font_size = 12 custom_color = "0080ff" class ArmButton(glooey.Button): if alarm.system_armed: class Base(glooey.Image): custom_image = pyglet.resource.image('Button2.png') elif not alarm.system_armed: class Base(glooey.Image): custom_image = pyglet.resource.image('Button3.png') class DoorStatusLabel(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" class TemperatureData(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" class Clock(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" SensorStatusVbox = glooey.VBox() self.grid = glooey.Grid() gui.add(self.grid)
def build(cls, ui): # Create our outer container container = glooey.VBox(0) container.alignment = 'center' container.cell_padding = 40 # Create the title title = TitleText('Backhaul') container.add(title) # Create our buttons buttons = { 'New Game': ui.lazy_emit('game:new'), 'Continue Game': ui.lazy_emit('game:load'), 'Seed Explorer': ui.lazy_emit('game:seedexplorer'), 'Settings': ui.lazy_emit('game:settings'), } for label, action in buttons.items(): button = Button(label) button.push_handlers(on_click=action) container.add(button) return container
#!/usr/bin/env python3 import pyglet import glooey import run_demos window = pyglet.window.Window() gui = glooey.Gui(window) vbox = glooey.VBox() vbox.alignment = 'center' vbox.padding = 10 gui.add(vbox) @run_demos.on_space(gui) # def test_label(): class TwoStateForm(glooey.Form): # class Label(glooey.EditableLabel): custom_padding = 2 custom_width_hint = 200 class Base(glooey.Background): custom_outline = 'green' class Focused(glooey.Background): custom_outline = 'orange' vbox.clear() vbox.add(TwoStateForm()) vbox.add(TwoStateForm('Lorem ipsum.'))
def display_scenes( data, height=480, width=640, tile=None, caption=None, rotate=False, rotation_scaling=1, ): import glooey scenes = None scenes_group = None scenes_ggroup = None if isinstance(data, types.GeneratorType): next_data = next(data) if isinstance(next_data, types.GeneratorType): scenes_ggroup = data scenes_group = next_data scenes = next(next_data) else: scenes_group = data scenes = next_data else: scenes = data scenes.pop("__clear__", False) if tile is None: nrow, ncol = _get_tile_shape(len(scenes), hw_ratio=height / width) else: nrow, ncol = tile configs = [ pyglet.gl.Config(sample_buffers=1, samples=4, depth_size=24, double_buffer=True), pyglet.gl.Config(double_buffer=True), ] HEIGHT_LABEL_WIDGET = 19 PADDING_GRID = 1 for config in configs: try: window = pyglet.window.Window( height=(height + HEIGHT_LABEL_WIDGET) * nrow, width=(width + PADDING_GRID * 2) * ncol, caption=caption, config=config, ) break except pyglet.window.NoSuchConfigException: pass window.rotate = rotate window._clear = False if scenes_group: window.play = False window.next = False window.scenes_group = scenes_group window.scenes_ggroup = scenes_ggroup def usage(): return """\ Usage: q: quit s: play / pause z: reset view n: next r: rotate view (clockwise) R: rotate view (anti-clockwise)\ """ @window.event def on_key_press(symbol, modifiers): if symbol == pyglet.window.key.Q: window.on_close() elif window.scenes_group and symbol == pyglet.window.key.S: window.play = not window.play elif symbol == pyglet.window.key.Z: for name in scenes: if isinstance(widgets[name], trimesh.viewer.SceneWidget): widgets[name].reset_view() elif symbol == pyglet.window.key.N: if (window.scenes_ggroup and modifiers == pyglet.window.key.MOD_SHIFT): try: window.scenes_group = next(window.scenes_ggroup) window.next = True window._clear = True except StopIteration: return else: window.next = True elif symbol == pyglet.window.key.C: camera_transform_ids = set() for key, widget in widgets.items(): if isinstance(widget, trimesh.viewer.SceneWidget): camera_transform_id = id(widget.scene.camera_transform) if camera_transform_id in camera_transform_ids: continue camera_transform_ids.add(camera_transform_id) print(f"{key}:") camera_transform = widget.scene.camera_transform print(repr(from_opengl_transform(camera_transform))) elif symbol == pyglet.window.key.R: # rotate camera window.rotate = not window.rotate # 0/1 if modifiers == pyglet.window.key.MOD_SHIFT: window.rotate *= -1 elif symbol == pyglet.window.key.H: print(usage()) def callback(dt): if window.rotate: for widget in widgets.values(): if isinstance(widget, trimesh.viewer.SceneWidget): axis = tf.transform_points( [[0, 1, 0]], widget.scene.camera_transform, translate=False, )[0] widget.scene.camera_transform[...] = (tf.rotation_matrix( np.deg2rad(window.rotate * rotation_scaling), axis, point=widget.scene.centroid, ) @ widget.scene.camera_transform) widget.view["ball"]._n_pose = widget.scene.camera_transform return if window.scenes_group and (window.next or window.play): try: scenes = next(window.scenes_group) clear = scenes.get("__clear__", False) or window._clear window._clear = False for key, widget in widgets.items(): scene = scenes[key] if isinstance(widget, trimesh.viewer.SceneWidget): assert isinstance(scene, trimesh.Scene) if clear: widget.clear() widget.scene = scene else: widget.scene.geometry.update(scene.geometry) widget.scene.graph.load(scene.graph.to_edgelist()) widget.scene.camera_transform[ ...] = scene.camera_transform widget.view[ "ball"]._n_pose = widget.scene.camera_transform widget._draw() elif isinstance(widget, glooey.Image): widget.set_image(numpy_to_image(scene)) except StopIteration: print("Reached the end of the scenes") window.play = False window.next = False gui = glooey.Gui(window) grid = glooey.Grid() grid.set_padding(PADDING_GRID) widgets = {} trackball = None for i, (name, scene) in enumerate(scenes.items()): vbox = glooey.VBox() vbox.add(glooey.Label(text=name, color=(255, ) * 3), size=0) if isinstance(scene, trimesh.Scene): widgets[name] = trimesh.viewer.SceneWidget(scene) if trackball is None: trackball = widgets[name].view["ball"] else: widgets[name].view["ball"] = trackball elif isinstance(scene, np.ndarray): widgets[name] = glooey.Image(numpy_to_image(scene), responsive=True) else: raise TypeError(f"unsupported type of scene: {scene}") vbox.add(widgets[name]) grid[i // ncol, i % ncol] = vbox gui.add(grid) pyglet.clock.schedule_interval(callback, 1 / 30) pyglet.app.run() pyglet.clock.unschedule(callback)
import pyglet #---import GUI---# import glooey #---Setting---# mainWindow = pyglet.window.Window() mainGui = glooey.Gui(mainWindow) rows = glooey.VBox() mainGui.add(rows) #---Customize Class---# class wow(glooey.Label): custom_font_size = 20 custom_bold = True custom_color = "002050" custom_alignment = "center" #---Display---# lable = wow("Welcome to Password Checker") rows.add(lable) form = glooey.Form("Enter your password: "******"Click to check") def buttonClick(widget): print("check") if form.text == "Enter your password: 1234": result = glooey.Label("Your password is weak")
def labeled_scene_widget(scene, label): vbox = glooey.VBox() vbox.add(glooey.Label(text=label, color=(255, 255, 255)), size=0) vbox.add(trimesh.viewer.SceneWidget(scene)) return vbox
def display_scenes(data, height=480, width=640, tile=None, caption=None): import glooey scenes = None scenes_group = None scenes_ggroup = None if isinstance(data, types.GeneratorType): next_data = next(data) if isinstance(next_data, types.GeneratorType): scenes = next(next_data) scenes_group = next_data scenes_ggroup = data else: scenes = next_data scenes_group = data else: scenes = data if tile is None: nrow, ncol = _get_tile_shape(len(scenes), hw_ratio=height / width) else: nrow, ncol = tile configs = [ pyglet.gl.Config(sample_buffers=1, samples=4, depth_size=24, double_buffer=True), pyglet.gl.Config(double_buffer=True), ] for config in configs: try: window = pyglet.window.Window( height=height * nrow, width=width * ncol, caption=caption, config=config, ) break except pyglet.window.NoSuchConfigException: pass window.rotate = 0 if scenes_group: window.play = False window.next = False window.scenes_group = scenes_group window.scenes_ggroup = scenes_ggroup @window.event def on_key_press(symbol, modifiers): if modifiers == 0: if symbol == pyglet.window.key.Q: window.on_close() elif window.scenes_group and symbol == pyglet.window.key.S: window.play = not window.play elif symbol == pyglet.window.key.Z: for name in scenes: if isinstance(widgets[name], trimesh.viewer.SceneWidget): widgets[name].reset_view() if symbol == pyglet.window.key.N: if modifiers == 0: window.next = True elif window.scenes_ggroup and \ modifiers == pyglet.window.key.MOD_SHIFT: try: window.scenes_group = next(window.scenes_ggroup) window.next = True except StopIteration: return if symbol == pyglet.window.key.R: # rotate camera window.rotate = not window.rotate # 0/1 if modifiers == pyglet.window.key.MOD_SHIFT: window.rotate *= -1 def callback(dt): if window.rotate: for widget in widgets.values(): if isinstance(widget, trimesh.viewer.SceneWidget): scene = widget.scene camera = scene.camera axis = tf.transform_points([[0, 1, 0]], camera.transform, translate=False)[0] camera.transform = tf.rotation_matrix( np.deg2rad(window.rotate), axis, point=scene.centroid, ) @ camera.transform widget.view['ball']._n_pose = camera.transform return if window.scenes_group and (window.next or window.play): try: scenes = next(window.scenes_group) for key, widget in widgets.items(): if isinstance(widget, trimesh.viewer.SceneWidget): widget.scene.geometry.update(scenes[key].geometry) widget.scene.graph.load( scenes[key].graph.to_edgelist()) widget._draw() elif isinstance(widget, glooey.Image): widget.set_image(numpy_to_image(scenes[key])) except StopIteration: window.play = False window.next = False gui = glooey.Gui(window) grid = glooey.Grid() grid.set_padding(5) widgets = {} trackball = None for i, (name, scene) in enumerate(scenes.items()): vbox = glooey.VBox() vbox.add(glooey.Label(text=name, color=(255, ) * 3), size=0) if isinstance(scene, trimesh.Scene): widgets[name] = trimesh.viewer.SceneWidget(scene) if trackball is None: trackball = widgets[name].view['ball'] else: widgets[name].view['ball'] = trackball elif isinstance(scene, np.ndarray): widgets[name] = glooey.Image(numpy_to_image(scene), responsive=True) else: raise TypeError(f'unsupported type of scene: {scene}') vbox.add(widgets[name]) grid[i // ncol, i % ncol] = vbox gui.add(grid) pyglet.clock.schedule_interval(callback, 1 / 30) pyglet.app.run() pyglet.clock.unschedule(callback)
class Over(glooey.Image): custom_image = pyglet.resource.image('over.png') class Down(glooey.Image): custom_image = pyglet.resource.image('down.png') class TemplateButtonLabel(glooey.Label): custom_font_name = "Calibri" custom_font_size = 9 custom_color = "0080ff" custom_alignment = 'center' # Document Organizer section DocOrgVbox = glooey.VBox() DocOrgVbox.alignment = 'top' DocOrgLabel = TitleLabel("Document Organizer") CheckDirBttn = CustomButton('Check Directories') CheckDirBttn.push_handlers(on_click=lambda w: DocOrg.ChkDir()) OrganizeBttn = CustomButton('Organize') OrganizeBttn.push_handlers(on_click=lambda w: DocOrg.Organize()) CCleanBttn = CustomButton('C Cleaner') CCleanBttn.push_handlers(on_click=lambda w: DocOrg.CCleaner()) DocOrgVbox.add(DocOrgLabel) DocOrgVbox.add(CheckDirBttn) DocOrgVbox.add(OrganizeBttn) DocOrgVbox.add(CCleanBttn) # Add objects to grid grid = glooey.Grid()