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)
def customer_match_selected(self, entrycompletion, treemodel, treeiter): self.customer_id = treemodel[treeiter][0] group = GooCanvas.CanvasGroup() self.canvas.set_root_item(group) self.populate_invoices() self.populate_payments() DB.rollback()
def do_simple_update(self, cr): cr.identity_matrix() if self.element.factory: self.visible_width = self.nsToPixel(self.element.duration) self.bounds = GooCanvas.CanvasBounds(0, 0, self.visible_width + KW_LABEL_X_OVERFLOW, self.height + KW_LABEL_Y_OVERFLOW)
def do_simple_paint(self, cr, bounds): cr.identity_matrix() if self.interpolator: cr.save() # set clipping region to the visible portion of the clip vis_bounds = intersect( GooCanvas.CanvasBounds( self.bounds.x1, self.bounds.y1 + KW_LABEL_Y_OVERFLOW, self.bounds.x2 - KW_LABEL_X_OVERFLOW, self.bounds.y2), bounds) vis_width = vis_bounds.x2 - vis_bounds.x1 vis_height = vis_bounds.y2 - vis_bounds.y1 cr.rectangle(vis_bounds.x1, vis_bounds.y1, vis_width, vis_height) cr.clip() self.make_curve(cr) cr.set_line_width(self.line_width) cr.set_source_rgb(1, 0, 0) cr.stroke() self.make_keyframes(cr) cr.set_line_width(1.0) cr.set_source_rgb(1, 1, 1) cr.fill_preserve() cr.set_source_rgb(1, 0, 0) cr.stroke() # re-draw the focused keyframe, if it exists, inverted if self._focused_kf: self._controlPoint(cr, self._focused_kf) cr.set_source_rgb(1, 0, 0) cr.fill_preserve() cr.set_source_rgb(1, 1, 1) cr.stroke() x, y = self.keyframes[self._focused_kf] x += KW_LABEL_X_OFFSET y += KW_LABEL_Y_OFFSET text = self.interpolator.formatValue(self._focused_kf.value) w, h = cr.text_extents("0" * len(text))[2:4] # reset clip region to the full bounds of the item bounds = intersect(self.bounds, bounds) width = bounds.x2 - bounds.x1 height = bounds.y2 - bounds.y1 # cr.reset_clip() cr.restore() cr.rectangle(bounds.x1, bounds.y1, width, height) cr.clip() # draw the value label roundedrec(cr, x - KW_LABEL_HPAD2, y - KW_LABEL_VPAD2, w + KW_LABEL_HPAD, h + KW_LABEL_VPAD, r=10) cr.set_source_rgb(1, 1, 1) cr.fill() cr.set_source_rgb(1, 0, 0) cr.move_to(x, y + h) cr.show_text(text) else: cr.restore()
def customer_changed (self, combobox): customer_id = combobox.get_active_id() if customer_id != None: self.customer_id = customer_id group = GooCanvas.CanvasGroup() self.canvas.set_root_item(group) self.populate_invoices () self.populate_payments ()