Esempio n. 1
0
    def __init__(self, aspect=True, enlarge=False,
            interp=gtk.gdk.INTERP_NEAREST, backcolor=None, max=(1600,1200)):
        """Construct a ResizableImage control.

        Parameters:
        aspect -- Maintain aspect ratio?
        enlarge -- Allow image to be scaled up?
        interp -- Method of interpolation to be used.
        backcolor -- Tuple (R, G, B) with values ranging from 0 to 1,
            or None for transparent.
        max -- Max dimensions for internal image (width, height).

        """
        DrawingArea.__init__(self)
        self.pixbuf = None
        # User options.
        self.aspect = aspect
        self.enlarge = enlarge
        self.interp = interp
        self.max = max
        self.backcolor = backcolor
        # Event handling.
        self.connect('expose_event', self.expose)

        self.tmpfile = None
Esempio n. 2
0
    def __init__(self, title=TITLE, level=WINDOW_TOPLEVEL, on_exit=None):
        self.title = title
        self.grabbing = False
        self.events = []
        self.rgb = WHITE_RGB
        self.on_exit = on_exit

        self.window = Window(level)
        self.window.set_title(title)
        self.window.set_resizable(True)
        self.window.add_events(POINTER_MOTION_MASK)
        self.window.set_default_size(350, 150)
        self.colors = []

        grab_btn = Button('Grab')
        grab_btn.connect_object('clicked', self.toggle_grab, self.window)
        self.grab_btn = grab_btn

        exit_btn = Button('Exit')
        exit_btn.connect_object('clicked', self.destroy, self.window)

        drawing = DrawingArea()
        drawing.connect_object('expose_event', self.do_expose, self.window)
        self.drawing = drawing

        label = Label(rgb_to_string(WHITE_RGB))
        self.label = label

        table = Table(2, 2, True)
        table.attach(self.drawing, 0, 1, 0, 1)
        table.attach(label,   0, 1, 1, 2)
        table.attach(grab_btn, 1, 2, 0, 1)
        table.attach(exit_btn, 1, 2, 1, 2)
        self.window.add(table)
Esempio n. 3
0
    def __init__(self, title, init_width=230, init_height=230):
        """
        Instantiate an instance of _BasePyClock.

        @type title: str
        @param title: String to be used for the window title.

        @type init_width: int
        @param init_width: Initial width of the window.
            DEFAULT: 230

        @type init_height: int
        @param init_height: Initial heigh of the window.
            DEFAULT: 230
        """
        super(BasePyClock, self).__init__()

        self.set_title(title=title)
        self.resize(width=init_width, height=init_height)
        self.set_position(position=WIN_POS_CENTER)
        self.connect("destroy", main_quit)

        self._time = datetime.now()

        self._draw_area = DrawingArea()
        self._draw_area.connect("expose-event", self._expose)
        self.add(self._draw_area)

        timeout_add(1000, self._update)

        self.show_all()
Esempio n. 4
0
	def __init__(self, parent, x, y):
		DrawingArea.__init__(self)
		self.set_flags(self.flags() | CAN_FOCUS)
		self.set_events(self.get_events() | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK)
		#|gdk.POINTER_MOTION_MASK|gdk.POINTER_MOTION_HINT_MASK)
		self.init_drawer()
		self.connect("button-press-event", self._mouseButton)
		self.connect("button-release-event", self._mouseButton)
		self.connect("scroll-event", self._mouseScroll)
		parent.put(self, x, y)
 def __init__ (self, values, getter):
     DrawingArea.__init__ (self)
     self.gc = None
     self.width = 0
     self.height = 0
     self.selected = []
     self.total = 0
     self.offset = 1
     self.getter = getter
     self.values = values
     self.connect ("size-allocate", self.__on_size_allocate)
     self.connect ("expose-event", self.__on_expose_event)
     self.connect ("realize", self.__on_realize)
 def __init__(self, values, getter):
     DrawingArea.__init__(self)
     self.gc = None
     self.width = 0
     self.height = 0
     self.selected = []
     self.total = 0
     self.offset = 1
     self.getter = getter
     self.values = values
     self.connect("size-allocate", self.__on_size_allocate)
     self.connect("expose-event", self.__on_expose_event)
     self.connect("realize", self.__on_realize)
Esempio n. 7
0
    def __init__(self):
        """Construct a ResizableImage control.

        Parameters:
        aspect -- Maintain aspect ratio?
        enlarge -- Allow image to be scaled up?
        interp -- Method of interpolation to be used.
        backcolor -- Tuple (R, G, B) with values ranging from 0 to 1,
            or None for transparent.
        max_size -- Max dimensions for internal image (width, height).
        """
        DrawingArea.__init__(self)
        self.pixbuf = None
        self.connect('expose_event', self.expose)
Esempio n. 8
0
    def __init__(self, graph):
        DrawingArea.__init__(self)
        self.connect('expose-event', self.expose)

        self.graph = graph
        self.cairo = None
        self.path = None
        self.adding_edge = None
        self.scale = 1

        self.set_double_buffered(True)
        self.selected_area = None
        self.area = None
        self.zoom = 1
        self.set_size_request(8096, 8096)
Esempio n. 9
0
    def __init__(self):
        self.action = ""
        self.option = ""
        self.state = ""
        self.queue = []

        self.instance = vlc.Instance("--no-xlib")

        self.media_player = self.instance.media_player_new()

        if config.platform == "linux2":
            window = DrawingArea()

            def embed(*args):
                self.media_player.set_xwindow(window.window.xid)

                return True

            window.connect("map", embed)
Esempio n. 10
0
class BasePyClock(Window):
    """
    Base class for PyClock.
    """
    def __init__(self, title, init_width=230, init_height=230):
        """
        Instantiate an instance of _BasePyClock.

        @type title: str
        @param title: String to be used for the window title.

        @type init_width: int
        @param init_width: Initial width of the window.
            DEFAULT: 230

        @type init_height: int
        @param init_height: Initial heigh of the window.
            DEFAULT: 230
        """
        super(BasePyClock, self).__init__()

        self.set_title(title=title)
        self.resize(width=init_width, height=init_height)
        self.set_position(position=WIN_POS_CENTER)
        self.connect("destroy", main_quit)

        self._time = datetime.now()

        self._draw_area = DrawingArea()
        self._draw_area.connect("expose-event", self._expose)
        self.add(self._draw_area)

        timeout_add(1000, self._update)

        self.show_all()

    def _expose(self, *args):
        """
        Method used to draw on to the canvas.
        """
        self._context = self._draw_area.window.cairo_create()
        content_area = Rectangle(width=self.allocation.width,
                                 height=self.allocation.height)
        self._context.rectangle(content_area)
        self._context.clip()

        self._draw_clock()

    def _draw_clock(self):
        """
        Draw the clock.

        NEEDS IMPLEMENTING IN THE INHERITING CLASS.
        """
        raise NotImplementedError

    def _redraw_canvas(self):
        """
        Redraw the canvas to make it look as thought the hands are
        ticking.
        """
        if self.window:
            dimensions = self.get_allocation()
            rect = Rectangle(width=dimensions.width, height=dimensions.height)
            self.window.invalidate_rect(rect, True)
            self.window.process_updates(True)

    def _update(self):
        """
        Get the current time of the machine and set the class _TIME
        property so that the canvas willbe updated.

        @rtype: bool
        @return: Return True to ensure that the timer object will fire
            again.
        """
        self._time = datetime.now()
        self._redraw_canvas()

        # returning True ensures that the timer object will fire again.
        return True