Exemplo n.º 1
0
    def __init__(self, logger=None, rgbmap=None, settings=None):
        ImageView.__init__(self,
                           logger=logger,
                           rgbmap=rgbmap,
                           settings=settings)

        imgwin = Gtk.DrawingArea()
        imgwin.connect("draw", self.draw_event)
        imgwin.connect("configure-event", self.configure_event)
        imgwin.set_events(Gdk.EventMask.EXPOSURE_MASK)
        # prevents some flickering
        imgwin.set_double_buffered(True)
        imgwin.set_app_paintable(True)
        # prevents extra redraws, because we manually redraw on a size
        # change
        imgwin.set_redraw_on_allocate(False)
        self.imgwin = imgwin
        self.imgwin.show_all()

        # see reschedule_redraw() method
        self._defer_task = GtkHelp.Timer()
        self._defer_task.add_callback('expired',
                                      lambda timer: self.delayed_redraw())
        self.msgtask = GtkHelp.Timer()
        self.msgtask.add_callback('expired',
                                  lambda timer: self.onscreen_message(None))
Exemplo n.º 2
0
    def __init__(self, logger=None, rgbmap=None, settings=None):
        ImageView.ImageViewBase.__init__(self,
                                         logger=logger,
                                         rgbmap=rgbmap,
                                         settings=settings)

        imgwin = Gtk.DrawingArea()
        imgwin.connect("draw", self.draw_event)
        imgwin.connect("configure-event", self.configure_event)
        imgwin.set_events(Gdk.EventMask.EXPOSURE_MASK)
        # prevents some flickering
        imgwin.set_double_buffered(True)
        imgwin.set_app_paintable(True)
        # prevents extra redraws, because we manually redraw on a size
        # change
        imgwin.set_redraw_on_allocate(False)
        self.imgwin = imgwin
        self.imgwin.show_all()

        self.t_.set_defaults(renderer='cairo')

        # create our default double-buffered surface area that we copy
        # to the widget
        rect = self.imgwin.get_allocation()
        x, y, wd, ht = rect.x, rect.y, rect.width, rect.height
        arr = np.zeros((ht, wd, 4), dtype=np.uint8)
        stride = cairo.ImageSurface.format_stride_for_width(
            cairo.FORMAT_ARGB32, wd)
        self.surface = cairo.ImageSurface.create_for_data(
            arr, cairo.FORMAT_ARGB32, wd, ht, stride)
        if sys.byteorder == 'little':
            self.rgb_order = 'BGRA'
        else:
            self.rgb_order = 'ARGB'

        # see reschedule_redraw() method
        self._defer_task = GtkHelp.Timer()
        self._defer_task.add_callback('expired',
                                      lambda timer: self.delayed_redraw())
        self.msgtask = GtkHelp.Timer()
        self.msgtask.add_callback('expired',
                                  lambda timer: self.onscreen_message(None))

        self.renderer = None
        # Pick a renderer that can work with us
        renderers = ['cairo', 'agg', 'pil', 'opencv']
        preferred = self.t_['renderer']
        if preferred in renderers:
            renderers.remove(preferred)
        self.possible_renderers = [preferred] + renderers
        self.choose_best_renderer()
Exemplo n.º 3
0
 def make_timer(self):
     return GtkHelp.Timer()