def setFullscreen(self, state): ''' If **state** is True, the set_fullscreen() method requests the window manager to place the window in the fullscreen state. If **state** is False the set_fullscreen() method requests the window manager to toggle off the fullscreen state for the window. Note that in any case, you shouldn't not assume the window state is definitely set afterward, because other entities (e.g. the user or window manager) could fullscreen/unfullscreen it again, and not all window managers honor requests to fullscreen windows. :param bool state: Fullscreen state to be set. ''' if self._fullscreen == state: return if state == True: glut.glutSetWindow( self._id ) self._saved_width = glut.glutGet(glut.GLUT_WINDOW_WIDTH) self._saved_height = glut.glutGet(glut.GLUT_WINDOW_HEIGHT) self._saved_x = glut.glutGet(glut.GLUT_WINDOW_X) self._saved_y = glut.glutGet(glut.GLUT_WINDOW_Y) self._fullscreen = True glut.glutFullScreen() else: self._fullscreen = False glut.glutSetWindow( self._id ) glut.glutReshapeWindow(self._saved_width, self._saved_height) glut.glutPositionWindow( self._saved_x, self._saved_y ) glut.glutSetWindowTitle( self._title )
def __init__(self, width=None, height=None, caption=None, visible=True, fullscreen=False): event.EventDispatcher.__init__(self) self._event_queue = [] if width and width > 0: self._width = width else: self._width = Window._default_width if height and height > 0: self._height = height else: self._height = Window._default_height if caption is None: caption = sys.argv[0] self._caption = caption self._saved_width = self._width self._saved_height = self._height if _window is None: glut.glutInit(sys.argv) glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH) self._window_id = glut.glutCreateWindow(self._caption) glut.glutDisplayFunc(self._display) glut.glutReshapeFunc(self._reshape) glut.glutKeyboardFunc(self._keyboard) glut.glutKeyboardUpFunc(self._keyboard_up) glut.glutMouseFunc(self._mouse) glut.glutMotionFunc(self._motion) glut.glutPassiveMotionFunc(self._passive_motion) glut.glutVisibilityFunc(self._visibility) glut.glutEntryFunc(self._entry) glut.glutSpecialFunc(self._special) glut.glutSpecialUpFunc(self._special_up) gl.glClearColor(0,0,0,0) self._visible = visible self._time = glut.glutGet(glut.GLUT_ELAPSED_TIME) if not visible: glut.glutHideWindow() else: glut.glutShowWindow() self.set_size(self._width, self._height) screen_width = glut.glutGet(glut.GLUT_SCREEN_WIDTH) screen_height= glut.glutGet(glut.GLUT_SCREEN_HEIGHT) glut.glutPositionWindow((screen_width-self._width)//2, (screen_height-self._height)//2) self.fullscreen = fullscreen
def setPosition(self, x, y): ''' The set_position() method requests the window manager to move the window to the specified coordinates as if the user had done so, obeying geometry constraints. Note you shouldn't assume the new window position is definitely the requested one afterward, because other entities (e.g. the user or window manager) could change it position again, and not all window managers honor requests to move windows. :param integer x: The x coordinate in pixels to move the window to :param integer y: The y coordinate in pixels to move the window to ''' glut.glutPositionWindow( x, y )
def set_window_move(self, x, y): """ Изменение положения текущего окна (int, int) -> None Аргументы: x - Перемещение окна по оси X y - Перемещение окна по оси Y Возвращает: None """ # Проверка аргументов if type(x) is not int or x < 0 or type(y) is not int or y < 0: return None self.move_window_x = x # Перемещение окна по оси X self.move_window_y = y # Перемещение окна по оси Y GLUT.glutPositionWindow(self.move_window_x, self.move_window_y) # Положение окна
def set_position(self, x, y): glut.glutPositionWindow(x, y)
def _vispy_set_position(self, x, y): # Set position of the widget or window. May have no effect for widgets glut.glutSetWindow(self._id) glut.glutPositionWindow(x, y)
def __init__(self, size=None, position=None, title=None, fullscreen=False,enableAlpha=True,pointSize=2): ''' Constructor ''' self._mouse_x = 0 self._mouse_y = 0 self._button = mouse.NONE self._modifiers = None self._motionEventCounter=0 self._time = None self._timer_stack = [] self._timer_date = [] self._title = title or "PyGLer" # FIXME: get default name from a central location self._fullscreen = -1 self.dragSensitivity = 5 # Is there any glut loop already running ? if glut.glutGetWindow( ) == 0: glut.glutInit() glut.glutInitDisplayMode( glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH ) self._interactive = False else: self._interactive = True self._id = glut.glutCreateWindow( self._title ) glut.glutShowWindow() glut.glutDisplayFunc( self.redraw ) glut.glutReshapeFunc( self._reshape ) glut.glutKeyboardFunc( self._keyboard ) glut.glutKeyboardUpFunc( self._keyboard_up ) glut.glutMouseFunc( self._mouse ) glut.glutMotionFunc( self._motion ) glut.glutPassiveMotionFunc( self._passive_motion ) glut.glutVisibilityFunc( self._visibility ) glut.glutEntryFunc( self._entry ) glut.glutSpecialFunc( self._special ) glut.glutSpecialUpFunc( self._special_up ) GL.glEnable(GL.GL_DEPTH_TEST) GL.glEnable(GL.GL_BLEND) if enableAlpha: GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); GL.glPolygonOffset(1, 1); GL.glEnable(GL.GL_POLYGON_OFFSET_FILL); GL.glPointSize(pointSize) GL.glEnable(GL.GL_PROGRAM_POINT_SIZE) if size is not None: width, height = size glut.glutReshapeWindow( width, height ) width = glut.glutGet( glut.GLUT_WINDOW_WIDTH ) height= glut.glutGet( glut.GLUT_WINDOW_HEIGHT ) self._width = width self._height = height if position is not None: x,y = position glut.glutPositionWindow( x, y ) x = glut.glutGet( glut.GLUT_WINDOW_X ) y = glut.glutGet( glut.GLUT_WINDOW_X ) self._x, self._y = x, y # These ones will be used when exiting fullscreen self._saved_width = self._width self._saved_height = self._height self._saved_x = self._x self._saved_y = self._y self._time = glut.glutGet( glut.GLUT_ELAPSED_TIME ) self._fullscreen = fullscreen if fullscreen: self.set_fullscreen(True)
def __init__( self, size=None, position=None, title=None, fullscreen=False): ''' Create a window with given sise, position and title. :param (int,int) size: Initial window size as (width,height) in pixels. :param (int,int) position: Initial window position. Depending on the window-manager, the position request may or may not be honored. :param string title: The title of the window. ''' global _window window.Window.__init__( self, size, position, title ) self._mouse_x = 0 self._mouse_y = 0 self._button = mouse.NONE self._modifiers = None self._time = None self._timer_stack = [] self._timer_date = [] self._title = title or sys.argv[0] self._fullscreen = -1 # Is there any glut loop already running ? if glut.glutGetWindow( ) == 0: glut.glutInit( sys.argv ) glut.glutInitDisplayMode( glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH ) self._interactive = False else: self._interactive = True self._id = glut.glutCreateWindow( self._title ) glut.glutShowWindow( ) glut.glutDisplayFunc( self._display ) glut.glutReshapeFunc( self._reshape ) glut.glutKeyboardFunc( self._keyboard ) glut.glutKeyboardUpFunc( self._keyboard_up ) glut.glutMouseFunc( self._mouse ) glut.glutMotionFunc( self._motion ) glut.glutPassiveMotionFunc( self._passive_motion ) glut.glutVisibilityFunc( self._visibility ) glut.glutEntryFunc( self._entry ) glut.glutSpecialFunc( self._special ) glut.glutSpecialUpFunc( self._special_up ) if size is not None: width, height = size glut.glutReshapeWindow( width, height ) width = glut.glutGet( glut.GLUT_WINDOW_WIDTH ) height= glut.glutGet( glut.GLUT_WINDOW_HEIGHT ) self._width = width self._height = height if position is not None: x,y = position glut.glutPositionWindow( x, y ) #else: # screen_width = glut.glutGet( glut.GLUT_SCREEN_WIDTH ) # screen_height= glut.glutGet( glut.GLUT_SCREEN_HEIGHT ) # x = (screen_width - self._size[0]) / 2 # y = (screen_width - self._size[0]) / 2 # glut.glutPositionWindow( x, y ) x = glut.glutGet( glut.GLUT_WINDOW_X ) y = glut.glutGet( glut.GLUT_WINDOW_X ) self._x, self._y = x, y # These ones will be used when exiting fullscreen self._saved_width = self._width self._saved_height = self._height self._saved_x = self._x self._saved_y = self._y self._time = glut.glutGet( glut.GLUT_ELAPSED_TIME ) _window = self self._fullscreen = False if fullscreen: self.set_fullscreen(True)