def __init__(self, toolbar): super(Debugger_Panel, self).__init__() self.toolbar = toolbar self.info_panel = Debugger_Info() topleft = QtWidgets.QFrame() topleft.setFrameShape(QtWidgets.QFrame.StyledPanel) self.editor = CodeEditor(self) self.editor_layout = QtWidgets.QVBoxLayout() self.editor_layout.setContentsMargins(0, 0, 0, 0) self.link = LinkPathLabel(self) self.editor_layout.addWidget(self.link) self.editor_layout.addWidget(self.editor) topleft.setLayout(self.editor_layout) self.splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.splitter.addWidget(topleft) self.splitter.addWidget(self.info_panel) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.splitter) self.setLayout(layout)
def on_mouse_press(self, x, y, button, modifiers): if self.menu.click(x, y): return x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size()) if button == 1: if self.field: self.pop_handlers() self.push_handlers() self.field = None if self.code_editor: if self.code_editor.intersect_point((x, y)): return else: if self.code_editor.hover: self.pop_handlers() self.push_handlers() self.code_editor = None for node in self.nodes: if node.intersect_point((x, y)): if (node in self.selected_nodes and len(self.selected_nodes) > 1): self.node_drag = True return else: si = node.selectedInput['name'] != 'none' so = node.selectedOutput['name'] != 'none' if si or so: self.pointer = (x, y) self.connection = True if si: self.disconnect_node(node) elif so: self.connecting_node = \ {'node': node, 'put': node.selectedOutput, 'mode': 'output'} return if isinstance(node, Node): self.code_editor = CodeEditor(node) elif isinstance(node, Field) and not self.field: self.push_handlers(node) self.field = node self.selected_nodes = [node] self.node_drag = True return self.select = True self.selectPoint = (x, y)
def on_mouse_press(self, x, y, button, modifiers): if self.menu.click(x, y): return x, y = x_y_pan_scale(x, y, self.pan_scale, self.get_size()) if button == 1: if self.field: self.pop_handlers() self.push_handlers() self.field = None if self.code_editor: if self.code_editor.intersect_point((x, y)): return else: if self.code_editor.hover: self.pop_handlers() self.push_handlers() self.code_editor = None for node in self.nodes: if node.intersect_point((x, y)): if (node in self.selected_nodes and len(self.selected_nodes) > 1): self.node_drag = True return else: if (node.selectedInput['name'] != 'none' or node.selectedOutput['name'] != 'none'): self.pointer = (x, y) self.connection = True if node.selectedInput['name'] != 'none': for c in node.connected_to: a = c['output'] if (c['input']['put']['name'] == node.selectedInput['name']): self.connecting_node = { 'node': a['node'], 'put': { 'name': a['put']['name'] }, 'mode': 'output' } n = node.connected_to del n[n.index(c)] for line in node.graphics[ 'connections']: for segment in line: segment.delete() node.graphics['connections'] = list() return self.connecting_node = { 'node': node, 'put': node.selectedInput, 'mode': 'input' } return elif node.selectedOutput['name'] != 'none': self.connecting_node = { 'node': node, 'put': node.selectedOutput, 'mode': 'output' } return if isinstance(node, Node): self.code_editor = CodeEditor(node) elif isinstance(node, Field) and not self.field: self.push_handlers(node) self.field = node self.selected_nodes = [node] self.node_drag = True return self.select = True self.selectPoint = (x, y)
def __init__(self): # make a window self.w = Window((400, 400), "DrawBot", minSize=(200, 200), textured=False) # setting previously stored frames, if any self.w.getNSWindow().setFrameUsingName_(self.windowAutoSaveName) try: # on 10.7+ full screen support self.w.getNSWindow().setCollectionBehavior_( 128) #NSWindowCollectionBehaviorFullScreenPrimary except: pass # the code editor self.codeView = CodeEditor((0, 0, -0, -0)) # the output view (will catch all stdout and stderr) self.outPutView = OutPutEditor((0, 0, -0, -0), readOnly=True) # the view to draw in self.drawView = DrawView((0, 0, -0, -0)) # the view with all thumbnails self.thumbnails = ThumbnailView((0, 0, -0, -0)) # connect the thumbnail view with the draw view self.thumbnails.setDrawView(self.drawView) # collect all code text view in a splitview paneDescriptors = [ dict(view=self.codeView, identifier="codeView", minSize=50, canCollapse=False), dict(view=self.outPutView, identifier="outPutView", size=100, minSize=50, canCollapse=False), ] self.codeSplit = SplitView((0, 0, -0, -0), paneDescriptors, isVertical=False) # collect the draw scroll view and the code split view in a splitview paneDescriptors = [ dict(view=self.thumbnails, identifier="thumbnails", minSize=100, size=100, maxSize=100), dict(view=self.drawView, identifier="drawView", minSize=50), dict(view=self.codeSplit, identifier="codeSplit", minSize=50, canCollapse=False), ] self.w.split = SplitView((0, 0, -0, -0), paneDescriptors) # setup BaseWindowController base behavoir self.setUpBaseWindowBehavior() # get the real size of the window windowX, windowY, windowWidth, windowHeight = self.w.getPosSize() # set the split view dividers at a specific position based on the window size self.w.split.setDividerPosition(0, 0) self.w.split.setDividerPosition(1, windowWidth * .6) self.codeSplit.setDividerPosition(0, windowHeight * .7)