示例#1
0
 def _do_flash():
     platform = window.get_platform()
     display = platform.get_default_display()
     x_display = display._display
    
     gamma_old = XF86VidModeGamma()
     XF86VidModeGetGamma(x_display, 0, gamma_old)
     
     gamma_old = XF86VidModeGamma()
     XF86VidModeGetGamma(x_display, 0, gamma_old)  
 
     intensities = [ 7.1, 8.1, 9.9]
     #intensities = [ 0.9, 0.6, 0]
 
     def set_intensity(x_display, inten):
         gamma = XF86VidModeGamma(inten, inten, inten)
         XF86VidModeSetGamma(x_display, 0, gamma)
         XF86VidModeGetGamma(x_display, 0, gamma)  
 
     for inten in sorted(intensities):
         set_intensity(x_display, inten)
         time.sleep(0.05)
             
     for inten in sorted(intensities, reverse=True):
         set_intensity(x_display, inten)
         time.sleep(0.05)
     
     XF86VidModeSetGamma(x_display, 0, gamma_old)
     XF86VidModeGetGamma(x_display, 0, gamma_old)
示例#2
0
    def _do_flash():
        platform = window.get_platform()
        display = platform.get_default_display()
        x_display = display._display

        gamma_old = XF86VidModeGamma()
        XF86VidModeGetGamma(x_display, 0, gamma_old)

        gamma_old = XF86VidModeGamma()
        XF86VidModeGetGamma(x_display, 0, gamma_old)

        intensities = [7.1, 8.1, 9.9]

        #intensities = [ 0.9, 0.6, 0]

        def set_intensity(x_display, inten):
            gamma = XF86VidModeGamma(inten, inten, inten)
            XF86VidModeSetGamma(x_display, 0, gamma)
            XF86VidModeGetGamma(x_display, 0, gamma)

        for inten in sorted(intensities):
            set_intensity(x_display, inten)
            time.sleep(0.05)

        for inten in sorted(intensities, reverse=True):
            set_intensity(x_display, inten)
            time.sleep(0.05)

        XF86VidModeSetGamma(x_display, 0, gamma_old)
        XF86VidModeGetGamma(x_display, 0, gamma_old)
示例#3
0
    def __init__(self, fullscreen=False,
                 screen=None,
                 width=None, height=None,
                 visible=False, vsync=False, fps=60,
                 show_fps=False):
        platform = get_platform()
        display = platform.get_default_display()
        screens = display.get_screens()
        screen=screens[screen]
        self.window = MyWindow(fullscreen=fullscreen, screen=screen,
            width=width, height=height, visible=visible,
            vsync=vsync
        )
        # glClearColor(0., 0., 0., 0.0)
        # glEnable(GL_BLEND)
        # glEnable(GL_LINE_SMOOTH)
        # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        self.clockDisplay = clock.ClockDisplay(color=(1., 1., 1., .8)) if show_fps \
                            else None
        self.paused = False
        clock.set_fps_limit(fps)

        self.window.on_draw = self.on_draw
        self.window.on_key_press = self.on_key_press
        self.window.on_mouse_drag = self.on_mouse_drag
        self.window.on_mouse_press = self.on_mouse_press
示例#4
0
    def get_text(self):
        display = window.get_platform().get_default_display()._display
        owner = xlib.XGetSelectionOwner(display, XA_PRIMARY)
        if not owner: return ''

        # XXX xa_utf8_string
        xlib.XConvertSelection(display, XA_PRIMARY, XA_STRING, 0, owner,
            CurrentTime)
        xlib.XFlush(display)

        # determine what's in the selection buffer
        type = xlib.Atom()
        format = c_int()
        len = c_ulong()
        bytes_left = c_ulong()
        data = POINTER(c_ubyte)()
        xlib.XGetWindowProperty(display, owner, XA_STRING, 0, 0, 0,
            AnyPropertyType, byref(type), byref(format), byref(len),
            byref(bytes_left), byref(data))

        length = int(bytes_left.value)
        if not length:
            return ''

        # get the contents
        dummy = c_ulong()
        xlib.XGetWindowProperty(display, owner, XA_STRING, 0,
             length, 0, AnyPropertyType, byref(type), byref(format),
             byref(len), byref(dummy), byref(data))
        s = ''.join(chr(c) for c in data[:len.value])
        xlib.XFree(data)
        return s
示例#5
0
    def get_text(self):
        display = window.get_platform().get_default_display()._display
        owner = xlib.XGetSelectionOwner(display, XA_PRIMARY)
        if not owner:
            return ''

        # TODO: xa_utf8_string
        xlib.XConvertSelection(display, XA_PRIMARY, XA_STRING, 0, owner,
                               CurrentTime)
        xlib.XFlush(display)

        # determine what's in the selection buffer
        type = xlib.Atom()
        format = c_int()
        len = c_ulong()
        bytes_left = c_ulong()
        data = POINTER(c_ubyte)()
        xlib.XGetWindowProperty(display, owner, XA_STRING, 0, 0, 0,
                                AnyPropertyType, byref(type), byref(format),
                                byref(len), byref(bytes_left), byref(data))

        length = int(bytes_left.value)
        if not length:
            return ''

        # get the contents
        dummy = c_ulong()
        xlib.XGetWindowProperty(display, owner, XA_STRING, 0, length, 0,
                                AnyPropertyType, byref(type), byref(format),
                                byref(len), byref(dummy), byref(data))
        s = ''.join(chr(c) for c in data[:len.value])
        xlib.XFree(data)
        return s
示例#6
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 pos=None,
                 size=None,
                 config=None,
                 fullscreen=False,
                 resizable=True,
                 vsync=True,
                 **traits):
        """ **parent** is an unneeded argument with the pyglet backend, but
        we need to preserve compatibility with other AbstractWindow
        subclasses.
        """
        # TODO: Fix fact that other backends' Window classes use positional
        # arguments

        self.control = None
        AbstractWindow.__init__(self, **traits)
        self._mouse_captured = False

        # Due to wx wonkiness, we don't reliably get cursor position from
        # a wx KeyEvent.  Thus, we manually keep track of when we last saw
        # the mouse and use that information instead.  These coordinates are
        # in the wx coordinate space, i.e. pre-self._flip_y().
        self._last_mouse_pos = (0, 0)

        # Try to get antialiasing, both for quality rendering and for
        # reproducible results. For example, line widths are measured in the
        # X or Y directions rather than perpendicular to the line unless if
        # antialiasing is enabled.
        display = window.get_platform().get_default_display()
        screen = display.get_default_screen()
        if config is None:
            if self.enable_antialias:
                template_config = gl.Config(double_buffer=True,
                                            sample_buffers=True,
                                            samples=4)
            else:
                template_config = gl.Config(double_buffer=False)
            try:
                config = screen.get_best_config(template_config)
            except window.NoSuchConfigException:
                # Rats. No antialiasing.
                config = screen.get_best_config(gl.Config(double_buffer=True))
        # Create the underlying control.
        kwds = dict(config=config,
                    fullscreen=fullscreen,
                    resizable=resizable,
                    vsync=vsync)
        if size is not None and not fullscreen:
            kwds['width'], kwds['height'] = size
        self.control = PygletWindow(enable_window=self, **kwds)
        if pos is not None:
            self.control.set_location(*pos)

        return
示例#7
0
 def test_multiple_screen(self):
     display = window.get_platform().get_default_display()
     self.screens = display.get_screens()
     for i in range(len(self.screens)):
         self.index = i
         self.open_next_window()
         self.on_expose()
         while not self.w.has_exit:
             self.w.dispatch_events()
         self.w.close()
 def test_multiple_screen(self):
     display = window.get_platform().get_default_display()
     self.screens = display.get_screens()
     for i in range(len(self.screens)):
         self.index = i
         self.open_next_window()
         self.on_expose()
         while not self.w.has_exit:
             self.w.dispatch_events()
         self.w.close()
示例#9
0
 def test_multiple_screen(self):
     display = window.get_platform().get_default_display()
     self.screens = display.get_screens()
     for i in range(len(self.screens)):
         self.index = i
         self.open_next_window()
         try:
             self.on_expose()
             self.w.dispatch_events()
             self.user_verify(
                 'Do you see a {} full screen window on screen {}?'.format(
                     self.colour_names[i], i + 1))
         finally:
             self.w.close()
示例#10
0
def get_window(options):
    vsync = (options['vsync'] != '0')
    if options['wmode'] == 'windowed':
        return Window(1280, 720, vsync=vsync,
                      style=Window.WINDOW_STYLE_DEFAULT)
    elif options['wmode'] == 'windowed_fs':
        defa = get_platform() .get_default_display() .get_default_screen()
        w = defa.width
        h = defa.height
        return Window(w, h, vsync=vsync, style=Window.WINDOW_STYLE_BORDERLESS)
    elif options['wmode'] == 'fullscreen':
        return Window(vsync=vsync, fullscreen=True)
    else:
        return Window(1280, 720, vsync=vsync,
                      style=Window.WINDOW_STYLE_DEFAULT)
示例#11
0
文件: window.py 项目: GaZ3ll3/enable
    def __init__(self, parent=None, id=-1, pos=None, size=None, config=None,
        fullscreen=False, resizable=True, vsync=True, **traits):
        """ **parent** is an unneeded argument with the pyglet backend, but
        we need to preserve compatibility with other AbstractWindow
        subclasses.
        """
        # TODO: Fix fact that other backends' Window classes use positional
        # arguments

        self.control = None
        AbstractWindow.__init__(self, **traits)
        self._mouse_captured = False

        # Due to wx wonkiness, we don't reliably get cursor position from
        # a wx KeyEvent.  Thus, we manually keep track of when we last saw
        # the mouse and use that information instead.  These coordinates are
        # in the wx coordinate space, i.e. pre-self._flip_y().
        self._last_mouse_pos = (0, 0)

        # Try to get antialiasing, both for quality rendering and for
        # reproducible results. For example, line widths are measured in the
        # X or Y directions rather than perpendicular to the line unless if
        # antialiasing is enabled.
        display = window.get_platform().get_default_display()
        screen = display.get_default_screen()
        if config is None:
            if self.enable_antialias:
                template_config = gl.Config(double_buffer=True, sample_buffers=True,
                    samples=4)
            else:
                template_config = gl.Config(double_buffer=False)
            try:
                config = screen.get_best_config(template_config)
            except window.NoSuchConfigException:
                # Rats. No antialiasing.
                config = screen.get_best_config(gl.Config(double_buffer=True))
        # Create the underlying control.
        kwds = dict(config=config, fullscreen=fullscreen,
            resizable=resizable, vsync=vsync)
        if size is not None and not fullscreen:
            kwds['width'], kwds['height'] = size
        self.control = PygletWindow(enable_window=self, **kwds)
        if pos is not None:
            self.control.set_location(*pos)

        return
示例#12
0
 def __init__(self, window_config=None, fullscreen=False):
     super().__init__(
         width=window_config['width'],
         height=window_config['height'],
         vsync=False,
         fullscreen=fullscreen,
         screen=window.get_platform().get_default_display().get_screens()
         [2])
     self.__config = window_config
     self.clock = clock.get_default()
     self.fps_display = pyglet.window.FPSDisplay(self)
     self.fps_display.label = pyglet.text.Label(font_size=18,
                                                x=14,
                                                y=35,
                                                anchor_x='left',
                                                anchor_y='bottom')
     self._set_fps(window_config['fps'])
     self.fps_display.update()
     self.reset_keys()
     self.mouse_pressed = False
     self.mouse = (0, 0)
     self.label = None
     self.particle_batch = None
示例#13
0
文件: cfg.py 项目: msarch/py
Vel = namedtuple('Vel', 'vx vy av')
Vel2 = namedtuple('Speed1', 'speed heading')
Vel3 = namedtuple('Speed2', 'x y angle speed')
Vel4 = namedtuple('Peg2', 'speed head_to')  # or use Peg3 ??
Vel5 = namedtuple('Peg3', 'speed path')  # target

Point = namedtuple('Point', 'x y')
AABB = namedtuple('AABB', 'lox loy hix hiy')

ORIGIN = Point(0.0, 0.0)
IDLE = Vel(0.0, 0.0, 0.0)
DOCKED = Peg(0.0, 0.0, 0.0, 0.0)
BACK = Peg(0.0, 0.0, -0.8, 0.0)

#--- DISPLAY INFO -------------------------------------------------------------
_screen = get_platform().get_default_display().get_default_screen()
WIDTH, HEIGHT = _screen.width * 1.0, _screen.height * 1.0
ASPECT = WIDTH / HEIGHT
CENTX, CENTY = WIDTH * 0.5, HEIGHT * 0.5
SCREEN = AABB(-CENTX, -CENTY, CENTX, CENTY)

##---TRANSFORMATION MATRIXES---------------------------------------------------
MAT_id = [1, 0, 0, 0, 1, 0, 0, 0, 1]  # Identity matrix
MAT_X_flip = [1, 0, 0, 0, -1, 0, 0, 0, 1]  # X axi symetry matrix
MAT_Y_flip = [-1, 0, 0, 0, 1, 0, 0, 0, 1]  # Y axi symetry matrix

#--- COLORS -------------------------------------------------------------------
Color = namedtuple('Color', 'r g b a')

orange = Color(255, 127, 0, 255)
white = Color(255, 255, 255, 255)
示例#14
0
 def create_context(self, share):
     display = window.get_platform().get_default_display()
     screen = display.get_default_screen()
     config = screen.get_best_config()
     return config.create_context(share)
示例#15
0
文件: __init__.py 项目: msarch/py
#--- Imports ------------------------------------------------------------------
from pyglet.window import get_platform
from color import *
from collections import namedtuple

#--- VARS ---------------------------------------------------------------------
#--- CONSTANTS ----------------------------------------------------------------

Peg = namedtuple('Peg','x y z angle')
Vel = namedtuple('Vel','vx vy av')
Vel2 = namedtuple('Speed1', 'speed heading')
Vel3 = namedtuple('Speed2', 'x y angle speed')
Vel4 = namedtuple('Peg2', 'speed head_to') # or use Peg3 ??
Vel5 = namedtuple('Peg3', 'speed path') # target

Point  = namedtuple('Point', 'x y')
AABB = namedtuple('AABB', 'lox loy hix hiy')

ORIGIN = Point(0.0, 0.0)
IDLE   = Vel(0.0, 0.0, 0.0)
DOCKED = Peg(0.0, 0.0, 0.0, 0.0)
BACK = Peg(0.0, 0.0, -0.8, 0.0)
#--- DISPLAY INFO -------------------------------------------------------------
_screen = get_platform().get_default_display().get_default_screen()
WIDTH, HEIGHT = _screen.width*1.0 ,_screen.height*1.0
ASPECT = WIDTH / HEIGHT
CENTX, CENTY = WIDTH*0.5, HEIGHT*0.5
SCREEN = (-CENTX, -CENTY, CENTX, CENTY)

示例#16
0
def get_center_coordinates(window_width,window_height):
	screen = window.get_platform().get_default_display().get_default_screen()
	x = (screen.width*0.5)-(window_width*0.5)
	y = (screen.height*0.5)-(window_height*0.5)
	return int(x),int(y)
示例#17
0
 def create_context(self, share):
     display = window.get_platform().get_default_display()
     screen = display.get_default_screen()
     config = screen.get_best_config()
     return config.create_context(share)
示例#18
0
import pyglet
import time

from math import sqrt, sin, cos, acos, pi, radians

from pyglet.window import get_platform

from widgets.event_window import EventWindow
from game_objects.projectile import Projectile

platform = get_platform()
display = platform.get_default_display()
screen = display.get_default_screen()
window = pyglet.window.Window(width=screen.width, height=screen.height)
window.maximize()
projectile = Projectile(src='images/candy_cane.png')
projectile.move(window.width / 2, window.height / 2 + 100)
print(projectile.x, projectile.y)
center_x, center_y = window.width / 2, window.height / 2
radius = sqrt((projectile.x - center_x)**2 + (projectile.y - center_y)**2)
initial_x, initial_y = center_x + radius, center_y
start = time.time()
acceleration = 1


@window.event
def on_draw():
    window.clear()
    projectile.draw()

示例#19
0
def get_center_coordinates(window_width, window_height):
    screen = window.get_platform().get_default_display().get_default_screen()
    x = (screen.width * 0.5) - (window_width * 0.5)
    y = (screen.height * 0.5) - (window_height * 0.5)
    return int(x), int(y)