How to use the pyglet.window.Window function in pyglet

To help you get started, weā€™ve selected a few pyglet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kxgames / glooey / tests / containers / demo_frame.py View on Github external
import glooey
import run_demos

class TestFrame(glooey.Frame): #
    custom_alignment = 'fill'

    class Decoration(glooey.Background): #
        custom_center = pyglet.image.load('assets/64x64/green.png')

    class Box(glooey.Bin): #
        custom_padding = 16

class TestBackground(glooey.Background): #
    custom_center = pyglet.image.load('assets/64x64/orange.png')

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

@run_demos.on_space(gui) #
def test_image():
    frame = TestFrame()
    widget = TestBackground()
    frame.add(widget)
    gui.add(frame)
    yield "A orange tiled background in green tiled frame."

    frame.padding = 32
    yield "Pad around the frame."

    frame.box.padding = 48
    yield "Pad inside the frame."
github kxgames / glooey / tests / themes / golden / demo_round_button.py View on Github external
#!/usr/bin/env python3

import pyglet
import glooey.themes.golden as golden
import run_demos

colors = 'red', 'green', 'blue', 'grey'
icons = None, 'save', 'chat', 'zoom', 'yes', 'no', 'plus', 'minus', 'up', 'right', 'down', 'left'

window = pyglet.window.Window()
gui = golden.Gui(window)
button = golden.RoundButton()
gui.add(button)

@run_demos.on_space(gui) #
def test_round_button():
    for color in colors:
        button.color = color
        for icon in icons:
            button.icon = icon
            yield f"{color} button with {icon or 'no'} icon."


pyglet.app.run()
github pyglet / pyglet / tests / interactive / window / WINDOW_CAPTION.py View on Github external
def test_caption(self):
        w1 = window.Window(400, 200, resizable=True)
        w2 = window.Window(400, 200, resizable=True)
        count = 1
        w1.set_caption('Window caption %d' % count)
        w2.set_caption(u'\u00bfHabla espa\u00f1ol?')
        last_time = time.time()
        while not (w1.has_exit or w2.has_exit):
            if time.time() - last_time > 1:
                count += 1
                w1.set_caption('Window caption %d' % count)
                last_time = time.time()
            w1.dispatch_events()
            w2.dispatch_events()
        w1.close()
        w2.close()
github kxgames / glooey / tests / images / demo_image.py View on Github external
#!/usr/bin/env python3

import pyglet
import glooey
import run_demos

window = pyglet.window.Window()
gui = glooey.Gui(window)
widget = glooey.Image()
gui.add(widget)

@run_demos.on_space(gui) #
def test_image():
    widget.image = pyglet.image.load('assets/misc/star_5.png')
    yield "Show a green star."

    widget.image = pyglet.image.load('assets/misc/star_7.png')
    yield "Show a orange star."

pyglet.app.run()
github kxgames / glooey / tests / themes / golden / demo_basic_button.py View on Github external
#!/usr/bin/env python3

import pyglet
import run_demos
import glooey.themes.golden as golden

window = pyglet.window.Window()
gui = golden.Gui(window)
button = golden.BasicButton('Lorem Ipsum')
gui.add(button)

pyglet.app.run()
github visionegg / visionegg / visionegg / VisionEgg / Core.py View on Github external
# Attempt to synchronize buffer swapping with vertical sync
        if cp.sync_swap:
            sync_success = VisionEgg.PlatformDependent.sync_swap_with_vbl_pre_gl_init()
        '''
        # Initialize pygame stuff
        if sys.platform == "darwin": # bug in Mac OS X version of pygame
            pygame.init()
        pygame.display.init()
        '''
        if cp.frameless:
            style = pyglet.window.Window.WINDOW_STYLE_BORDERLESS
        else:
            style = pyglet.window.Window.WINDOW_STYLE_DEFAULT

        self.win = pyglet.window.Window(width=cp.size[0],
                                        height=cp.size[1],
                                        caption='Vision Egg',
                                        style=style,
                                        vsync=cp.double_buffer,
                                        screen=self.screen)

        self.win.set_fullscreen(cp.fullscreen) # fullscreen can't be set with width and height in constructor

        ## TODO: figure out pyglet eq'v of gl_set_attribute

        '''
        if hasattr(pygame.display, "gl_set_attribute"):
            pygame.display.gl_set_attribute(pygame.locals.GL_RED_SIZE, cp.red_bits)
            pygame.display.gl_set_attribute(pygame.locals.GL_GREEN_SIZE, cp.green_bits)
            pygame.display.gl_set_attribute(pygame.locals.GL_BLUE_SIZE, cp.blue_bits)
            pygame.display.gl_set_attribute(pygame.locals.GL_ALPHA_SIZE, cp.alpha_bits)
github jaredly / babytux / app.py View on Github external
def __init__(self):
        self.world = World()
        self.win = pyglet.window.Window(fullscreen=True, vsync=True)
        self.win.set_exclusive_keyboard()

        for i in dir(self):
            if i.startswith('on_'):
                setattr(self.win, i, getattr(self, i))

        self.camera = Camera(self.win, zoom=100.0)
        self.hud = Hud(self.win)
        clock.set_fps_limit(60)
github vojtechruz / pyladies-7 / zaverecny-projekt / snake / 5_snake_moving.py View on Github external
def draw_snake():
    # Clear contents of the window, delete everything
    window.clear()
    # Draw snake.
    # The position is lower-left corner if not specified otherwise
    snake_sprite.draw()

def tick(time_elapsed):
   # Every time this is called, move the snake
   # one pixel to the right
   snake_sprite.x = snake_sprite.x+1

pyglet.clock.schedule_interval(tick, 1/30)

window = pyglet.window.Window()
# Every time we need to redraw (for example when minimalizing and then
# maximizing the app window), function draw_snake will be called
window.push_handlers(on_draw=draw_snake)
pyglet.app.run()
github tisnik / presentations / pyglet / 86_custom_and_standard_cursors.py View on Github external
@window.event
def on_draw():
    window.clear()


cursors = {
    pyglet.window.key.F1: pyglet.window.Window.CURSOR_DEFAULT,
    pyglet.window.key.F2: pyglet.window.Window.CURSOR_HAND,
    pyglet.window.key.F3: pyglet.window.Window.CURSOR_HELP,
    pyglet.window.key.F4: pyglet.window.Window.CURSOR_SIZE,
    pyglet.window.key.F5: pyglet.window.Window.CURSOR_SIZE_UP,
    pyglet.window.key.F6: pyglet.window.Window.CURSOR_SIZE_DOWN,
    pyglet.window.key.F7: pyglet.window.Window.CURSOR_SIZE_LEFT,
    pyglet.window.key.F8: pyglet.window.Window.CURSOR_SIZE_RIGHT,
    pyglet.window.key.F9: pyglet.window.Window.CURSOR_WAIT,
    pyglet.window.key.F10: pyglet.window.Window.CURSOR_NO
}


@window.event
def on_key_press(symbol, modifiers):
    if symbol == pyglet.window.key.SPACE:
        cursor = custom_cursor
    else:
        cursor_type = cursors.get(symbol)
        cursor = window.get_system_mouse_cursor(cursor_type)
    window.set_mouse_cursor(cursor)


pyglet.app.run()
github ubuntunux / PyEngine3D / App / GameBackend.py View on Github external
def __init__(self, core_manager):
        GameBackend.__init__(self, core_manager)

        os.environ['PYGLET_DEBUG_GL'] = '1'
        config = Config(double_buffer=True, )
        # Ubuntu Vsync Off : NVidia X Server Setting -> OpenGL Setting -> Sync To VBlank ( Off )
        self.window = pyglet.window.Window(width=512, height=512, config=config, resizable=True, vsync=False)

        # for debbug
        # self.window.push_handlers(pyglet.window.event.WindowEventLogger())

        # show system info
        # pyglet.info.dump()

        # listen for draw and resize events
        self.window.push_handlers(
            on_draw=self.on_draw,
            on_resize=self.on_resize,
            # on_key_press=self.on_key_press,
            # on_key_release=self.on_key_release
        )

        self.valid = True