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))
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()
def get_rgb_image_as_pixbuf(self): dawd = self.surface.get_width() daht = self.surface.get_height() rgb_buf = bytes(self.surface.get_data()) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, GdkPixbuf.Colorspace.RGB, False, 8, dawd, daht, dawd * 3) return pixbuf
def get_rgb_image_as_pixbuf(self): dawd = self.surface.get_width() daht = self.surface.get_height() rgb_buf = bytes(self.surface.get_data()) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, GdkPixbuf.Colorspace.RGB, False, 8, dawd, daht, dawd*3) return pixbuf
def get_rgb_image_as_pixbuf(self): arr8 = self.renderer.get_surface_as_array(order='RGB') daht, dawd = arr8.shape[:2] rgb_buf = arr8.tobytes(order='C') pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, GdkPixbuf.Colorspace.RGB, False, 8, dawd, daht, dawd * 3) return pixbuf
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x y = event.y degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % (degrees, direction)) data_x, data_y = self.get_data_xy(x, y) self.last_data_x, self.last_data_y = data_x, data_y return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x; y = event.y degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % ( degrees, direction)) data_x, data_y = self.get_data_xy(x, y) self.last_data_x, self.last_data_y = data_x, data_y return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def draw_event(self, widget, cr): self.logger.debug("updating window from surface") if six.PY2: # redraw the screen from backing surface cr.set_source_surface(self.surface, 0, 0) else: # see NOTE [1] above arr8 = self.get_image_as_array() pixbuf = GtkHelp.pixbuf_new_from_array(arr8, GdkPixbuf.Colorspace.RGB, 8) Gdk.cairo_set_source_pixbuf(cr, pixbuf, 0, 0) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() return False
def __init__(self, logger): self.logger = logger root = Gtk.Window(title="ImageViewZoom Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: self.quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = Gtk.VBox(spacing=2) # create the ginga viewer and configure it fi = CanvasView(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) fi.enable_auto_orient(True) self.fitsimage = fi # enable some user interaction bd = fi.get_bindings() bd.enable_all(True) w = fi.get_widget() w.set_size_request(512, 512) # add scrollbar interface around this viewer si = ScrolledView(fi) si.scroll_bars(horizontal='on', vertical='on') vbox.pack_start(si, True, True, 0) hbox = Gtk.HButtonBox() hbox.set_layout(Gtk.ButtonBoxStyle.END) wopen = Gtk.Button(label="Open File") wopen.connect('clicked', self.open_file) wquit = Gtk.Button(label="Quit") wquit.connect('clicked', self.quit) for w in (wopen, wquit): hbox.add(w) vbox.pack_start(hbox, False, False, 0) root.add(vbox)
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x y = event.y self.last_win_x, self.last_win_y = x, y # NOTE: for future use in distinguishing mouse wheel vs. # trackpad events dev = event.get_source_device() src = 'mouse' if dev is not None: _src = dev.get_source() if _src == Gdk.InputSource.TOUCHPAD: src == 'touchpad' degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % (degrees, direction)) data_x, data_y = self.check_cursor_location() return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x y = event.y self.last_win_x, self.last_win_y = x, y # NOTE: for future use in distinguishing mouse wheel vs. # trackpad events dev = event.get_source_device() src = "mouse" if dev is not None: _src = dev.get_source() if _src == Gdk.InputSource.TOUCHPAD: src == "touchpad" degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % (degrees, direction)) data_x, data_y = self.get_data_xy(x, y) self.last_data_x, self.last_data_y = data_x, data_y return self.make_ui_callback("scroll", direction, degrees, data_x, data_y)
def get_plain_image_as_pixbuf(self): arr = self.getwin_array(order='RGB', dtype=np.uint8) pixbuf = GtkHelp.pixbuf_new_from_array(arr, GdkPixbuf.Colorspace.RGB, 8) return pixbuf
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() root = Gtk.Window(title="Gtk3 CanvasView Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = Gtk.VBox(spacing=2) fi = CanvasView(logger) fi.enable_autocuts("on") fi.set_autocut_params("zscale") fi.enable_autozoom("on") fi.set_zoom_algorithm("rate") fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback("drag-drop", self.drop_file) fi.set_callback("none-move", self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype("rectangle", color="lightblue") canvas.setSurface(fi) self.canvas = canvas # add canvas to view private_canvas = fi.get_canvas() private_canvas.register_for_cursor_drawing(fi) private_canvas.add(canvas) canvas.ui_setActive(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar fi.show_color_bar(True) # add little mode indicator that shows keyboard modal states fi.show_mode_indicator(True, corner="ur") w = fi.get_widget() w.set_size_request(512, 512) vbox.pack_start(w, True, True, 1) self.readout = Gtk.Label("") vbox.pack_start(self.readout, False, False, 0) hbox = Gtk.HBox(spacing=5) wdrawtype = GtkHelp.combo_box_new_text() index = 0 for name in self.drawtypes: wdrawtype.insert_text(index, name) index += 1 index = self.drawtypes.index("rectangle") wdrawtype.set_active(index) wdrawtype.connect("changed", self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = GtkHelp.combo_box_new_text() index = 0 for name in self.drawcolors: wdrawcolor.insert_text(index, name) index += 1 index = self.drawcolors.index("lightblue") wdrawcolor.set_active(index) wdrawcolor.connect("changed", self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = GtkHelp.CheckButton("Fill") wfill.sconnect("toggled", self.set_drawparams) self.wfill = wfill walpha = GtkHelp.SpinButton() adj = walpha.get_adjustment() adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0) walpha.set_value(1.0) walpha.set_digits(1) walpha.sconnect("value-changed", self.set_drawparams) self.walpha = walpha wclear = Gtk.Button("Clear Canvas") wclear.connect("clicked", self.clear_canvas) wopen = Gtk.Button("Open File") wopen.connect("clicked", self.open_file) wquit = Gtk.Button("Quit") wquit.connect("clicked", quit) for w in (wquit, wclear, walpha, Gtk.Label("Alpha:"), wfill, wdrawcolor, wdrawtype, wopen): hbox.pack_end(w, False, False, 0) vbox.pack_start(hbox, False, False, 0) root.add(vbox)
def make_timer(self): return GtkHelp.Timer()
def make_cursor(self, iconpath, x, y): cursor = GtkHelp.make_cursor(self.imgwin, iconpath, x, y) return cursor
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() root = Gtk.Window(title="Gtk3 CanvasView Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = Gtk.VBox(spacing=2) fi = CanvasView(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_zoom_algorithm('rate') fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback('drag-drop', self.drop_file_cb) fi.set_callback('cursor-changed', self.cursor_cb) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.set_surface(fi) self.canvas = canvas # add canvas to view private_canvas = fi.get_canvas() private_canvas.register_for_cursor_drawing(fi) private_canvas.add(canvas) canvas.ui_set_active(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar fi.show_color_bar(True) fi.show_focus_indicator(True) # add little mode indicator that shows keyboard modal states fi.show_mode_indicator(True, corner='ur') w = fi.get_widget() w.set_size_request(512, 512) vbox.pack_start(w, True, True, 1) self.readout = Gtk.Label("") vbox.pack_start(self.readout, False, False, 0) hbox = Gtk.HBox(spacing=5) wdrawtype = GtkHelp.combo_box_new_text() index = 0 for name in self.drawtypes: wdrawtype.insert_text(index, name) index += 1 index = self.drawtypes.index('rectangle') wdrawtype.set_active(index) wdrawtype.connect('changed', self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = GtkHelp.combo_box_new_text() index = 0 for name in self.drawcolors: wdrawcolor.insert_text(index, name) index += 1 index = self.drawcolors.index('lightblue') wdrawcolor.set_active(index) wdrawcolor.connect('changed', self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = GtkHelp.CheckButton("Fill") wfill.sconnect('toggled', self.set_drawparams) self.wfill = wfill walpha = GtkHelp.SpinButton() adj = walpha.get_adjustment() adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0) walpha.set_value(1.0) walpha.set_digits(1) walpha.sconnect('value-changed', self.set_drawparams) self.walpha = walpha wclear = Gtk.Button("Clear Canvas") wclear.connect('clicked', self.clear_canvas) wopen = Gtk.Button("Open File") wopen.connect('clicked', self.open_file) wquit = Gtk.Button("Quit") wquit.connect('clicked', quit) for w in (wquit, wclear, walpha, Gtk.Label("Alpha:"), wfill, wdrawcolor, wdrawtype, wopen): hbox.pack_end(w, False, False, 0) vbox.pack_start(hbox, False, False, 0) root.add(vbox)
def __init__(self, logger=None, rgbmap=None, settings=None): ImageViewGtk.__init__(self, logger=logger, rgbmap=rgbmap, settings=settings) imgwin = self.imgwin imgwin.set_can_focus(True) imgwin.connect("map_event", self.map_event) imgwin.connect("focus_in_event", self.focus_event, True) imgwin.connect("focus_out_event", self.focus_event, False) imgwin.connect("enter_notify_event", self.enter_notify_event) imgwin.connect("leave_notify_event", self.leave_notify_event) imgwin.connect("motion_notify_event", self.motion_notify_event) imgwin.connect("button_press_event", self.button_press_event) imgwin.connect("button_release_event", self.button_release_event) imgwin.connect("key_press_event", self.key_press_event) imgwin.connect("key_release_event", self.key_release_event) imgwin.connect("scroll_event", self.scroll_event) mask = imgwin.get_events() imgwin.set_events(mask | Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK | Gdk.EventMask.FOCUS_CHANGE_MASK | Gdk.EventMask.STRUCTURE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.SCROLL_MASK) # Set up widget as a drag and drop destination imgwin.connect("drag-data-received", self.drop_event_cb) imgwin.connect("drag-motion", self.drag_motion_cb) imgwin.connect("drag-drop", self.drag_drop_cb) self.TARGET_TYPE_TEXT = 0 imgwin.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) imgwin.drag_dest_add_text_targets() # last known window mouse position self.last_win_x = 0 self.last_win_y = 0 # last known data mouse position self.last_data_x = 0 self.last_data_y = 0 # Does widget accept focus when mouse enters window self.enter_focus = self.t_.get('enter_focus', True) # @$%&^(_)*&^ gnome!! self._keytbl = { 'shift_l': 'shift_l', 'shift_r': 'shift_r', 'control_l': 'control_l', 'control_r': 'control_r', 'alt_l': 'alt_l', 'alt_r': 'alt_r', 'super_l': 'super_l', 'super_r': 'super_r', 'meta_right': 'meta_right', 'asciitilde': '~', 'grave': 'backquote', 'exclam': '!', 'at': '@', 'numbersign': '#', 'percent': '%', 'asciicircum': '^', 'ampersand': '&', 'asterisk': '*', 'dollar': '$', 'parenleft': '(', 'parenright': ')', 'underscore': '_', 'minus': '-', 'plus': '+', 'equal': '=', 'braceleft': '{', 'braceright': '}', 'bracketleft': '[', 'bracketright': ']', 'bar': '|', 'colon': ':', 'semicolon': ';', 'quotedbl': 'doublequote', 'apostrophe': 'singlequote', 'backslash': 'backslash', 'less': '<', 'greater': '>', 'comma': ',', 'period': '.', 'question': '?', 'slash': '/', 'space': 'space', 'escape': 'escape', 'return': 'return', 'tab': 'tab', 'f1': 'f1', 'f2': 'f2', 'f3': 'f3', 'f4': 'f4', 'f5': 'f5', 'f6': 'f6', 'f7': 'f7', 'f8': 'f8', 'f9': 'f9', 'f10': 'f10', 'f11': 'f11', 'f12': 'f12', 'right': 'right', 'left': 'left', 'up': 'up', 'down': 'down', } # Define cursors for curname, filename in (('pan', 'openHandCursor.png'), ('pick', 'thinCrossCursor.png')): path = os.path.join(icon_dir, filename) cur = GtkHelp.make_cursor(self.imgwin, path, 8, 8) self.define_cursor(curname, cur) for name in ( 'motion', 'button-press', 'button-release', 'key-press', 'key-release', 'drag-drop', 'scroll', 'map', 'focus', 'enter', 'leave', ): self.enable_callback(name)
def __init__(self, logger=None, rgbmap=None, settings=None): ImageViewGtk.__init__(self, logger=logger, rgbmap=rgbmap, settings=settings) imgwin = self.imgwin imgwin.set_can_focus(True) imgwin.connect("map_event", self.map_event) imgwin.connect("focus_in_event", self.focus_event, True) imgwin.connect("focus_out_event", self.focus_event, False) imgwin.connect("enter_notify_event", self.enter_notify_event) imgwin.connect("leave_notify_event", self.leave_notify_event) imgwin.connect("motion_notify_event", self.motion_notify_event) imgwin.connect("button_press_event", self.button_press_event) imgwin.connect("button_release_event", self.button_release_event) imgwin.connect("key_press_event", self.key_press_event) imgwin.connect("key_release_event", self.key_release_event) imgwin.connect("scroll_event", self.scroll_event) mask = imgwin.get_events() imgwin.set_events(mask | Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK | Gdk.EventMask.FOCUS_CHANGE_MASK | Gdk.EventMask.STRUCTURE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.SCROLL_MASK) # Set up widget as a drag and drop destination imgwin.connect("drag-data-received", self.drop_event_cb) imgwin.connect("drag-motion", self.drag_motion_cb) imgwin.connect("drag-drop", self.drag_drop_cb) self.TARGET_TYPE_TEXT = 0 imgwin.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) imgwin.drag_dest_add_text_targets() # last known window mouse position self.last_win_x = 0 self.last_win_y = 0 # last known data mouse position self.last_data_x = 0 self.last_data_y = 0 # Does widget accept focus when mouse enters window self.enter_focus = self.t_.get('enter_focus', True) # @$%&^(_)*&^ gnome!! self._keytbl = { 'shift_l': 'shift_l', 'shift_r': 'shift_r', 'control_l': 'control_l', 'control_r': 'control_r', 'alt_l': 'alt_l', 'alt_r': 'alt_r', 'super_l': 'super_l', 'super_r': 'super_r', 'meta_right': 'meta_right', 'asciitilde': '~', 'grave': 'backquote', 'exclam': '!', 'at': '@', 'numbersign': '#', 'percent': '%', 'asciicircum': '^', 'ampersand': '&', 'asterisk': '*', 'dollar': '$', 'parenleft': '(', 'parenright': ')', 'underscore': '_', 'minus': '-', 'plus': '+', 'equal': '=', 'braceleft': '{', 'braceright': '}', 'bracketleft': '[', 'bracketright': ']', 'bar': '|', 'colon': ':', 'semicolon': ';', 'quotedbl': 'doublequote', 'apostrophe': 'singlequote', 'backslash': 'backslash', 'less': '<', 'greater': '>', 'comma': ',', 'period': '.', 'question': '?', 'slash': '/', 'space': 'space', 'escape': 'escape', 'return': 'return', 'tab': 'tab', 'f1': 'f1', 'f2': 'f2', 'f3': 'f3', 'f4': 'f4', 'f5': 'f5', 'f6': 'f6', 'f7': 'f7', 'f8': 'f8', 'f9': 'f9', 'f10': 'f10', 'f11': 'f11', 'f12': 'f12', 'right': 'right', 'left': 'left', 'up': 'up', 'down': 'down', } # Define cursors for curname, filename in (('pan', 'openHandCursor.png'), ('pick', 'thinCrossCursor.png')): path = os.path.join(icon_dir, filename) cur = GtkHelp.make_cursor(self.imgwin, path, 8, 8) self.define_cursor(curname, cur) for name in ('motion', 'button-press', 'button-release', 'key-press', 'key-release', 'drag-drop', 'scroll', 'map', 'focus', 'enter', 'leave', ): self.enable_callback(name)
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() root = Gtk.Window(title="ImageViewCanvas Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = Gtk.VBox(spacing=2) fi = ImageViewCanvas(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.enable_draw(False) fi.set_callback('drag-drop', self.drop_file) fi.set_callback('none-move', self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.setSurface(fi) self.canvas = canvas # add canvas to view fi.add(canvas) canvas.ui_setActive(True) w = fi.get_widget() w.set_size_request(512, 512) vbox.pack_start(w, True, True, 1) self.readout = Gtk.Label("") vbox.pack_start(self.readout, False, False, 0) hbox = Gtk.HBox(spacing=5) wdrawtype = GtkHelp.combo_box_new_text() self.drawtypes = fi.get_drawtypes() index = 0 for name in self.drawtypes: wdrawtype.insert_text(index, name) index += 1 index = self.drawtypes.index('rectangle') wdrawtype.set_active(index) wdrawtype.connect('changed', self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = GtkHelp.combo_box_new_text() index = 0 for name in self.drawcolors: wdrawcolor.insert_text(index, name) index += 1 index = self.drawcolors.index('lightblue') wdrawcolor.set_active(index) wdrawcolor.connect('changed', self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = GtkHelp.CheckButton("Fill") wfill.sconnect('toggled', self.set_drawparams) self.wfill = wfill walpha = GtkHelp.SpinButton() adj = walpha.get_adjustment() adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0) walpha.set_value(1.0) walpha.set_digits(1) walpha.sconnect('value-changed', self.set_drawparams) self.walpha = walpha wclear = Gtk.Button("Clear Canvas") wclear.connect('clicked', self.clear_canvas) wopen = Gtk.Button("Open File") wopen.connect('clicked', self.open_file) wquit = Gtk.Button("Quit") wquit.connect('clicked', quit) for w in (wquit, wclear, walpha, Gtk.Label("Alpha:"), wfill, wdrawcolor, wdrawtype, wopen): hbox.pack_end(w, False, False, 0) vbox.pack_start(hbox, False, False, 0) root.add(vbox)
def get_image_as_pixbuf(self): arr = self.getwin_array(order='RGB') pixbuf = GtkHelp.pixbuf_new_from_array(arr, GdkPixbuf.Colorspace.RGB, 8) return pixbuf