Пример #1
0
def test_scroll_box_scale_grip_no_child():
    # It should not be an error to attach a scroll box with a scaled grip and
    # no child to the GUI.  This means the scroll box needs to hold off
    # calculating how big its grip should be if it's attached before it has a
    # child.  See #36.

    class TestWindow:
        def __init__(self):
            self.width = 600
            self.height = 480

        def push_handlers(self, listener):
            pass

    class TestScrollBox(glooey.ScrollBox):
        class VBar(glooey.VScrollBar):
            custom_scale_grip = True

            class Grip(glooey.Button):
                pass

    win = TestWindow()
    gui = glooey.Gui(win)

    scroll = TestScrollBox()
    gui.add(scroll)
Пример #2
0
    def __init__(self):
        self.state = "login"  # character_select, character_gen, main
        super().__init__()

        self.window = pyglet.window.Window(896, 498)
        self.client_name = ""
        self.character_name = ""
        self.last_request = time.time()

        pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
        pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
                              pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)

        self.gui = glooey.Gui(self.window)

        self.gui.add(CustomBackground())

        # TODO: make new hotbar in pyglet.
        self.hotbars = []

        self.LoginWindow = LoginWindow()
        self.LoginWindow.grid[6, 1].push_handlers(
            on_click=self.login)  # Connect Button

        self.gui.add(self.LoginWindow)

        # init but don't show the window
        self.main_window = MainWindow
Пример #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.set_location(50, 50)  # location of upper left window corner
        self.batch = pyglet.graphics.Batch()
        self.group = pyglet.graphics.Group()
        # self.set_mouse_visible(False)
        self.frame_rate = 1 / 60.
        self.fps_display = FPSDisplay(self)

        self.keys = key.KeyStateHandler()
        self.push_handlers(self.keys)

        self.gui = glooey.Gui(self, batch=self.batch, group=self.group)

        # Set GAME Finite State Machine states and transitions
        self.fsm = FSM()
        self.fsm.states['MENU'] = GameMenu(self)
        self.fsm.states['GAME'] = GamePlay(self)
        self.fsm.states['OPTIONS'] = GameOptions(self)
        self.fsm.states['END'] = GameEnd(self)
        self.fsm.states['EXIT'] = GameExit(self)
        self.fsm.transitions['toMENU'] = TransitionToMenu('MENU', self)
        self.fsm.transitions['toGAME'] = TransitionToGame('GAME', self)
        self.fsm.transitions['toOPTIONS'] = TransitionToOptions(
            'OPTIONS', self)
        self.fsm.transitions['toEND'] = TransitionToEnd('END', self)
        self.fsm.transitions['toEXIT'] = TransitionToEnd('EXIT', self)

        self.fsm.transition('toMENU')
Пример #4
0
    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()
Пример #5
0
 def __init__(self):
     pyglet.window.Window.__init__(self,
                                   854,
                                   480,
                                   caption='Select/Create a Character.')
     self.gui = glooey.Gui(self)
     self.gui.add(Background())
Пример #6
0
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()
Пример #7
0
    def __init__(self, width, height):
        conf = Config(sample_buffers=1,
                      samples=4,
                      depth_size=16,
                      double_buffer=True)
        super(Main_Window2, self).__init__(Game.WIDTH,
                                           Game.HEIGHT,
                                           config=conf)
        self.push_handlers(keys)

        self.gui = glooey.Gui(self, gui_batch)

        self.client = Game_Client2(width, height, self.gui, stack)
        start_button = Start_Button(self.client)
        start_button.right_padding = 170
        vbox.add(start_button)
        vbox.top_padding = 250
        exit_button = Exit_Button()
        exit_button.right_padding = 170

        def exit(widget):
            sys.exit()

        exit_button.on_click = exit
        vbox.add(exit_button)
        self.gui.add(stack)

        self.ping = pyglet.text.HTMLLabel(
            '<font face="Arial" size="13" color="white"><b>latency: %3.3f ms fps:%3.3f</b></font>'
            % (self.client._client.latency, pyglet.clock.get_fps()),
            x=self.width - 130,
            y=self.height - 12,
            anchor_x='center',
            anchor_y='center')
Пример #8
0
    def on_click(self, w):
        if Globals.dialog != None:
            pass
        else:
            Globals.dialog = pyglet.window.Window(
                height=300,
                width=300,
                caption="Select Widget for Cell " + str(self.x + 1) + ", " +
                str(self.y + 1),
                style=pyglet.window.Window.WINDOW_STYLE_DIALOG)
            Globals.dialog.set_icon(pyglet.resource.image('icon16.png'),
                                    pyglet.resource.image('icon32.png'))
            dialog_gui_batch = pyglet.graphics.Batch()
            dialog_gui = glooey.Gui(Globals.dialog, batch=dialog_gui_batch)

            dialog_gui.add(SelectWidgetDialog((self.x, self.y)))

            @Globals.dialog.event
            def on_draw():
                Globals.dialog.clear()
                dialog_gui_batch.draw()

            @Globals.dialog.event
            def on_close():
                dialogOnClose()
Пример #9
0
    def on_click(self, w):
        parent = self.parent.parent

        if Globals.dialog != None:
            pass
        else:
            Globals.dialog = pyglet.window.Window(
                height=300,
                width=300,
                caption="Options for " + parent.name,
                style=pyglet.window.Window.WINDOW_STYLE_DIALOG)
            Globals.dialog.set_icon(pyglet.resource.image('icon16.png'),
                                    pyglet.resource.image('icon32.png'))
            new_gui_batch = pyglet.graphics.Batch()
            new_gui = glooey.Gui(Globals.dialog, batch=new_gui_batch)

            try:
                new_gui.add(self.parent.parent.Options(self.position))
            except AttributeError:
                new_gui.add(BaseOptionsMenu(self.position))

            @Globals.dialog.event
            def on_draw():
                Globals.dialog.clear()
                new_gui_batch.draw()

            @Globals.dialog.event
            def on_close():
                dialogOnClose()
Пример #10
0
    def __init__(self, database):
        self.database = database
        self.window = pyglet.window.Window(width=1200, height=900)

        pyglet.font.add_file("resources/8bit.TTF")

        self.gui = glooey.Gui(self.window)
        self.gui.add(Browser(self))
Пример #11
0
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()
Пример #12
0
 def __init__(
         self, character, room
 ):  # main window needs a room and character to display properly.
     pyglet.window.Window.__init__(self,
                                   854,
                                   480,
                                   caption='Looming Darkness ' +
                                   character.full_name())
     self.gui = glooey.Gui(self)
     self.gui.add(Background())
Пример #13
0
    def __init__(self, name):
        MastermindClientTCP.__init__(self)
        pyglet.resource.path = [
            'tiles', 'tiles/background', 'tiles/monsters', 'tiles/terrain'
        ]
        pyglet.resource.reindex()
        ######################################################################################
        ## when we get an update from the server we update these values from the parsed chunk.
        self.name = name
        self.chunk_size = (51, 27)
        self.player = None
        self.chunk = None
        self.map = None
        self.creatures = None
        self.objects = None
        self.map_grid = glooey.Grid(self.chunk_size[1], self.chunk_size[0], 16,
                                    16)  # chunk_size + tilemap size
        self.map_grid.set_left_padding(16)  # for the border.
        self.map_grid.set_top_padding(16)

        for i in range(self.chunk_size[1]
                       ):  # glooey uses y,x for grids from the top left.
            for j in range(self.chunk_size[0]):
                self.map_grid.add(
                    i, j,
                    glooey.images.Image(pyglet.resource.texture('t_grass.png'))
                )  # before we get an update we need to init the map with grass.

        ######################################################################################

        window = pyglet.window.Window(854, 480)
        gui = glooey.Gui(window)

        bg = glooey.Background()
        bg.set_appearance(
            center=pyglet.resource.texture('center.png'),
            top=pyglet.resource.texture('top.png'),
            bottom=pyglet.resource.texture('bottom.png'),
            left=pyglet.resource.texture('left.png'),
            right=pyglet.resource.texture('right.png'),
            top_left=pyglet.resource.texture('top_left.png'),
            top_right=pyglet.resource.texture('top_right.png'),
            bottom_left=pyglet.resource.texture('bottom_left.png'),
            bottom_right=pyglet.resource.texture('bottom_right.png'))
        gui.add(bg)
        gui.add(self.map_grid)

        @window.event
        def on_key_press(symbol, modifiers):
            if symbol == KEY.RETURN:
                print('return')
            if symbol == KEY.W:
                command = Command(args.name, 'move', ['north'])
                client.send(command)
Пример #14
0
    def __init__(self):
        self.window = pyglet.window.Window(1916, 1010)
        self.window.set_location(0, 32)

        pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
        pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
                              pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)

        self.gui = glooey.Gui(self.window)

        self.gui.add(mainWindow())
Пример #15
0
    def __init__(self):
        super(MyWindow, self).__init__(setup.screen_width,
                                       setup.screen_height,
                                       "Click The Knight",
                                       vsync=True,
                                       fullscreen=False)

        self.gui = glooey.Gui(self, batch=resources.gui_batch)
        self.knights = []
        self.fps_display = FPSDisplay(self)
        self.gameRunning = False
        self.createGui(None)
Пример #16
0
def control_panel():

    WIDTH = 800
    HEIGHT = 1000

    window = pyglet.window.Window(WIDTH, HEIGHT)
    gui = glooey.Gui(window)
    grid = glooey.Grid(2, 2)

    G_WIDTH = 1280 / 4
    G_HEIGHT = 780 / 4
    window2 = pyglet.window.Window(G_WIDTH + 100, G_HEIGHT)
    gui2 = glooey.Gui(window2)

    def make_initial_circles():
        c0 = Circle(0, main=True)
        c1 = Circle(1)
        c2 = Circle(2)
        c3 = Circle(3)
        c4 = Circle(4)
        circles = [c0, c1, c2, c3, c4]
        for circle in circles:
            gui2.add(circle)
        c0.reposition(G_WIDTH, G_HEIGHT / 2)
        c1.reposition(G_WIDTH / 4, G_HEIGHT / 4)
        c2.reposition(G_WIDTH / 4 + G_WIDTH / 2, G_HEIGHT / 4)
        c3.reposition(G_WIDTH / 4, G_HEIGHT / 4 + G_HEIGHT / 2)
        c4.reposition(G_WIDTH / 4 + G_WIDTH / 2, G_HEIGHT / 4 + G_HEIGHT / 2)
        return circles

    circles = make_initial_circles()
    change_performer = TogglePerformer("Change Selected to Performer",
                                       circles=circles)
    save_locations = SaveLocations("change location", circles=circles)
    grid.add(0, 0, change_performer)
    grid.add(0, 1, save_locations)
    gui.add(grid)
    return (window, window2, gui)
    def init_visualiser(self):
        gui = glooey.Gui(self.window)
        # pyglet.clock.schedule_interval(func=self.update_visualisation, interval=self.update_time)


        aabb_min = np.array([-1.4, -1., 0.])
        aabb_max = np.array([0.45, 0.75, 2.])
        initial_bbox = trimesh.path.creation.box_outline(
            aabb_max - aabb_min,
            tf.translation_matrix((aabb_min + aabb_max) / 2),
        )
        scene = trimesh.Scene(geometry=[initial_bbox]) # initial_bbox


        gui.add(trimesh.viewer.SceneWidget(scene))
        pyglet.app.run()
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)
Пример #19
0
    def __init__(self):
        super().__init__()
        self.state = DesktopStates.menu
        self.window = pyglet.window.Window(width=1200, height=900)

        background = TiledBackground()

        self.gui = glooey.Gui(self.window)
        self.gui.add(background)

        self.intro = IntroWidget(self)
        self.menu = MenuWidget(self)
        self.game = GameWidget(self)

        self.time_remaining = None

        @self.window.event
        def on_draw():
            if self.state == DesktopStates.intro:
                self.clear_window()
                self.gui.add(self.intro)
                pyglet.clock.schedule_once(menu_state, 2)
            elif self.state == DesktopStates.menu:
                self.clear_window()
                self.gui.add(self.menu)
            elif self.state == DesktopStates.options:
                # TODO: Implement options display
                pass
            elif self.state == DesktopStates.game:
                self.clear_window()
                self.gui.add(self.game)
                self.game.refresh_board()
            self.gui.on_draw()

        @self.window.event()
        def on_key_press(symbol, modifer):
            if self.state == DesktopStates.game:
                self.game.handle_keypress(symbol)

        def intro_state(dt):
            self.state = DesktopStates.intro

        def menu_state(dt):
            self.state = DesktopStates.menu

        def game_state(dt):
            self.state = DesktopStates.game
Пример #20
0
    def __init__(self):
        self.state = "login"  # character_select, character_gen, main
        MastermindClientTCP.__init__(self)

        self.window = pyglet.window.Window(896, 498)
        self.client_name = ''

        pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
        pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
                              pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)

        self.gui = glooey.Gui(self.window)

        self.bg = glooey.Background()
        self.bg.set_appearance(
            center=pyglet.resource.texture("center.png"),
            top=pyglet.resource.texture("top.png"),
            bottom=pyglet.resource.texture("bottom.png"),
            left=pyglet.resource.texture("left.png"),
            right=pyglet.resource.texture("right.png"),
            top_left=pyglet.resource.texture("top_left.png"),
            top_right=pyglet.resource.texture("top_right.png"),
            bottom_left=pyglet.resource.texture("bottom_left.png"),
            bottom_right=pyglet.resource.texture("bottom_right.png"),
        )

        self.gui.add(self.bg)

        self.TileManager = TileManager
        self.ItemManager = ItemManager
        self.RecipeManager = RecipeManager

        # TODO: make new hotbar in pyglet.
        self.hotbars = []

        self.LoginWindow = LoginWindow()
        self.LoginWindow.grid[6, 1].push_handlers(
            on_click=self.login)  # Connect Button

        self.gui.add(self.LoginWindow)

        self.character = None
        self.localmap = None

        # init but don't show the window
        self.mainWindow = mainWindow
Пример #21
0
    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)
Пример #22
0
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)
Пример #23
0
    def __init__(self):
        self.window = pyglet.window.Window()
        self.window.set_visible(True)
        self.window.set_size(*world.World.field_size)
        self.batch = pyglet.graphics.Batch()

        self.bg_color = glooey.drawing.white

        # Load all the sprite images from resource files.

        self.images = {}
        for code in world.World.codes:
            for suite in world.World.suites:
                key = world.get_card_key(suite, code)
                filename = suite[0] + code + '.png'
                self.images[key] = pyglet.resource.image(filename)

        self.border_images = {}
        for border_name in "border", "border-over", "border-down", "border-selected":
            filename = border_name + '.png'
            self.border_images[border_name] = pyglet.resource.image(filename)

        # Center all the images, which we will want to rotate around it's
        # leftmost edge.

        for image in self.images.values():
            image.anchor_x = image.width / 2
            image.anchor_y = image.height / 2

        # Create the viewing grid
        rows = world.World.rows
        cols = world.World.cols
        padding = world.World.padding
        self.root = glooey.Gui(self.window, batch=self.batch)
        self.grid = glooey.Grid(rows, cols, padding=padding)
        for row, col in self.grid.yield_cells():
            self.grid[row, col] = CardButton(self)
        self.root.add(self.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()
Пример #25
0
#!/usr/bin/env python3

import glooey
import pyglet

pyglet.font.add_file('Lato-Regular.ttf')
pyglet.font.load('Lato Regular')

class WesnothLabel(glooey.Label):
    custom_font_name = 'Lato Regular'
    custom_font_size = 10
    custom_color = '#b9ad86'
    custom_alignment = 'center'

window = pyglet.window.Window()
gui = glooey.Gui(window)

label = WesnothLabel('Hello world!')
gui.add(label)

pyglet.app.run()


Пример #26
0
	def _gui(self):
		if self.__gui is None:
			self.__gui = glooey.Gui(self._window)
		return self.__gui
Пример #27
0
 def __init__(self):
     pyglet.window.Window.__init__(self, 854, 480, caption='Please Login')
     self.gui = glooey.Gui(self)
     self.gui.add(Background())
Пример #28
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--host")
    parser.add_argument("--port", type=int)
    args = parser.parse_args()
    zmq_client = HoldingsClient(host=args.host, port=args.port)

    window = HoldingsManagerWindow()
    gui = glooey.Gui(window)
    grid = glooey.Grid()
    grid.padding = 10

    # First create the forms where the user enters the inputs...
    form_dep_amt = HMForm()
    form_buy_qty = HMForm()
    form_buy_price = HMForm()
    form_sell_qty = HMForm()
    form_sell_price = HMForm()
    # then create a "tab cycle", i.e. a list of these widgets in the tab order
    # we want...
    tab_cycle = [form_dep_amt.get_label(),
                 form_buy_qty.get_label(), form_buy_price.get_label(),
                 form_sell_qty.get_label(), form_sell_price.get_label()]
    # then set this tab cycle as an attribute of the Labels in these forms...
    form_dep_amt.get_label().tab_cycle = tab_cycle
    form_buy_qty.get_label().tab_cycle = tab_cycle
    form_buy_price.get_label().tab_cycle = tab_cycle
    form_sell_qty.get_label().tab_cycle = tab_cycle
    form_sell_price.get_label().tab_cycle = tab_cycle
    # then create the non-editable labels...
    shares = (zmq_client.send_command("get_share_balance")).replace("[OK]","")
    cash = (zmq_client.send_command("get_cash_balance")).replace("[OK]","")
    share_balance = HMHighLabel(shares)
    cash_balance = HMHighLabel(cash)
    # ...then create the buttons which send the user's inputs to the server.
    btn_buy = HMActionButton('Buy Shares', zmq_client, server_cmd='buy',
                             widgets={'root_gui':      gui,
                                      'qty_form':      form_buy_qty,
                                      'price_form':    form_buy_price,
                                      'share_blc_lbl': share_balance,
                                      'cash_blc_lbl':  cash_balance})
    btn_sell = HMActionButton('Sell Shares', zmq_client, server_cmd='sell',
                              widgets={'root_gui':      gui,
                                       'qty_form':      form_sell_qty,
                                       'price_form':    form_sell_price,
                                       'share_blc_lbl': share_balance,
                                       'cash_blc_lbl':  cash_balance})
    btn_dep = HMActionButton('Deposit Cash', zmq_client,
                             server_cmd='deposit_cash',
                             widgets={'root_gui':      gui,
                                      'qty_form':      form_dep_amt,
                                      'price_form':    None,
                                      'share_blc_lbl': None,
                                      'cash_blc_lbl':  cash_balance})
    btn_shut_down_svr = HMShutdownButton('Close Server & Quit', zmq_client)

    row_num = 0
    grid.add(row_num, 1, HMLowLabel('Shares'))
    grid.add(row_num, 2, HMLowLabel('Cash'))
    row_num += 1
    grid.add(row_num, 0, HMHighLabel('Balances:'))
    grid.add(row_num, 1, share_balance)
    grid.add(row_num, 2, cash_balance)
    row_num += 1
    grid.add(row_num, 1, HMLowLabel('Amount'))
    row_num += 1
    grid.add(row_num, 0, btn_dep)
    grid.add(row_num, 1, form_dep_amt)
    row_num += 1
    grid.add(row_num, 1, HMLowLabel('Quantity'))
    grid.add(row_num, 2, HMLowLabel('Price per Share'))
    row_num += 1
    grid.add(row_num, 0, btn_buy)
    grid.add(row_num, 1, form_buy_qty)
    grid.add(row_num, 2, form_buy_price)
    row_num += 1
    grid.add(row_num, 1, HMLowLabel('Quantity'))
    grid.add(row_num, 2, HMLowLabel('Price per Share'))
    row_num += 1
    grid.add(row_num, 0, btn_sell)
    grid.add(row_num, 1, form_sell_qty)
    grid.add(row_num, 2, form_sell_price)
    row_num += 2
    grid.add(row_num, 1, btn_shut_down_svr)

    gui.add(grid)

    # Handle the possibility we are connecting to a server with an existing
    # cash or share balance.
    # - GET THE CURRENT SHARE BALANCE, AND DISPLAY IT IN THE GUI
    # - GET THE CURRENT CASH BALANCE, AND DISPLAY IT IN THE GUI
    # <YOUR CODE HERE>
    # Placing the initial focus on the deposit amount form seems to cause
    # intermittent stability problems on startup, so comment this out:
    # form_dep_amt.focus()

    # Last but not least, enter the main loop!
    pyglet.app.run()
Пример #29
0
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")
Пример #30
0

class ScrollBar(glooey.FillBar):
    custom_alignment = 'fill bottom'
    custom_padding = 0

    class Base(glooey.Background):
        custom_left = pyglet.image.load('resources\\purple.png')
        custom_center = pyglet.image.load('resources\\grey.png')
        custom_right = pyglet.image.load('resources\\purple.png')

    class Fill(glooey.Background):
        custom_center = pyglet.image.load('resources\\green.png')
        custom_horz_padding = 4


gui = glooey.Gui(window)  #create gui
pauseToggle = PauseButton()  #make a new pause button
scrollBar = ScrollBar()
label = glooey.Label('Drop your video to get started!')
label.set_font_size(50)
label.set_color('white')

#set up our label (instructions)
hbox = glooey.HBox()
gui.add(label)
hbox.pack(pauseToggle)
hbox.add(scrollBar)
#add our pausebutton to the hbox that we just made
#gui.add(hbox)
pyglet.app.run()