def __init__(self, parent_canvas_item, sta, dev): """! Initialize function. @param self The object pointer. @param parent_canvas_item: parent canvas @param sta The STA node @param dev The dev """ super(WifiLink, self).__init__() self.node1 = sta self.dev = dev self.node2 = None # ap self.canvas_item = GooCanvas.CanvasGroup(parent=parent_canvas_item) self.invisible_line = GooCanvas.CanvasPolyline(parent=self.canvas_item, line_width=25.0, visibility=GooCanvas.CanvasItemVisibility.HIDDEN) self.visible_line = GooCanvas.CanvasPolyline(parent=self.canvas_item, line_width=1.0, stroke_color_rgba=0xC00000FF, line_dash=GooCanvas.CanvasLineDash.newv([2.0, 2.0 ])) # self.invisible_line.set_property("pointer-events", (GooCanvas.CanvasPointerEvents.STROKE_MASK # |GooCanvas.CanvasPointerEvents.FILL_MASK # |GooCanvas.CanvasPointerEvents.PAINTED_MASK)) self.canvas_item.pyviz_object = self self.canvas_item.lower(None) self.set_ap(None)
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()
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 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_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 ()
def __init__(self, rows, pattern): GooCanvas.Canvas.__init__(self) self.rows = rows self.pattern = pattern self.row_height = 24 self.grid_unit = PPQN / 4 # unit in pulses self.zoom_in = 2 self.instr_width = 120 self.edited_note = None self.orig_velocity = None self.orig_length = None self.orig_y = None self.channel_modes = ['D' if ch == 10 else 'M' for ch in range(1, 17)] self.update_size() self.grid = GooCanvas.CanvasGroup(parent=self.get_root_item(), x=self.instr_width) self.update_grid() self.notes = GooCanvas.CanvasGroup(parent=self.get_root_item(), x=self.instr_width) self.names = GooCanvas.CanvasGroup(parent=self.get_root_item(), x=0) self.update_names() self.cursor = DrumCanvasCursor(self) hide_item(self.cursor) self.connect('event', self.on_grid_event) self.channel = 10 self.edit_mode = self.channel_modes[self.channel - 1] self.toolbox = DrumEditorToolbox(self) self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK) self.grab_focus(self.grid) self.update_notes()
def __init__(self): GooCanvas.Canvas.__init__(self) # canvas size canvasWidth = 2000 canvasHeight = 1000 self.set_bounds(0, 0, canvasWidth, canvasHeight) self.lastClickecPt = (None, None) self.m_fPixels_per_unit = 1.0 self.reset() self.savedXml = self.ToXml() # capture the current state self.bIsUndoEnabled = False # undo enabled flag self.initUndo() self.show() # canvas receives events before its children, so we need to use # a group as root item, so that its receives events after blocks # and connectors self.wGroup = GooCanvas.CanvasGroup() self.get_root_item().add_child(self.wGroup, -1) self.wGroup.connect("button-press-event", self.group_event) self.wGroup.connect("button-release-event", self.group_event) self.wGroup.connect("motion-notify-event", self.group_event) # add a rectangle as 'group background', else group will not # receive interior events self.root_add( GooCanvas.CanvasRect( width=canvasWidth, height=canvasHeight, pointer_events=GooCanvas.CanvasPointerEvents.ALL, stroke_color='gray')) self.m_sFilename = None self.createWorkingDir() self.m_sErrorLog = "" # turn on tooltips self.set_property('has-tooltip', True) self.sessionManager = None
def __init__(self, diagram, a_nConnectorCountId=1, a_nFrom=-1, a_nFromOut=-1): #a_nInputs, a_nOutputs, a_nBlockType ): self.ParentDiagram = diagram self.m_nCountId = a_nConnectorCountId self.fromBlock = a_nFrom self.fromBlockOut = a_nFromOut self.fromPoint = self.ParentDiagram.m_oBlocks[ self.fromBlock].GetOutputPos(self.fromBlockOut) self.ConnBoundary = 16.0 self.toPoint = (0, 0) self.toBlock = -1 #a_nTo self.toBlockIn = -1 #a_nToIn self.m_bFocus = False self.m_bHasFlow = False self.wGroup = GooCanvas.CanvasGroup(can_focus=True) # append connector to canvas root at a low level # so that blocks catch events before connectors self.ParentDiagram.root_add(self.wGroup, 1) w1 = GooCanvas.CanvasPolyline(end_arrow=True, line_width=3) # create the begin and end points of the connector # see GooCanvas.CanvasPoints API self.canvas_points = GooCanvas.CanvasPoints.new(2) w1.props.points = self.canvas_points self.wGroup.add_child(w1, -1) self.widgets = {} self.widgets["Line"] = w1 self.turnOnEvents()
def __init__(self, diagram, a_nBlockType, a_nBlockCountId=1): #a_nInputs, a_nOutputs, a_nBlockType ): #initialize all members #if len(a_oDictBlock) == 0: #a_oDictBlock["Label"] = "Unknown Block" #a_oDictBlock["Icon"] = 'haarDetect.png' #a_oDictBlock["Color"] = "150:20:40:150" #a_oDictBlock["Inputs"] = 0 #a_oDictBlock["Outputs"] = 0 self.m_nBlockType = a_nBlockType self.ParentDiagram = diagram self.m_sDataDir = os.environ['HARPIA_DATA_DIR'] if s2idirectory.block.has_key(a_nBlockType): self.m_oDictBlock = s2idirectory.block[a_nBlockType] #a_oDictBlock else: self.m_oDictBlock = s2idirectory.block[0] #a_oDictBlock print "Bad block type", a_nBlockType, "... assuming 0" self.m_nBlockCountId = a_nBlockCountId self.widgets = {} self.m_bFocus = False self.m_bHasFlow = False self.m_bTimeShifts = False self.m_bIsSource = False if self.m_oDictBlock['Inputs'] == 0: self.m_bIsSource = True if self.m_oDictBlock.has_key("TimeShifts"): #delay block self.m_bTimeShifts = self.m_oDictBlock["TimeShifts"] # self.m_oPropertiesXML contains something like: # <block id="1" type="0"> # <property name="state" value="true" /> # <property name="_PARAM1_" type="filename" value="resource/lena.jpg" /> # </block> self.m_oPropertiesXML = xmltree.xmlTree() self.m_oPropertiesXML.load(str(self.m_oDictBlock["Path"]["Xml"])) self.m_oPropertiesXML = self.m_oPropertiesXML.findSubTrees( './block')[0] self.m_oPropertiesXML.setAttribute('.', 'id', unicode(str(self.m_nBlockCountId))) self.m_oBorderColor = [0, 0, 0, 255] self.m_oBackColor = [0, 0, 0, 150] self.m_nRadius = 15 self.m_nInputHeight = 24 self.m_nInputWidth = 24 self.m_nOutputHeight = 24 self.m_nOutputWidth = 14 self.inputPortCenters = [] self.outputPortCenters = [] self.width = WIDTH_DEFAULT self.TextWidth = self.width - WIDTH_2_TEXT_OFFSET t_nMaxIO = max(self.m_oDictBlock["Inputs"], self.m_oDictBlock["Outputs"]) ## Generates the block size, based on the number of inputs,outputs # Comment block is too small... if not t_nMaxIO: t_nMaxIO = 1 self.height = max( ((t_nMaxIO - 1) * 5) # space between ports = 5 + (self.m_nRadius * 2) #tirando a margem superior e inferior + (t_nMaxIO * self.m_nInputHeight), #adicionando a altura de cada port HEIGHT_DEFAULT) self.Label = self.m_oDictBlock["Label"] self.iconFile = self.m_sDataDir + self.m_oDictBlock["Icon"] self.wGroup = GooCanvas.CanvasGroup(can_focus=True) self.ParentDiagram.root_add(self.wGroup) self.wGroup.connect("button-press-event", self.group_event) self.wGroup.connect("button-release-event", self.group_event) self.wGroup.connect("key-press-event", self.group_event) self.wGroup.connect("motion-notify-event", self.group_event) self.wGroup.connect("enter-notify-event", self.group_event) self.wGroup.connect("leave-notify-event", self.group_event) self.wGroup.connect("focus-in-event", self.onFocusIn) self.wGroup.connect("focus-out-event", self.onFocusOut) self.Build() self.isMoving = False # is the block being moved ?