def on_button_release(self,event):
		"""
		This handles and 'drag' part of any connection, after the
		on_button_press  of this tool returns a True (i.e by clicking on an
		Line Handle) the on_button_release is triggered on mouse button release.
		Note that this handles both the new connections and modified
		connections.
		Hint:
		ConnectorTool is a child of this class.
		Uncommenting all the print statements should give a fair idea how this
		tool works.
		"""
		line = self.grabbed_item
		handle = self.grabbed_handle
		glueitem,glueport,gluepos = self.view.get_port_at_point((event.x,event.y),distance = 10,exclude = [line])
		line = self.grabbed_item
		handle = self.grabbed_handle
		try:
			if glueport and hasattr(glueport,"point"):
				#print 'READY_CONNECTION_CHECK_PASSED_1'
				conn = Connector(line,handle)
				sink = ConnectionSink(glueitem,glueport)
				conn.connect_port(sink)
				self.ungrab_handle()
				#print 'READY_CONNECTION_CHECK_PASSED_2'
		except Exception as e:
			print 'Connection Failed, Disconnect/Connect the last Connection again: /n',e
		finally:
			self.toggle_highlight_ports()
			return super(BlockConnectTool, self).on_button_release(event)
示例#2
0
    def on_button_release(self, event):
        """
		This handles and 'drag' part of any connection, after the
		on_button_press  of this tool returns a True (i.e by clicking on an
		Line Handle) the on_button_release is triggered on mouse button release.
		Note that this handles both the new connections and modified
		connections.
		Hint:
		ConnectorTool is a child of this class.
		Uncommenting all the print statements should give a fair idea how this
		tool works.
		"""
        line = self.grabbed_item
        handle = self.grabbed_handle
        glueitem, glueport, gluepos = self.view.get_port_at_point(
            (event.x, event.y), distance=10, exclude=[line])
        line = self.grabbed_item
        handle = self.grabbed_handle
        try:
            if glueport and hasattr(glueport, "point"):
                #print 'READY_CONNECTION_CHECK_PASSED_1'
                conn = Connector(line, handle)
                sink = ConnectionSink(glueitem, glueport)
                conn.connect_port(sink)
                self.ungrab_handle()
                #print 'READY_CONNECTION_CHECK_PASSED_2'
        except Exception as e:
            print 'Connection Failed, Disconnect/Connect the last Connection again: /n', e
        finally:
            self.toggle_highlight_ports()
            return super(BlockConnectTool, self).on_button_release(event)
示例#3
0
	def on_button_press(self,event):
		
		glueitem,glueport,gluepos = self.view.get_port_at_point((event.x,event.y),distance = 10,exclude = [])
		line,handle =  self.view.get_handle_at_point((event.x,event.y))
		try:
			if glueport and hasattr(glueport,"point"):
				self.toggle_highlight_ports(glueport.portinstance)
				self.line = self._create_line((event.x, event.y))
				self._new_item = self.line
				h_glue = self.line.handles()[self._handle_index_glued]
				conn = Connector(self.line,h_glue)
				sink = ConnectionSink(glueitem,glueport)
				conn.connect_port(sink)
				h_drag = self.line.handles()[self._handle_index_dragged]
				self.grab_handle(self.line,h_drag)
				return True
		except Exception as e:
			print 'Connection Failed, Disconnect/Connect the last Connection again: /n',e
示例#4
0
    def on_button_press(self, event):

        glueitem, glueport, gluepos = self.view.get_port_at_point(
            (event.x, event.y), distance=10, exclude=[])
        line, handle = self.view.get_handle_at_point((event.x, event.y))
        try:
            if glueport and hasattr(glueport, "point"):
                self.toggle_highlight_ports(glueport.portinstance)
                self.line = self._create_line((event.x, event.y))
                self._new_item = self.line
                h_glue = self.line.handles()[self._handle_index_glued]
                conn = Connector(self.line, h_glue)
                sink = ConnectionSink(glueitem, glueport)
                conn.connect_port(sink)
                h_drag = self.line.handles()[self._handle_index_dragged]
                self.grab_handle(self.line, h_drag)
                return True
        except Exception as e:
            print 'Connection Failed, Disconnect/Connect the last Connection again: /n', e