Ejemplo n.º 1
0
    def __draw_outputs(self):
        """
        This method draw the outputs.
        """
        outs = []
        x = 0
        for port in self.out_ports:
            text_name = self.__get_port_label(port["type"]);
            out = GooCanvas.CanvasText(parent=self,
                                 text=text_name,
                                 fill_color='black',
                                 anchor=GooCanvas.CanvasAnchorType.EAST,
                                 alignment = Pango.Alignment.RIGHT,
                                 x=(self.width - 1),
                                 y=(RADIUS +  # upper border
                                     (x * 5) +  # spacing betwen ports
                                      x * INPUT_HEIGHT),  # prev ports
                                 use_markup=True
                                 )

            out.set_property("tooltip", port["label"])
            out.connect("button-press-event", self.__on_output_press, x)
            out.connect("button-release-event", self.__on_output_release, x)
            outs.append(out)
            x += 1
        self.widgets["Outputs"] = outs
Ejemplo n.º 2
0
    def __draw_ports(self):
        """        for port in self.ports:

        This method draws the ports.
        """
        for port in self.ports:
            text_name = self.__create_ports_label(port)
            x,y = self.__get_port_pos(port)
            if port.is_input():
                alignment = Pango.Alignment.LEFT
                anchor=GooCanvas.CanvasAnchorType.WEST
                press_event = self.__on_input_press
                release_event = self.__on_input_release
            else:
                alignment = Pango.Alignment.RIGHT
                anchor = GooCanvas.CanvasAnchorType.EAST
                press_event = self.__on_output_press
                release_event = self.__on_output_release

            text = GooCanvas.CanvasText(parent=self,
                                 text=text_name,
                                 fill_color='black',
                                 anchor=anchor,
                                 alignment=alignment,
                                 x=x,
                                 y=y,
                                 use_markup=True,
                                 tooltip=port.label
                                 )
            text.connect("button-press-event", press_event , port)
            text.connect("button-release-event", release_event, port)
            self.widgets["port" + str(port)] = text
Ejemplo n.º 3
0
    def __draw_label(self):
        """
        This method draw the label.

        """
        text_label = "<span font_family ='Arial' " + \
            "size = '10000' weight = 'ultralight'> " + \
            self.label + "</span>"

        label = GooCanvas.CanvasText(parent=self,
                                     text=text_label,
                                     fill_color='black',
                                     anchor=GooCanvas.CanvasAnchorType.CENTER,
                                     x=(self.width / 2),
                                     y=(10),
                                     use_markup=True,
                                     stroke_color='black'
                                     )

        width = Pango.Rectangle()
        width2 = Pango.Rectangle()
        label.get_natural_extents(width, width2)
        text_width = width2.width / 1000
        oldX, oldY = ((self.width / 2), (self.height - 10))
        self.width = max(text_width + 22, self.width)
        label.translate((self.width / 2) - oldX, (self.height - 10) - oldY)
        self.widgets["Label"] = label
Ejemplo n.º 4
0
 def __draw_inputs(self):
     """
     This method draw the inputs.
     """
     ins = []
     x = 0
     for port in self.in_ports:
         text_name = self.__get_port_label(port["type"]);
         inp = GooCanvas.CanvasText(parent=self,
                              text=text_name,
                              fill_color='black',
                              anchor=GooCanvas.CanvasAnchorType.WEST,
                              alignment = Pango.Alignment.LEFT,
                              x=2,
                              y=(RADIUS +  # upper border
                                  (x * 5) +  # spacing betwen ports
                                   x * INPUT_HEIGHT),  # prev ports
                              use_markup=True
                              )
         inp.set_property("tooltip", port["label"])
         inp.connect("button-press-event", self.__on_input_press, x)
         inp.connect("button-release-event", self.__on_input_release, x)
         ins.append(inp)
         x += 1
     self.widgets["Inputs"] = ins
Ejemplo n.º 5
0
    def __draw_icon(self):
        """
        This method draw a icon.
        """
        text_label = "<span font_family ='Arial' " + \
            "size = '25000' weight = 'bold' > " + \
            self.label.title()[0] + "</span>"

        icon = GooCanvas.CanvasText(parent=self,
                                     text=text_label,
                                     fill_color='white',
                                     anchor=GooCanvas.CanvasAnchorType.CENTER,
                                     x=(self.width / 2),
                                     y=(self.height / 2),
                                     use_markup=True,
                                     stroke_color='black'
                                     )

        width = Pango.Rectangle()
        width2 = Pango.Rectangle()
        icon.get_natural_extents(width, width2)
        text_width = width2.width / 1000
        oldX, oldY = ((self.width / 2), (self.height / 2))
        self.width = max(text_width + 22, self.width)
        icon.translate((self.width / 2) - oldX, (self.height / 2) - oldY)
        self.widgets["Icon"] = icon
 def populate_invoices(self):
     c = DB.cursor()
     root = self.canvas.get_root_item()
     previous_position = 25.0
     c.execute(
         "SELECT "
         "'Invoice '||id::text||' '||format_date(dated_for)||' '||amount_due::money, "
         "amount_due::float, "
         "id "
         "FROM invoices "
         "WHERE (canceled, posted, customer_id) = (False, True, %s) "
         "ORDER BY dated_for", (self.customer_id, ))
     for row in c.fetchall():
         amount = row[1]
         parent1 = GooCanvas.CanvasGroup(parent=root)
         GooCanvas.CanvasRect(parent=parent1,
                              x=50,
                              y=previous_position,
                              width=300,
                              height=amount,
                              stroke_color="black")
         t = GooCanvas.CanvasText(parent=parent1,
                                  text=row[0],
                                  x=340,
                                  y=previous_position + (amount / 2),
                                  anchor=GooCanvas.CanvasAnchorType.EAST)
         t.connect("button-release-event", self.invoice_clicked, row[2])
         previous_position += amount
     self.canvas.set_size_request(800, previous_position + 100)
     c.close()
Ejemplo n.º 7
0
	def populate_payments (self):
		c = self.db.cursor()
		root = self.canvas.get_root_item()
		previous_position = 25.0
		c.execute("SELECT "
				"'Payment '||payment_info(id)||' '||format_date(date_inserted)||' '||amount::money, "
				"amount::float, "
				"id "
				"FROM payments_incoming "
				"WHERE customer_id = %s "
				"ORDER BY date_inserted", (self.customer_id,))
		for row in c.fetchall():
			amount = row[1]
			parent1 = GooCanvas.CanvasGroup(parent = root)
			GooCanvas.CanvasRect   (parent = parent1, 
									x=350,
									y = previous_position ,
									width=400,
									height=amount,
									stroke_color="black")
			t = GooCanvas.CanvasText (parent = parent1,
									text = row[0], 
									x=360,
									y=previous_position + (amount / 2), 
									anchor = GooCanvas.CanvasAnchorType.WEST)
			t.connect("button-release-event", self.po_clicked, row[2])
			previous_position += amount
		if previous_position + 100 > self.canvas.get_size_request().height:
			self.canvas.set_size_request(800,  previous_position)
Ejemplo n.º 8
0
 def update_names(self):
     for i in self.names.items:
         i.destroy()
     for i in range(0, self.rows):
         #GooCanvas.CanvasText(parent = self.names, text = gui_tools.note_to_name(i), x = self.instr_width - 10, y = (i + 0.5) * self.row_height, anchor = Gtk.AnchorType.E, size_points = 10, font = "Sans", size_set = True)
         GooCanvas.CanvasText(parent=self.names,
                              text=gui_tools.note_to_name(i),
                              x=self.instr_width - 10,
                              y=(i + 0.5) * self.row_height,
                              anchor=GooCanvas.CanvasAnchorType.E,
                              font="Sans")
Ejemplo n.º 9
0
 def _BLabels(self):
     label = GooCanvas.CanvasText(text=self.m_oDictBlock["Label"],
                                  anchor=GooCanvas.CanvasAnchorType.CENTER,
                                  x=(self.width / 2),
                                  y=(self.height - 10),
                                  font=BLOCKNAME_FONT_NAME,
                                  fill_color=BLOCKNAME_FONT_COLOR)
     self.wGroup.add_child(label, -1)
     textBounds = label.get_bounds()
     self.TextWidth = textBounds.x2 - textBounds.x1
     oldX, oldY = ((self.width / 2), (self.height - 10))
     self.width = max(self.TextWidth + WIDTH_2_TEXT_OFFSET, self.width)
     label.translate((self.width / 2) - oldX, (self.height - 10) - oldY)
     self.widgets["Label"] = label
Ejemplo n.º 10
0
        def get_label():
            """!
            Get label function

            @param self: this object
            @return label
            """
            try:
                label = unused_labels.pop(0)
            except IndexError:
                label = GooCanvas.CanvasText(parent=self.viz.canvas.get_root_item(), stroke_color_rgba=self.color)
            else:
                label.set_property("visibility", GooCanvas.CanvasItemVisibility.VISIBLE)
                label.lower(None)
            self.labels.append(label)
            return label
Ejemplo n.º 11
0
    def __draw_label(self):
        """
        This method draw the label.

        """
        text_label = "<span font_family ='Arial' " + \
            "size = '10000' weight = 'normal'> " + \
            self.label + "</span>"

        label = GooCanvas.CanvasText(parent=self,
                                     text=text_label,
                                     fill_color='black',
                                     anchor=GooCanvas.CanvasAnchorType.CENTER,
                                     x=(self.width / 2),
                                     y=0,
                                     use_markup=True,
                                     stroke_color='black')
        self.__widgets["Label"] = label
Ejemplo n.º 12
0
    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('<', '&lt;')
            description = description.replace('>', '&gt;')

            # 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
Ejemplo n.º 13
0
    def __draw_icon(self):
        """
        This method draw a icon.
        """
        text_label = "<span font_family ='Arial' " + \
            "size = '25000' weight = 'bold' > " + \
            self.label.title()[0] + "</span>"

        icon = GooCanvas.CanvasText(parent=self,
                                    text=text_label,
                                    fill_color='white',
                                    anchor=GooCanvas.CanvasAnchorType.CENTER,
                                    x=(self.width / 2),
                                    y=(self.height / 2),
                                    use_markup=True,
                                    stroke_color='black',
                                    tooltip=self.label)

        self.__widgets["Icon"] = icon
Ejemplo n.º 14
0
 def __init__(self, canvas):
     self.canvas = canvas
     self.canvas_root = canvas.get_root_item()
     self.frame = GooCanvas.CanvasRect(parent=self.canvas_root,
                                       x=-6,
                                       y=-6,
                                       width=12,
                                       height=12,
                                       stroke_color="gray",
                                       line_width=1)
     hide_item(self.frame)
     self.vel = GooCanvas.CanvasText(parent=self.canvas_root,
                                     x=0,
                                     y=0,
                                     fill_color="blue",
                                     stroke_color="blue",
                                     anchor=GooCanvas.CanvasAnchorType.S)
     hide_item(self.vel)
     self.rubberband = False
     self.rubberband_origin = None
     self.rubberband_current = None