def contextMenuEvent(self, event): self.menu = QtWidgets.QMenu() action = QtWidgets.QAction('add attr', self) action.triggered.connect(self.showAddAttrDialog) icon = IconManager.get("add.svg", type="icon") action.setIcon(icon) self.menu.addAction(action) action = QtWidgets.QAction('rename attr', self) action.triggered.connect(self.renameAttrDialog) icon = IconManager.get("edit.svg", type="icon") action.setIcon(icon) self.menu.addAction(action) action = QtWidgets.QAction('remove attr', self) action.triggered.connect(self.removeSelectedAttr) icon = IconManager.get("trashbin.svg", type="icon") action.setIcon(icon) self.menu.addAction(action) action = QtWidgets.QAction('copy attr', self) action.triggered.connect(self.copyAttr) icon = IconManager.get("copy.png", type="icon") action.setIcon(icon) self.menu.addAction(action) action = QtWidgets.QAction('paste attr', self) action.triggered.connect(self.pasteAttr) icon = IconManager.get("paste.png", type="icon") action.setIcon(icon) self.menu.addAction(action) self.menu.exec_(event.globalPos())
def __init__(self, parent=None, blueprintWidget=None): super(BlockListWidget, self).__init__(parent=parent) self.blueprintWidget = blueprintWidget self.setDragDropMode(self.InternalMove) # self.setDragDropMode(self.DragDrop) self.setSelectionMode(self.ExtendedSelection) self.setStyleSheet(self.stylesheet) self.setAlternatingRowColors(True) self.contextMenu = ContextMenu(self) # self.contextMenu.addCommand("edit annotation", self.editAnnotationCallback) # self.contextMenu.addSeparator() icon = IconManager.get("copy.png", type="icon") self.contextMenu.addCommand("copy", self.copyBlock, icon=icon) icon = IconManager.get("paste.png", type="icon") self.contextMenu.addCommand("paste", self.pasteBlock, icon=icon) self.contextMenu.addSeparator() icon = IconManager.get("start_from_here.png", type="icon") self.contextMenu.addCommand("start from here", self.setNextToSelected, icon=icon) self._currItemRow = None
def _initUI(self): layout = VBoxLayout(self) layout.setContentsMargins(2, 0, 2, 0) with layout: mainLayout = qcreate(HBoxLayout) mainLayout.setContentsMargins(0, 0, 0, 0) with mainLayout: self.indicatorWidget = qcreate(QtWidgets.QStackedWidget) self.indicatorWidget.setFixedWidth(15) self.nothing = qcreate(QtWidgets.QLabel) self.indicatorWidget.addWidget(self.nothing) self.frame = qcreate(QtWidgets.QFrame, layoutType=HBoxLayout) self.frame.layout().setContentsMargins(0, 0, 0, 0) with self.frame.layout(): self.activeCheckBox = qcreate(Checkbox) self.blockType = qcreate(QtWidgets.QLabel, "Break Point") self.blockNameField = qcreate(StringField) self.blockNameField.setHidden(True) qcreate(Spacer) with qcreate(VBoxLayout): icon = IconManager.get("delete.svg", type="icon") self.deleteButton = qcreate(Button, "", icon=icon) self.deleteButton.setFixedSize(QtCore.QSize(15, 15)) qcreate(SeparatorLine) # self.setEnableDisplay(True) self.activeCheckBox.setValue(self.block.active) self.setEnableDisplay(self.block.active)
def _initToolBar(self): toolBar = QtWidgets.QToolBar(self) icon = IconManager.get("new.png", type="icon") action = toolBar.addAction(icon, "new blueprint") action.triggered.connect(self.newBlueprintCalled) icon = IconManager.get("open.png", type="icon") action = toolBar.addAction(icon, "open blueprint") action.triggered.connect(self.loadBlueprintDialogCalled) icon = IconManager.get("save.png", type="icon") action = toolBar.addAction(icon, "save blueprint") action.triggered.connect(self.saveExistingBlueprintCalled) self.addToolBar(toolBar)
def initUI(self): icon = IconManager.get("load.png",type="icon") self.browseFolderButton.setIcon(icon) self.blueprintTreeWidget = BlueprintTreeWidget(self) self.blueprintListLayout.addWidget(self.blueprintTreeWidget)
def _initUI(self): self.setContentsMargins(0, 0, 0, 0) layout = VBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) with layout: splitter = qcreate(Splitter, mode="vertical") with splitter: self.headerWidget = qcreate(HeaderWidget) # self.blockMenu = qcreate(BlockMenuWidget,self) w2 = qcreate(QtWidgets.QGroupBox, layoutType=VBoxLayout) w2.setTitle("Blueprint") w2.setStyleSheet( '''QGroupBox{ font-size: 14px; font-weight: bold;}''') w2.setAlignment(QtCore.Qt.AlignCenter) w2lay = w2.layout() w2lay.setContentsMargins(0, 0, 0, 0) with w2lay: self.blockListWidget = BlockListWidget( blueprintWidget=self) w2lay.add(self.blockListWidget) with qcreate(HBoxLayout): icon = IconManager.get("rewind.png", type="icon") self.rewindButton = qcreate(Button, icon, "") self.rewindButton.setMinimumHeight(25) icon = IconManager.get("step_back.png", type="icon") self.stepBackButton = qcreate(Button, icon, "") self.stepBackButton.setMinimumHeight(25) self.stepBackButton.setMaximumWidth(30) icon = IconManager.get("build_next.png", type="icon") self.buildNextButton = qcreate(Button, icon, "") self.buildNextButton.setMinimumHeight(25) icon = IconManager.get("step_forward.png", type="icon") self.stepForwardButton = qcreate(Button, icon, "") self.stepForwardButton.setMinimumHeight(25) self.stepForwardButton.setMaximumWidth(30) icon = IconManager.get("fast_forward.png", type="icon") self.fastForwardButton = qcreate(Button, icon, "") self.fastForwardButton.setMinimumHeight(25) splitter.setSizes((50, 600))
def __init__(self, *args, **kwargs): super(DeleteButton, self).__init__(*args, **kwargs) icon = IconManager.get('trashbin.svg',type="icon") self.setIcon(icon) self.setFlat(True) sizePol = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.setSizePolicy(sizePol) self.setMaximumWidth(14) self.setMaximumHeight(18)
def initUI(self): self.setWindowTitle('Script Editor') layout = VBoxLayout(self) with layout: self.editor = qcreate(PythonTextEditor) with qcreate(HBoxLayout) as hlayout: icon = IconManager.get("save.png", type='icon') self.setBtn = qcreate(Button, 'Save', icon=icon) self.cancelBtn = qcreate(Button, 'Cancel') hlayout.setRatio(2, 1) layout.setRatio(1, 0) self.resize(800, 800)
def __init__(self, parent=None): super(BrickWindow, self).__init__(parent=parent) mainWidget = BrickWidget(mainWindow=self) self.currentBlueprint = None mainWidget.setContentsMargins(0, 0, 0, 0) self.setCentralWidget(mainWidget) self.menuBar = None self._initMenuBar() self._initToolBar() self._initPropertyDock() self._initLogDock() icon = IconManager.get("brick.png", type="icon") self.setWindowIcon(icon) self.updateTitle() self.resize(1300, 1080)
def _populateBlocks(self): blockMap = lib.collectBlocksByCategory() with self.blockMenuLayout: qcreate(Spacer, mode="vertical") for category, blockClasses in blockMap.items(): gbox = qcreate(QtWidgets.QGroupBox, layoutType=VBoxLayout) gbox.setTitle(category) with gbox.layout(): lwidget = qcreate(BlockMenuListWidget) for blockClass in blockClasses: icon = IconManager.get(blockClass.ui_icon_name, type="icon") item = QtWidgets.QListWidgetItem( icon, blockClass.__name__) item.blockClass = blockClass item.setSizeHint(QtCore.QSize(100, 30)) lwidget.addItem(item) qcreate(Spacer, mode="vertical")
def _initUI(self): layout = VBoxLayout(self) layout.setContentsMargins(2, 0, 2, 0) with layout: mainLayout = qcreate(HBoxLayout) mainLayout.setContentsMargins(0, 0, 0, 0) with mainLayout: self.indicatorWidget = qcreate(QtWidgets.QStackedWidget) self.indicatorWidget.setFixedWidth(15) self.nothing = qcreate(QtWidgets.QLabel) self.nothing.setStyleSheet( 'background-color:rgb(126, 126, 126)') self.success = qcreate(QtWidgets.QLabel) self.success.setStyleSheet('background-color:rgb(52, 141, 3)') self.fail = qcreate(QtWidgets.QLabel) self.fail.setStyleSheet('background-color:rgb(149, 0, 2)') self.next = qcreate(QtWidgets.QLabel) self.next.setStyleSheet('background-color:rgb(244, 244, 0)') self.indicatorWidget.addWidget(self.nothing) self.indicatorWidget.addWidget(self.success) self.indicatorWidget.addWidget(self.fail) self.indicatorWidget.addWidget(self.next) # self.indicatorWidget.setCurrentIndex(1) self.frame = qcreate(QtWidgets.QFrame, layoutType=HBoxLayout) self.frame.layout().setContentsMargins(0, 0, 0, 0) with self.frame.layout(): self.activeCheckBox = qcreate(Checkbox) icon = IconManager.get(self.block.ui_icon_name, type="path") self.labelIcon = qcreate(Image, icon, w=15, h=15) self.blockTypeLabel = qcreate(QtWidgets.QLabel, "Block Type") self.blockNameField = qcreate(StringField) qcreate(Spacer) with qcreate(VBoxLayout): with qcreate(HBoxLayout): icon = IconManager.get("play.svg", type="icon") self.runBlockButton = qcreate(Button, icon, "") qcreate(QtWidgets.QLabel, " ") icon = IconManager.get("delete.svg", type="icon") self.deleteButton = qcreate(Button, "", icon=icon) self.deleteButton.setFixedSize(QtCore.QSize(15, 15)) # self.runBlockButton = qcreate(Button,">") # self.runBlockButton.setFixedWidth(20) # self.runBlockButton.setFixedHeight(60) qcreate(SeparatorLine) self.blockTypeLabel.setText("{} : ".format( self.block.__class__.__name__)) self.blockTypeLabel.setText("{} : ".format( self.block.__class__.__name__)) self.blockNameField.setValue(self.block.name) self.activeCheckBox.setValue(self.block.active) self.setEnableDisplay(self.block.active)