def __init__(self, parent=None): super(DragDropList, self).__init__(parent) self.setFrameStyle(self.Panel|self.Sunken) self.setAcceptDrops(True) self._buttonGroup = QtGui.QButtonGroup(self) self._buttonGroup.setExclusive(True) header = QtGui.QWidget(self) header.setFixedHeight(20) headerLayout = QtGui.QHBoxLayout(header) headerLayout.setSpacing(0) headerLayout.setContentsMargins(8, 0, 8, 0) self._headerLayer = headerLayout self._contentWidget = content = QtGui.QWidget(self) scroll = QtGui.QScrollArea(self) scroll.setFrameStyle(self.Panel|self.Raised) scroll.setWidgetResizable(True) scroll.setWidget(content) scrollLayout = QtGui.QVBoxLayout(content) scrollLayout.setSpacing(0) scrollLayout.setContentsMargins(0, 0, 0, 0) self._itemLayout = QtGui.QVBoxLayout() self._itemLayout.setSpacing(self.ITEM_SPACING) self._itemLayout.setContentsMargins(0, 12, 0, 12) scrollLayout.addLayout(self._itemLayout) scrollLayout.addStretch() layout = QtGui.QVBoxLayout(self) layout.setContentsMargins(4, 4, 4, 4) layout.addWidget(header) layout.addWidget(scroll) # Connections self._buttonGroup.buttonClicked.connect(self.itemClicked)
def __init__(self, name, ptype, parent=None): QtGui.QDockWidget.__init__(self, parent) # Add the standard dock action buttons in. # TODO: hook up signals self.__label = QtGui.QLabel(self) self.__label.setIndent(10) self.__name = None self.__ptype = ptype self.setName(name) self.attrs = {} self.__refreshTimer = None # Note: the widet in the panel adds more buttons # to this toolbar. titleBar = QtGui.QWidget(self) barLayout = QtGui.QHBoxLayout(titleBar) barLayout.setSpacing(0) barLayout.setContentsMargins(0, 0, 0, 0) self.__toolbar = toolbar = QtGui.QToolBar(self) toolbar.setIconSize(QtCore.QSize(18, 18)) toolbar.addAction(QtGui.QIcon(":/images/close.png"), "Close", self.__close) float_action = QtGui.QAction(QtGui.QIcon(":/images/float.png"), "Float", self) float_action.toggled.connect(self.__floatingChanged) float_action.setCheckable(True) toolbar.addAction(float_action) config_action = QtGui.QAction(QtGui.QIcon(":/images/config.png"), "Configure Panel", self) config_action.triggered.connect(self._openPanelSettingsDialog) toolbar.addAction(config_action) toolbar.addSeparator() barLayout.addWidget(toolbar) barLayout.addStretch() barLayout.addWidget(self.__label) barLayout.addSpacing(4) self.setTitleBarWidget(titleBar) self.init()
def __init__(self, parent=None): super(JobColumnWidget, self).__init__(parent) self.__currentJob = None self.__currentLayer = None self.__currentTask = None self.setFocusPolicy(QtCore.Qt.NoFocus) contentWidget = QtGui.QWidget(self) self.setWidget(contentWidget) self.setWidgetResizable(True) mainLayout = QtGui.QHBoxLayout(contentWidget) self._jobWidget = job = JobSelectionWidget(self) job.setMinimumWidth(220) self._layerWidget = layer = FilterableListBox(parent=self) layer.setLabel("Layer:") layer.setMinimumWidth(180) self._taskWidget = task = FilterableListBox(parent=self) task.setLabel("Task:") task.setMinimumWidth(120) mainLayout.addWidget(job) mainLayout.addWidget(layer) mainLayout.addWidget(task) # connections job.selectionChanged.connect(self._jobSelectionChanged) job.valueClicked.connect(layer.clearSelection) job.valueClicked.connect(task.clearSelection) layer.selectionChanged.connect(self._layerSelectionChanged) layer.valueClicked.connect(task.clearSelection) task.selectionChanged.connect(self._taskSelectionChanged)
def spacer(width): w = QtGui.QWidget() w.setFixedWidth(width) return w
def __init__(self, job=None, task=None, attrs=None, parent=None): QtGui.QWidget.__init__(self, parent) self.__task = None self.__log_file = QtCore.QFile() self.__log_stream = QtCore.QTextStream() openAction = QtGui.QAction("Open Log File", self) openAction.setShortcut(QtGui.QKeySequence.Open) self.addAction(openAction) self.__searchLine = QtGui.QLineEdit(self) self.__chk_tail = QtGui.QAction("Tail log", self) self.__chk_tail.setCheckable(True) self.__findPrevBtn = prev = QtGui.QAction(self) prev.setToolTip("Find Previous Match") prev.setIcon(QtGui.QIcon(":/images/left_arrow.png")) self.__findNextBtn = nxt = QtGui.QAction(self) nxt.setToolTip("Find Next Match") nxt.setIcon(QtGui.QIcon(":/images/right_arrow.png")) self.__jobNameLabel = label = QtGui.QLabel(self) label.setIndent(10) # label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) label.hide() self.__jobNameSpacer = QtGui.QWidget(self) self.__jobNameSpacer.setFixedHeight(6) self.__jobNameSpacer.hide() def spacer(width): w = QtGui.QWidget() w.setFixedWidth(width) return w stretch = QtGui.QWidget() stretch.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) self.__toolbar = tb = QtGui.QToolBar(self) tb.addWidget(spacer(4)) tb.addWidget(QtGui.QLabel("Find: ", self)) tb.addWidget(self.__searchLine) tb.addAction(self.__findPrevBtn) tb.addAction(self.__findNextBtn) tb.addWidget(stretch) tb.addAction(self.__chk_tail) tb.addWidget(spacer(4)) self.__view = view = QtGui.QPlainTextEdit(self) font = view.font() font.setPixelSize(DEFAULT_FONT_SIZE) view.setFont(font) view.setLineWrapMode(view.WidgetWidth) view.setReadOnly(True) view.setMaximumBlockCount(1000000) # self.__view.setFocusPolicy(QtCore.Qt.NoFocus) layout = QtGui.QVBoxLayout(self) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.__toolbar) layout.addWidget(self.__jobNameLabel) layout.addWidget(self.__jobNameSpacer) layout.addWidget(self.__view) self.__highlighter = TextHighlighter(view.document()) self.__logWatcher = FileWatcher(self) # Connections self.__logWatcher.fileChanged.connect(self.__logUpdated) self.__chk_tail.toggled.connect(self.__logTailToggled) self.__searchLine.textChanged.connect(self.findText) self.__searchLine.returnPressed.connect(self.findNext) self.__findPrevBtn.triggered.connect(self.findPrev) self.__findNextBtn.triggered.connect(self.findNext) openAction.triggered.connect(self.openLogFile) # Optional args if job: self.setJobName(job.name) if task: self.setCurrentTask(task)