def _BIcon(self): pb = GdkPixbuf.Pixbuf.new_from_file(self.m_sDataDir + self.m_oDictBlock["Icon"]) xpos = self.width / 2 - pb.get_width() / 2 ypos = self.height / 2 - pb.get_height() / 2 icon = GooCanvas.CanvasImage(pixbuf=pb, x=xpos, y=ypos) self.wGroup.add_child(icon, -1) self.widgets["pb"] = icon
def __init__(self, image_path): GooCanvas.Canvas.__init__(self) self.image = GooCanvas.CanvasImage() self.frame = [] self.setBackgroundImage(image_path) self.grab_focus(self.image) self.realize() self.get_root_item().add_child(self.image, 0) self.area_fill_rgba = (94, 156, 235, 150) self.area_stroke_rgba = (94, 156, 235, 250) self.area_selected_stroke_rgba = (255, 255, 0, 255) self.image.connect('button_press_event', self.startSelectionArea) self.image.connect('button_release_event', self.endSelectionArea) self.image.connect('motion_notify_event', self.updateSelectionArea) self.image.connect('key_press_event', self.pressedKeyOnImage) self.connect('scroll-event', self.scrollEventCb) self.selected_areas = [] self.currently_created_area = None
def _BOutputs(self): outPWids = [] for outputId in range(len(self.m_oDictBlock["OutTypes"])): xIcon = self.width - self.m_nOutputWidth yIcon = self.m_nRadius + outputId * 5 + outputId * self.m_nOutputHeight outputType = self.m_oDictBlock["OutTypes"][outputId + 1]['type'] # build description string (escape '<' and '>' characters) try: description = self.m_oDictBlock["OutTypes"][outputId + 1]['desc'] except KeyError: description = '' description += ' (' + outputType + ')' description = description.replace('<', '<') description = description.replace('>', '>') # display input icon icon = GdkPixbuf.Pixbuf.new_from_file(self.m_sDataDir + OUTPUT_ICON_FILE) t_Wid = GooCanvas.CanvasImage(pixbuf=icon, x=xIcon, y=yIcon) t_Wid.set_property('tooltip', description) self.wGroup.add_child(t_Wid, -1) outPWids.append(t_Wid) # display input text (input type) outputTypeText = outputType if outputTypeText.startswith('cv::'): outputTypeText = outputTypeText[4:] if len(outputTypeText) > 10: outputTypeText = '... ' label = GooCanvas.CanvasText( text=outputTypeText, anchor=GooCanvas.CanvasAnchorType.EAST, x=(self.width - 2), y=(yIcon + 16), font=IO_FONT_NAME, fill_color=IO_FONT_COLOR) label.set_property('tooltip', description) self.wGroup.add_child(label, -1) outPWids.append(label) self.widgets["Outputs"] = outPWids
def setup_scalability(c): N_COLS = 5 N_ROWS = 20 PADDING = 10 vbox = Gtk.VBox (homogeneous=False, spacing=4) vbox.set_border_width (4) vbox.show() table = Gtk.Table (2, 2, False) table.set_row_spacings (4) table.set_col_spacings (4) vbox.pack_start (table, True, True, 0) table.show () frame = Gtk.Frame () frame.set_shadow_type (Gtk.ShadowType.IN) table.attach (frame, 0, 1, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, 0, 0); frame.show() if 1: pb = GdkPixbuf.Pixbuf.new_from_file("../../demo/toroid.png") width = pb.get_width() height = pb.get_height() else: pb = None width = 37 height = 19 c.set_bounds ( 0, 0, N_COLS * (width + PADDING), N_ROWS * (height + PADDING)) c.show (); scrolled_win = Gtk.ScrolledWindow () scrolled_win.show() frame.add(scrolled_win) scrolled_win.add(c) root = c.get_root_item() for i in range(N_COLS): for j in range(N_ROWS): if pb: GooCanvas.CanvasImage ( parent=root, pixbuf=pb, x=i * (width + PADDING), y=j * (height + PADDING)) else: item = GooCanvas.CanvasRect ( parent=root, x=i * (width + PADDING), y=j * (height + PADDING), width=width, height=height) item.props.fill_color = {True:"mediumseagreen",False:"steelblue"}[j % 2 == 0] return vbox