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): # create window with padding self.width, self.height = 480 * 3, 360 window = self._create_window(width=self.width, height=self.height) gui = glooey.Gui(window) hbox = glooey.HBox() hbox.set_padding(5) # scene widget for changing camera location scene = create_scene() self.scene_widget1 = trimesh.viewer.SceneWidget(scene) self.scene_widget1._angles = [np.deg2rad(45), 0, 0] hbox.add(self.scene_widget1) # scene widget for changing scene scene = trimesh.Scene() geom = trimesh.path.creation.box_outline((0.6, 0.6, 0.6)) scene.add_geometry(geom) self.scene_widget2 = trimesh.viewer.SceneWidget(scene) hbox.add(self.scene_widget2) # integrate with other widget than SceneWidget self.image_widget = glooey.Image() hbox.add(self.image_widget) gui.add(hbox) pyglet.clock.schedule_interval(self.callback, 1. / 20) pyglet.app.run()
def main(): np.random.seed(0) window = pyglet.window.Window(width=1295, height=975) gui = glooey.Gui(window) grid = glooey.Grid(2, 2) grid.set_padding(5) scene = create_scene1() widget = SceneWidget(scene) grid[0, 0] = widget scene = create_scene2() widget = SceneWidget(scene) grid[0, 1] = widget image = pyglet.image.load('images/beach.jpg') widget = glooey.Image(image) grid[1, 0] = widget hbox = glooey.HBox() widget = glooey.Button(text='yes') widget.push_handlers(on_click=lambda w: print(f'[{w.text}] clicked!')) hbox.add(widget) widget = glooey.Button(text='no') widget.push_handlers(on_click=lambda w: print(f'[{w.text}] clicked!')) hbox.add(widget) grid[1, 1] = hbox gui.add(grid) pyglet.app.run()
def __init__(self, interface): super().__init__() self.interface = interface self.hbox = glooey.HBox(0) self.hbox.add(LeftBrowserWrapper(self.interface)) self.hbox.add(RightBrowserWrapper(self.interface)) self._attach_child(self.hbox)
def __init__(self, interface, string): super().__init__() self.interface = interface self.hbox = glooey.HBox() for char in string: self.hbox.add(GameBoardTile(interface, char)) self._attach_child(self.hbox)
def __init__(self): super().__init__() # our points available to spend on traits self.points = 8 _screens = [ "scenario", "profession", "traits", "stats", "skills", "description", ] # the row of buttons on top. responsible for switching the subcontext below points left. top_buttons = glooey.HBox(0) # finish_button is self. so we can access it easier. self.finish_button = ConnectButton("Commit") for screen in _screens: _button = CharacterGenButton(screen) top_buttons.add(_button) top_buttons.add(self.finish_button) self.add(top_buttons) # now add the remaining points label points_box = glooey.HBox() points_label = glooey.Label("Points Left:") points_box.add(points_label) self.pointsLeftLabel = glooey.Label(str(self.points)) points_box.add(self.pointsLeftLabel) self.add(points_box) # our main_frame will be a single use container that we replace the contents of. self.main_frame = glooey.containers.Bin() self.main_frame.custom_padding = 8 self.main_frame.add(self.DescriptionTab()) self.add(self.main_frame) self.name = "" self.gender = ""
def visualize(occupied, empty, K, width, height, rgb, pcd, mask, resolution, aabb): window = pyglet.window.Window(width=int(640 * 0.9 * 3), height=int(480 * 0.9)) @window.event def on_key_press(symbol, modifiers): if modifiers == 0: if symbol == pyglet.window.key.Q: window.on_close() gui = glooey.Gui(window) hbox = glooey.HBox() hbox.set_padding(5) camera = trimesh.scene.Camera( resolution=(width, height), focal=(K[0, 0], K[1, 1]), transform=np.eye(4), ) camera_marker = trimesh.creation.camera_marker(camera, marker_height=0.1) # initial camera pose camera.transform = np.array( [[0.73256052, -0.28776419, 0.6168848, 0.66972396], [-0.26470017, -0.95534823, -0.13131483, -0.12390466], [0.62712751, -0.06709345, -0.77602162, -0.28781298], [ 0., 0., 0., 1., ]], ) aabb_min, aabb_max = aabb bbox = trimesh.path.creation.box_outline( aabb_max - aabb_min, tf.translation_matrix((aabb_min + aabb_max) / 2), ) geom = trimesh.PointCloud(vertices=pcd[mask], colors=rgb[mask]) scene = trimesh.Scene(camera=camera, geometry=[bbox, geom, camera_marker]) hbox.add(labeled_scene_widget(scene, label='pointcloud')) geom = trimesh.voxel.multibox(occupied, pitch=resolution, colors=[1., 0, 0, 0.5]) scene = trimesh.Scene(camera=camera, geometry=[bbox, geom, camera_marker]) hbox.add(labeled_scene_widget(scene, label='occupied')) geom = trimesh.voxel.multibox(empty, pitch=resolution, colors=[0.5, 0.5, 0.5, 0.5]) scene = trimesh.Scene(camera=camera, geometry=[bbox, geom, camera_marker]) hbox.add(labeled_scene_widget(scene, label='empty')) gui.add(hbox) pyglet.app.run()
def __init__(self, interface, game_input): super().__init__() self.interface = interface self.game_input = game_input self.hbox = glooey.HBox() self.game_info = GameInformationWidget(interface) self.game_buttons = GameButtonsWidget(interface, game_input) self.hbox.add(self.game_info) self.hbox.add(self.game_buttons) self._attach_child(self.hbox)
def __init__(self, interface): super().__init__() self.interface = interface self.hbox = glooey.HBox() self.time_widget = InformationWidget("Time", "--:--") self.retries_widget = InformationWidget("Retries", "3") self.score_widget = InformationWidget("Score", "0") self.hbox.add(self.time_widget) self.hbox.add(self.retries_widget) self.hbox.add(self.score_widget) self._attach_child(self.hbox)
def __init__(self, text): super().__init__() hbox = glooey.HBox() self.checkbox = WesnothCheckbox() self.label = WesnothLabel(text) hbox.pack(self.checkbox) hbox.add(self.label) hbox.padding = 6 self._attach_child(hbox)
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, interface, game_input): super().__init__() self.interface = interface self.game_input = game_input def handle_ans_btn(source): self.interface.view_events.answer( self.game_input.game_input.input_string) self.game_input.game_input.input_string = "" hbox = glooey.HBox() check_ans_button = GameButton("Answer") check_ans_button.push_handlers(on_click=handle_ans_btn) hbox.add(check_ans_button) self._attach_child(hbox)
def visualize(occupied, resolution, is_pyglet_used): blue = np.linspace(1., 0., len(occupied) // 2) blue1 = np.zeros(len(occupied) - (len(occupied) // 2)) blue = np.hstack((blue, blue1)) green = np.linspace(0., 1., len(occupied) // 2) green1 = np.linspace(1., 0., len(occupied) - (len(occupied) // 2)) green = np.hstack((green, green1)) red = np.zeros(len(occupied) // 2) red1 = np.linspace(0., 1., len(occupied) - (len(occupied) // 2)) red = np.hstack((red, red1)) trans = 1.0 * np.ones(len(occupied)) colors = np.vstack((red, green, blue, trans)).T sorted_occupied = occupied[occupied[:, 1].argsort()][::-1] if is_pyglet_used: window = pyglet.window.Window(width=int(640 * 0.9 * 3), height=int(480 * 0.9 * 2)) @window.event def on_key_press(symbol, modifiers): if modifiers == 0: if symbol == pyglet.window.key.Q: window.on_close() gui = glooey.Gui(window) hbox = glooey.HBox() hbox.set_padding(5) geom = trimesh.voxel.ops.multibox(sorted_occupied, pitch=resolution, colors=colors) scene = trimesh.Scene(geometry=[geom]) hbox.add(labeled_scene_widget(scene, label='occupied')) gui.add(hbox) pyglet.app.run() else: v = pptk.viewer(sorted_occupied) v.set(point_size=0.03) v.attributes(colors) v.set(color_map=colors)
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 __init__(self, resolution=0.1): # create window self.resolution = resolution self.width, self.height = 700, 700 window = self._create_window(width=self.width, height=self.height) gui = glooey.Gui(window) hbox = glooey.HBox() # scene widget for changing self.geometry_name = 'geometry_0' scene = trimesh.Scene() # initial cube geom = trimesh.path.creation.box_outline((1, 1, 1)) scene.add_geometry(geom) self.scene_widget = trimesh.viewer.SceneWidget(scene) hbox.add(self.scene_widget) # clear from cube ¯\_(ツ)_/¯ to delete useless geometry self.scene_widget.scene.delete_geometry(self.geometry_name) gui.add(hbox) # buffer here (points and all for processing self.points = np.random.uniform(-0.3, 0.3, (100, 3)) self.render_points = self.points self.is_changed = True # self.is_updated = False pcd = o3d.io.read_point_cloud("data/pcl_comb_opt.pcd") self.all_points = np.asarray(pcd.points) self.batch = self.all_points.shape[0]/1000 self.current_batch = 1 # launch updater and main thread pyglet.clock.schedule_interval(self._update_visualisation_callback, 1. / 60) self.main_thread = StoppableThread(target=self._start_processing) self.main_thread.start() pyglet.app.run()
def test_checkbox(): yield "Green button with orange over and purple down states." button.disable() yield "Grey inactive button (no rollover)." button.enable() gui.clear() hbox = glooey.HBox() proxy = glooey.Placeholder(100, 10) hbox.pack(button) hbox.pack(proxy) hbox.alignment = 'center' hbox.padding = 10 gui.add(hbox) button.add_proxy(proxy) yield "Rollover or click the placeholder to control the button." gui.clear() hbox.remove(button) gui.add(button)
elif symbol == 65293: nextLabel() ############################# vBox = glooey.VBox() from trimesh.viewer import SceneWidget sc = trimesh.Scene() sphere = trimesh.creation.icosphere(1, 1, [0.0, 1.0, 0.0, 0.5]) sc.add_geometry(sphere) sceneWidget = SceneWidget(sc) displayHBox = glooey.HBox() displayHBox.add_right(sceneWidget, size=650) im = np.dstack((np.ones((250, 750)) * 255, np.zeros((250, 750)), np.zeros((250, 750)))).astype(np.uint8) imageWidget = GUI.ImageWidget(im) displayHBox.add_left(imageWidget, size=750) vBox.add_top(displayHBox) hbox = glooey.HBox() hbox.alignment = 'bottom' buttons = [
#!/usr/bin/env python3 import pyglet import glooey window = pyglet.window.Window() gui = glooey.Gui(window) hbox = glooey.HBox() hbox.padding = 10 left = glooey.Placeholder() right = glooey.Placeholder() hbox.add(left) hbox.add(right) gui.add(hbox) pyglet.app.run()
def load_level(self): ''' Decodes the level from the level.json ''' level_path = pathlib.Path("static_assets/levels/level{}.json".format( self.current_level)) with level_path.open(mode="r") as data: level_data = json.load(data) # Loads the HUD of the main game hud_gui = glooey.Gui(self, batch=self.batches["game_batch"], group=self.gui_group) h_container = glooey.HBox() h_container.alignment = "fill top" h_container.set_padding(10) self.level_lbl = Standared("Level: {}".format(self.current_level)) self.level_lbl.alignement = "left" self.level_lbl.set_right_padding(100) h_container.add(self.level_lbl) self.score_lbl = Standared("Score: {}".format(self.score)) self.score_lbl.alignment = "center" h_container.add(self.score_lbl) pause_btn = MenuButton("Pause", self.game_pause) pause_btn.alignment = "right" pause_btn.set_left_padding(100) h_container.add(pause_btn) hud_gui.add(h_container) # Loads the items to populate the game self.player = player.Player(level_data["player_spawn"]["x"], level_data["player_spawn"]["y"], batch=self.batches["game_batch"], group=self.game_group) self.platform_list = [] for i in level_data["platforms"]: self.platform_list.append( platform.Platform(i["x"], i["y"], i["scale_x"], batch=self.batches["game_batch"], group=self.game_group)) self.coin_list = [] for i in level_data["coins"]: self.coin_list.append( coin.Coin(x=i["x"], y=i["y"], batch=self.batches["game_batch"], group=self.game_group)) self.collision_dict = { "coins": self.coin_list, "platforms": self.platform_list }