Exemplo n.º 1
0
 def _exit(self, need_sync):
     assert self.depth >= 0
     self.depth -= 1
     if self.depth == 0 and need_sync:
         _gdk.flush()
     # This is a Xlib error constant (Success == 0)
     error = _gdk.error_trap_pop()
     if error:
         if error in _exc_for_error:
             raise _exc_for_error[error](error)
         else:
             raise XError, error
Exemplo n.º 2
0
  def Adjust(self, ThrdIx, Time, Value):
    gdk.threads_enter()
    gc = self.window.new_gc()
    lb = self.window.new_gc()
    cm = gc.get_colormap()

    OldValue = self.ThrdInfo[ThrdIx][1]
    if OldValue < Value:
      color = cm.alloc_color(*index2rgb(ThrdIx))
      base = 75 + OldValue
    else:
      color = self.style.bg[0]
      base = 75 + Value
    #end if
    gc.set_foreground(color)
    self.window.draw_rectangle(gc, True , base , (2 * ThrdIx + 1) * RowHght , abs(Value - OldValue)  , RowHght)
    self.layout.set_text("%8d" % (Time,))
    self.window.begin_paint_rect((0, (2 * ThrdIx + 1) * RowHght, 75 , RowHght))
    self.window.draw_layout(lb, 5 , (2 * ThrdIx + 1) * RowHght + self.TxtPad , self.layout)
    self.window.end_paint()
    gdk.flush()
    gdk.threads_leave()
    self.ThrdInfo[ThrdIx] = [Time, Value]
Exemplo n.º 3
0
def gdk_window_settings(win,
                        x=None,
                        y=None,
                        width=None,
                        height=None,
                        decoration=None,
                        maximized=False,
                        centered=False):
    '''
    Applies appeareance and position modifications to the Window identified by win    
    '''
    # Screen dimensions
    scr_width = gdk.screen_width()
    scr_height = gdk.screen_height() - BOTTOM_BAR_HEIGHT

    # Window dimensions and position
    old_x, old_y = win.get_root_origin()
    old_width, old_height = win.get_geometry()[2:4]

    # Sort out the decorations
    if decoration is not None:
        if decoration is False:
            # Resize if the window was decorated before
            if _is_decorated(win):
                dw, dh = _get_decoration_size(win)
                old_width += dw
                old_height += dh

                win.set_decorations(0)
                gdk.window_process_all_updates()
                gdk.flush()
        else:
            # Resize if the window was not decorated before
            if not _is_decorated(win):
                win.set_decorations(1)
                gdk.flush()

                dw, dh = _get_decoration_size(win)
                old_width -= dw
                old_height -= dh

    # Resizing is irrelevant when maximizing, so just return afterwards
    if maximized:
        win.maximize()
        gdk.window_process_all_updates()
        gdk.flush()
        return

    # Initialize the target values
    new_x, new_y, new_width, new_height = old_x, old_y, old_width, old_height

    # Window position
    if x is not None:
        if x <= 1:
            new_x = scr_width * x
        else:
            new_x = x

    if y is not None:
        if y <= 1:
            new_y = scr_height * y
        else:
            new_y = y

    # Window dimensions
    if width is not None:
        if width <= 1:
            new_width = scr_width * width
        else:
            new_width = width

        if decoration is True:
            new_width -= _get_decoration_size(win)[0]

    if height is not None:
        if height <= 1:
            new_height = scr_height * height
        else:
            new_height = height

        if decoration is True:
            new_height -= _get_decoration_size(win)[1]

    # Should the window be centered?
    if centered:
        dec_w, dec_h = _get_decoration_size(win)
        new_x = (scr_width - new_width - dec_w) / 2
        new_y = (scr_height - new_height - dec_h) / 2

    # Do all the resizing at once
    win.move_resize(int(new_x), int(new_y), int(new_width), int(new_height))
    gdk.window_process_all_updates()
    gdk.flush()
Exemplo n.º 4
0
 def flip(self):
     self.window.window.draw_drawable(self.gc, self.offscreen,
                                      0, 0, 0, 0, self.width, self.height)
     gdk.flush()
     self.events_poll()
Exemplo n.º 5
0
def gdk_window_settings(win, x=None, y=None, width=None, height=None,
                        decoration=None, maximized=False, centered=False):
    '''
    Applies appeareance and position modifications to the Window identified by win    
    '''
    # Screen dimensions
    scr_width = gdk.screen_width()
    scr_height = gdk.screen_height() - BOTTOM_BAR_HEIGHT

    # Window dimensions and position
    old_x, old_y = win.get_root_origin()
    old_width, old_height = win.get_geometry()[2:4]

    # Sort out the decorations
    if decoration is not None:
        if decoration is False:
            # Resize if the window was decorated before
            if _is_decorated(win):
                dw, dh = _get_decoration_size(win)
                old_width += dw
                old_height += dh

                win.set_decorations(0)
                gdk.window_process_all_updates()
                gdk.flush()
        else:
            # Resize if the window was not decorated before
            if not _is_decorated(win):
                win.set_decorations(1)
                gdk.flush()

                dw, dh = _get_decoration_size(win)
                old_width -= dw
                old_height -= dh

    # Resizing is irrelevant when maximizing, so just return afterwards
    if maximized:
        win.maximize()
        gdk.window_process_all_updates()
        gdk.flush()
        return

    # Initialize the target values
    new_x, new_y, new_width, new_height = old_x, old_y, old_width, old_height

    # Window position
    if x is not None:
        if x <= 1:
            new_x = scr_width * x
        else:
            new_x = x

    if y is not None:
        if y <= 1:
            new_y = scr_height * y
        else:
            new_y = y

    # Window dimensions
    if width is not None:
        if width <= 1:
            new_width = scr_width * width
        else:
            new_width = width

        if decoration is True:
            new_width -= _get_decoration_size(win)[0]

    if height is not None:
        if height <= 1:
            new_height = scr_height * height
        else:
            new_height = height

        if decoration is True:
            new_height -= _get_decoration_size(win)[1]

    # Should the window be centered?
    if centered:
        dec_w, dec_h = _get_decoration_size(win)
        new_x = (scr_width - new_width - dec_w) / 2
        new_y = (scr_height - new_height - dec_h) / 2

    # Do all the resizing at once
    win.move_resize(int(new_x), int(new_y), int(new_width), int(new_height))
    gdk.window_process_all_updates()
    gdk.flush()