def __init__(self,title,parent): super(KPIView,self).__init__(parent) self.widget = QLabel(parent=self) self.widget.setAlignment(Qt.AlignHCenter) self.setFrameShape(QFrame.Panel) self.setFrameShadow(QFrame.Sunken) self.setStyleSheet("background:white") l = QLabel("<h2><font color='grey'>" + title + "</h2>") l.setAlignment(Qt.AlignHCenter) l.setWordWrap(True) vlayout2 = QVBoxLayout() vlayout2.addWidget(l,0,Qt.AlignHCenter) # vlayout2.addStretch(1000) vlayout2.addWidget(self.widget) # hlayout = QHBoxLayout() # hlayout.addStretch() # hlayout.addWidget(widget) # hlayout.addStretch() # vlayout2.addLayout(hlayout) self.setLayout(vlayout2) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
def set_led_count(self, number, colour=Colour.RED, names=None, tips=None, reverse=False, toolTip=True): self._toolTip = toolTip labels = [] for i in range(number): layout = QVBoxLayout() led = WidgetLed(self, colour) label = QLabel(self) label.setAlignment(Qt.AlignHCenter | Qt.AlignTop) layout.addWidget(led) layout.addWidget(label) self._layout.addLayout(layout) self._leds.append(led) labels.append(label) if not reverse: self._leds.reverse() labels.reverse() if names is not None: names.reverse() if tips is not None: tips.reverse() for i in range(number): if names is None: labels[i].setText(str(i)) else: labels[i].setText(names[i]) if tips is not None: self._leds[i].setToolTip(tips[i]) labels[i].setToolTip(tips[i])
class SimpleOption(QWidget): def __init__(self, settingsName, labelText, defaultValue, checkable=False): super(SimpleOption, self).__init__() self.setLayout(QHBoxLayout()) #self.layout().setSpacing(0) self.checkable = checkable if checkable: self.checkBox = QCheckBox() self.layout().addWidget(self.checkBox) self.label = QLabel(labelText) self.label.setAlignment(Qt.AlignRight|Qt.AlignVCenter) #self.label.setMinimumWidth(240) self.layout().addWidget(self.label) self.settingsName = settingsName self.editor(defaultValue) def editor(self, defaultValue): self.lineEdit = QLineEdit() self.lineEdit.setText(str(QSettings().value(self.settingsName, defaultValue))) self.lineEdit.setToolTip('Default value: %s' % defaultValue) self.lineEdit.setAlignment(Qt.AlignLeft|Qt.AlignTop) self.layout().addWidget(self.lineEdit) def setEnabled(self, e): self.lineEdit.setEnabled(e) def getName(self): return self.label.text() def setName(self, newName): self.label.setText(newName) def getValue(self): return self.lineEdit.text() def setValue(self, newValue): self.lineEdit.setText(str(newValue)) def save(self): QSettings().setValue(self.settingsName, self.getValue()) def __str__(self): return str(self.getValue())
def getLabel(self, text, font, alignment=None): """ Get a Level Label with the text """ label = QLabel(text, self) label.setFont(font) if alignment: label.setAlignment(alignment) return label
class PlusMinusButtons(QWidget): def __init__(self, caption): super(PlusMinusButtons, self).__init__() self.upButton = CameraButton() self.upButton.setIcon(QIcon(":icons/list-add")) self.downButton = CameraButton() self.downButton.setIcon(QIcon(":icons/list-remove")) self.caption = QLabel("<b>" + caption + "</b>") self.caption.setAlignment(Qt.AlignHCenter | Qt.AlignTop) self.initLayout() def initLayout(self): layout = QGridLayout() self.setLayout(layout) layout.addWidget(self.upButton, 0, 0) layout.addWidget(self.caption, 1, 0) layout.addWidget(self.downButton, 2, 0) layout.setRowStretch(0, 2) layout.setRowStretch(1, 2) layout.setRowStretch(2, 2)
def getLabel(self, font): """ Get a Level Label witht he apropriate Font """ label = QLabel(self.level.name, self) label.setFont(self.smallFont) label.setAlignment(Qt.AlignCenter) label.resize(self.WIDTH, self.HEIGHT) return label
class HelpForm(QDialog): def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.pageLabel = QLabel("<font color=purple size=30><b>Help Contents</b></font>") self.pageLabel.setMinimumSize(400, 50) self.pageLabel.setAlignment(Qt.AlignCenter) appicom = QIcon(":/icons/njnlogo.png") self.setWindowIcon(appicom) toolBar = QToolBar() pixmap = QPixmap(":/icons/njnlogo.png") lbl = QLabel(self) lbl.setPixmap(pixmap) lbl.setFixedSize(70, 70) toolBar.setMinimumHeight(70) toolBar.setMaximumHeight(80) toolBar.addWidget(lbl) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.textBrowser.setSource(QUrl(page)) self.setMinimumSize(650, 650) self.setMaximumSize(650, 660) self.setWindowTitle("Nigandu English to Tamil Dictionary | HELP")
def __init__(self, parent=None): ''' Constructor ''' QDialog.__init__(self, parent) self._ui = Ui_CreditsDialog() self._ui.setupUi(self) creditsTab = QTabWidget() creditSections = info.CREDITS.keys() for creditSection in creditSections: creditTab = QWidget() creditsTab.addTab(creditTab, creditSection) vbox = QVBoxLayout(creditTab) creditList = "" for person in info.CREDITS[creditSection]: creditList += ("\n%s [%s]" % (person['name'], person['email'])) creditLabel = QLabel() creditLabel.setStyleSheet("QLabel { background-color : white}") creditLabel.setText(creditList) creditLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft) vbox.addWidget(creditLabel) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(creditsTab) self._ui.frame_CreditsTab.setLayout(vbox)
def getParameterWidget(self): """ Returns a widget with sliders / fields with which properties of this volume property can be adjusted. :rtype: QWidget """ layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignTop) self.sliders = [] for index in range(7): slider = QSlider(Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(1000) slider.setValue( int( math.pow(self.sectionsOpacity[index], 1.0 / 3.0) * slider.maximum())) slider.valueChanged.connect(self.valueChanged) self.sliders.append(slider) label = QLabel(self.sectionNames[index]) label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(label, index, 0) layout.addWidget(slider, index, 1) try: from ColumnResizer import ColumnResizer columnResizer = ColumnResizer() columnResizer.addWidgetsFromLayout(layout, 0) except Exception, e: print e
def getLabel(self, font): """ Get a Level Label witht he apropriate Font """ label = QLabel(self.level.name, self) label.setFont(self.smallFont) label.setAlignment(Qt.AlignCenter) label.resize(self.WIDTH, self.HEIGHT) return label
def getParameterWidget(self): """ Returns a widget with sliders / fields with which properties of this volume property can be adjusted. :rtype: QWidget """ layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignTop) self.sliders = [] for index in range(7): slider = QSlider(Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(1000) slider.setValue(int(math.pow(self.sectionsOpacity[index], 1.0/3.0) * slider.maximum())) slider.valueChanged.connect(self.valueChanged) self.sliders.append(slider) label = QLabel(self.sectionNames[index]) label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(label, index, 0) layout.addWidget(slider, index, 1) try: from ColumnResizer import ColumnResizer columnResizer = ColumnResizer() columnResizer.addWidgetsFromLayout(layout, 0) except Exception, e: print e
def __init__(self, ftb, atem, parent=None): super(FadeToBlackControl, self).__init__(parent) self.atem = atem self.ftb = ftb layout = QGridLayout() lblRate = QLabel("Rate") lblRate.setAlignment(Qt.AlignHCenter | Qt.AlignBottom) layout.addWidget(lblRate, 0, 0) self.rate = FrameRateTouchSpinner() self.rate.setValue(self.ftb.rate) layout.addWidget(self.rate, 1, 0) self.btnFade = ExpandingButton() self.btnFade.setText("Fade to Black") self.btnFade.setCheckable(True) self.btnFade.setChecked(self.ftb.active) layout.addWidget(self.btnFade, 1, 1) self.ftb.rateChanged.connect(self.rate.setValue) self.ftb.activeChanged.connect(self.btnFade.setChecked) if self.atem: self.rate.valueChanged.connect(self.atem.setFadeToBlackRate) self.btnFade.clicked.connect(self.atem.performFadeToBlack) layout.setRowStretch(0, 1) layout.setRowStretch(1, 1) self.setLayout(layout)
def create_label(self, parent, label="", align="left"): """ Returns an adapted label control. """ control = QLabel(check_parent(parent)) control.setText(label) control.setAlignment(horizontal_alignment_styles[align] | Qt.AlignVCenter) return control_adapter_for(control)
def createLabel(self, text, color): label = QLabel(text) font = label.font() font.setPixelSize(12) label.setFont(font) label.setAlignment(Qt.AlignCenter) label.setStyleSheet("color: " + color) return label
def __init__(self, renderController, parent=None): super(RenderSlicerParamWidget, self).__init__(parent=parent) self.renderController = renderController self.renderController.slicesChanged.connect(self.setSlices) self.renderController.clippingBoxChanged.connect(self.showsClippingBox) self.renderController.clippingPlanesChanged.connect(self.showsClippingPlanes) self.sliceLabelTexts = ["Axial:", "Coronal:", "Sagittal:"] self.sliceLabels = [QLabel(text) for text in self.sliceLabelTexts] self.sliceCheckBoxes = [QCheckBox() for i in range(3)] for index in range(3): self.sliceCheckBoxes[index].clicked.connect(self.checkBoxChanged) self.sliceLabels[index].setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.sliceCheckBoxes[index].setEnabled(True) slicesLayout = QGridLayout() slicesLayout.setAlignment(Qt.AlignTop) for index in range(3): slicesLayout.addWidget(self.sliceLabels[index], index+1, 0) slicesLayout.addWidget(self.sliceCheckBoxes[index], index+1, 1) self.slicesGroupBox = QGroupBox() self.slicesGroupBox.setTitle("Visible slices") self.slicesGroupBox.setLayout(slicesLayout) # Create option to show clipping box self.clippingCheckBox = QCheckBox() self.clippingCheckBox.setChecked(self.renderController.clippingBox) self.clippingCheckBox.clicked.connect(self.clippingCheckBoxChanged) self.clippingPlanesCheckBox = QCheckBox() self.clippingPlanesCheckBox.setChecked(self.renderController.clippingPlanes) self.clippingPlanesCheckBox.clicked.connect(self.clippingPlanesCheckBoxChanged) self.resetButton = QPushButton("Reset") self.resetButton.clicked.connect(self.resetClippingBox) clippingLabel = QLabel("Clipping box:") clippingLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter) clippingPlanesLabel = QLabel("Clipping planes:") clippingPlanesLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter) clipLayout = QGridLayout() clipLayout.addWidget(clippingLabel, 0, 0) clipLayout.addWidget(self.clippingCheckBox, 0, 1) clipLayout.addWidget(clippingPlanesLabel, 1, 0) clipLayout.addWidget(self.clippingPlanesCheckBox, 1, 1) clipLayout.addWidget(self.resetButton, 2, 0) self.clippingGroupBox = QGroupBox() self.clippingGroupBox.setTitle("Clipping box") self.clippingGroupBox.setLayout(clipLayout) # Create a nice layout for the labels layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.slicesGroupBox, 0, 0) layout.addWidget(self.clippingGroupBox, 0, 1) self.setLayout(layout)
def _initUI(self): # Controls lbl_unknown = QLabel("No viewer for this result") lbl_unknown.setAlignment(Qt.AlignCenter) # Layouts layout = _ResultWidget._initUI(self) layout.addWidget(lbl_unknown) return layout
class TouchSpinner(QWidget): valueChanged = Signal(int) def __init__(self, parent=None): super(TouchSpinner, self).__init__(parent) self._value = 50 self._max = 100 self._min = 0 layout = QHBoxLayout() self.btnMinus = ExpandingButton() self.btnMinus.setIcon(QIcon(":icons/list-remove")) self.btnMinus.setText("-") self.btnMinus.clicked.connect(lambda: self.setValue(self._value - 1)) layout.addWidget(self.btnMinus, 1) self.lblValue = QLabel(self.formattedValue(self._value)) self.lblValue.setAlignment(Qt.AlignHCenter) layout.addWidget(self.lblValue, 1) self.btnPlus = ExpandingButton() self.btnPlus.setIcon(QIcon(":icons/list-add")) self.btnPlus.setText("+") self.btnPlus.clicked.connect(lambda: self.setValue(self._value + 1)) layout.addWidget(self.btnPlus, 1) self.setLayout(layout) def setValue(self, value): if value > self._max: newValue = self._max elif value < self._min: newValue = self._min else: newValue = value if value != self._value: self._value = newValue self.valueChanged.emit(newValue) self.lblValue.setText(self.formattedValue(newValue)) self.btnPlus.setEnabled(self._value < self._max) self.btnMinus.setEnabled(self._value > self._min) def setMaximum(self, maxi): self._max = maxi def setMinimum(self, mini): self._min = mini def value(self): return self._value def formattedValue(self, value): return "{}".format(value)
def __init__(self): super().__init__() if separate_colorbars: if rescale_colorbars: self.vmins = tuple(np.min(u[0]) for u in U) self.vmaxs = tuple(np.max(u[0]) for u in U) else: self.vmins = tuple(np.min(u) for u in U) self.vmaxs = tuple(np.max(u) for u in U) else: if rescale_colorbars: self.vmins = (min(np.min(u[0]) for u in U),) * len(U) self.vmaxs = (max(np.max(u[0]) for u in U),) * len(U) else: self.vmins = (min(np.min(u) for u in U),) * len(U) self.vmaxs = (max(np.max(u) for u in U),) * len(U) layout = QHBoxLayout() plot_layout = QGridLayout() self.colorbarwidgets = [cbar_widget(self, vmin=vmin, vmax=vmax) if cbar_widget else None for vmin, vmax in zip(self.vmins, self.vmaxs)] plots = [widget(self, grid, vmin=vmin, vmax=vmax, bounding_box=bounding_box, codim=codim) for vmin, vmax in zip(self.vmins, self.vmaxs)] if legend: for i, plot, colorbar, l in zip(range(len(plots)), plots, self.colorbarwidgets, legend): subplot_layout = QVBoxLayout() caption = QLabel(l) caption.setAlignment(Qt.AlignHCenter) subplot_layout.addWidget(caption) if not separate_colorbars or backend == 'matplotlib': subplot_layout.addWidget(plot) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) subplot_layout.addLayout(hlayout) plot_layout.addLayout(subplot_layout, int(i/columns), (i % columns), 1, 1) else: for i, plot, colorbar in zip(range(len(plots)), plots, self.colorbarwidgets): if not separate_colorbars or backend == 'matplotlib': plot_layout.addWidget(plot, int(i/columns), (i % columns), 1, 1) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) if colorbar: hlayout.addWidget(colorbar) plot_layout.addLayout(hlayout, int(i/columns), (i % columns), 1, 1) layout.addLayout(plot_layout) if not separate_colorbars: layout.addWidget(self.colorbarwidgets[0]) for w in self.colorbarwidgets[1:]: w.setVisible(False) self.setLayout(layout) self.plots = plots
def DisplayWelcome(self): WelcomeScreen = QApplication(sys.argv) appLabel = QLabel() appLabel.setText("Welcome To SparkControl: Python") appLabel.setAlignment(Qt.AlignCenter) appLabel.setWindowTitle("Spark Control Python") appLabel.setGeometry(300, 300, 250, 175) #Draw the label appLabel.show()
def DisplayWelcome(self): WelcomeScreen = QApplication(sys.argv) appLabel=QLabel() appLabel.setText("Welcome To SparkControl: Python") appLabel.setAlignment(Qt.AlignCenter) appLabel.setWindowTitle("Spark Control Python") appLabel.setGeometry(300,300,250,175) #Draw the label appLabel.show()
class WaitForServiceProvider(QFrame): def __init__(self, parent=None): super(WaitForServiceProvider, self).__init__(parent) self.setFrameStyle(QFrame.Panel | QFrame.Raised) # Global horizontal layout vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) self.image = QLabel() self.image.setAlignment(Qt.AlignCenter) def get_res(f): return resource_filename("clacks.client", "data/%s" % f) self.pixmaps = [QPixmap(get_res("network-wireless-connected-00.png")), QPixmap(get_res("network-wireless-connected-25.png")), QPixmap(get_res("network-wireless-connected-50.png")), QPixmap(get_res("network-wireless-connected-75.png")), QPixmap(get_res("network-wireless.png"))] self.pixmap_index = -1 self.rotate_image() vbox.addWidget(self.image) label = QLabel(_("Searching service provider...")) self.setStyleSheet("QWidget { background-color: #F0F0F0; color: black; padding: 5;}") label.setAlignment(Qt.AlignCenter) vbox.addWidget(label) # Finalize the window self.setLayout(vbox) self.setMinimumSize(300, 150) self.setWindowTitle(_("Searching for service provider")) # Disable close self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint) self.setGeometry((QApplication.desktop().width() - 300) / 2, (QApplication.desktop().height() - self.sizeHint().height()) / 2, 300, self.sizeHint().height()) # Start animation timer = QTimer(self) self.connect(timer, SIGNAL("timeout()"), self.rotate_image) timer.start(500) def rotate_image(self): self.pixmap_index = self.pixmap_index + 1 if self.pixmap_index >= len(self.pixmaps): self.pixmap_index = 0 self.image.setPixmap(self.pixmaps[self.pixmap_index])
def _SetUpScoreLabels( self, match ): self._CleanUpScore() for sset in match.result: for score in sset: res = "{0:d}:{1:d}".format( score[ 0 ], score[ 1 ] ) if abs( score[ 0 ] - score[ 1 ] ) == 1: res += " ({0:1d}:{1:1d})".format( sset[ score ][ -1 ][ 0 ], sset[ score ][ -1 ][ 1 ] ) label = QLabel( res ) self._label_scores.append( label ) label.setAlignment( Qt.AlignHCenter ) self.window.main_score_layout.addWidget( label )
def replace(self, unit): old_item = self.test_layout.itemAtPosition(0, 0) old_label = old_item.widget() ref = weakref.ref(old_item, self._destroyed) self.test_layout.removeWidget(old_label) unit.assertRaises(RuntimeError, old_item.widget) del old_item label = QLabel("Label New") old_label.deleteLater() label.setAlignment(Qt.AlignCenter) self.test_layout.addWidget(label, 0, 0)
def replace(self, unit): old_item = self.test_layout.itemAtPosition(0, 0) old_label = old_item.widget() ref = weakref.ref(old_item, self._destroyed) self.test_layout.removeWidget(old_label) unit.assertRaises(RuntimeError, old_item.widget) del old_item label = QLabel("Label New") old_label.deleteLater() label.setAlignment(Qt.AlignCenter) self.test_layout.addWidget(label, 0, 0)
def addPlot(self, fillLevelIn, brushIn, penIn, dataType='float', dataName=None): data = np.array([0], dtype=dataType) plot = self.graph.plot(fillLevel=fillLevelIn, brush=brushIn, pen=penIn) dataWidget = QLabel(dataName) dataWidget.dataName = dataName dataWidget.setStyleSheet('color: rgb' + str(penIn) + '; background-color: black') dataWidget.setAlignment(Qt.AlignCenter) self.dataLayout.addWidget(dataWidget) self.plots.append({'plot':plot, 'data':data, 'widget':dataWidget})
def organizeContent(self, widget): # get style metrics leftMargin = self.app.style().pixelMetric(QStyle.PM_LayoutLeftMargin) topMargin = self.app.style().pixelMetric(QStyle.PM_LayoutTopMargin) standHeight = self.app.style().pixelMetric(QStyle.PM_ButtonMargin) +\ self.app.fontMetrics().height() doubleStandHeight = standHeight * 2 hsepara = self.app.style().pixelMetric(QStyle.PM_LayoutHorizontalSpacing) vsepara = self.app.style().pixelMetric(QStyle.PM_LayoutVerticalSpacing) # calculate grids col0Left = leftMargin col1Left = leftMargin + doubleStandHeight + vsepara col2Left = leftMargin + doubleStandHeight + standHeight + 2*vsepara col3Left = leftMargin + 2*doubleStandHeight + standHeight + 4*vsepara row0Top = topMargin row1Top = topMargin + standHeight + hsepara row2Top = topMargin + 3*standHeight + 2*hsepara row3Top = topMargin + 4*standHeight + 3*hsepara btnUp = QPushButton('Up', widget) btnUp.setGeometry(col1Left, row1Top, standHeight, doubleStandHeight) btnLeft = QPushButton('Left', widget) btnLeft.setGeometry(col0Left, row2Top, doubleStandHeight, standHeight) txtQuant = QLineEdit(widget) txtQuant.setGeometry(col1Left, row2Top, standHeight, standHeight) txtQuant.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) btnRight = QPushButton('Right', widget) btnRight.setGeometry(col2Left, row2Top, doubleStandHeight, standHeight) btnDown = QPushButton('Dn', widget) btnDown.setGeometry(col1Left, row3Top, standHeight, doubleStandHeight) lb3 = QLabel('Elevation:', widget) lb3.setGeometry(col3Left, row2Top, lb3.sizeHint().width(), standHeight) wi = self.app.fontMetrics().width('Horizontal:') + 2 lb4 = QLabel('Horizontal:', widget) lb4.setGeometry(col3Left, row3Top, wi, standHeight) col4Left = leftMargin + 2*doubleStandHeight + standHeight + 5*vsepara + wi txtElev = QLineEdit(widget) txtElev.setGeometry(col4Left, row2Top, doubleStandHeight, standHeight) txtElev.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) txtHoriz = QLineEdit(widget) txtHoriz.setGeometry(col4Left, row3Top, doubleStandHeight, standHeight) txtHoriz.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) lb2 = QLabel('Angles in degrees', widget) lb2.setGeometry(col3Left, row2Top - standHeight - hsepara, wi + hsepara + doubleStandHeight, standHeight) lb2.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) #Qt.AlignVCenter totalWi = col4Left + doubleStandHeight - col0Left totalHi = row3Top + doubleStandHeight - row0Top lb1 = QLabel('Camera position control panel', widget) lb1.setGeometry(col0Left, row0Top, totalWi, standHeight) lb1.setAlignment(Qt.AlignVCenter | Qt.AlignCenter) lb1.setFrameStyle(QFrame.Box)
def getAppLabel(self): ''' Gets label to be displayed in widget ''' appTitle = QLabel(CUSTOMER_NAME) appTitle.setAlignment(Qt.AlignCenter) appTitle.setFixedHeight( QApplication.desktop().screenGeometry().height() / 20) appTitle.setStyleSheet( "border-style:ridge;border: 2px solid red; border-radius: 3px;" "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #7EC0EE, stop: 1 #7EC0EE);" "min-width: 40px;color: red;font-size: 54px; font-style=bold italic large 'New Century Schoolbook'" ) return appTitle
def _create_label ( self, dialog, layout, text ): dummy = QLabel( text, dialog ) dummy.setAlignment( Qt.AlignTop | Qt.AlignLeft ) label = QLabel( "unknown", dialog ) label.setAlignment( Qt.AlignTop | Qt.AlignLeft | Qt.AlignRight ) sub_layout = QHBoxLayout() sub_layout.addWidget( dummy ) sub_layout.addWidget( label ) layout.addLayout( sub_layout ) return label
def makeContent(self): layout = QHBoxLayout() # self.exposureControls = ExposureControl(self.camera) # layout.addWidget(self.exposureControls) whiteBalanceGrid = QGridLayout() wbTitle = QLabel("White Balance") wbTitle.setAlignment(Qt.AlignCenter) whiteBalanceGrid.addWidget(wbTitle, 0, 0, 1, 2) btnAuto = OptionButton() btnAuto.setText("Auto") _safelyConnect(btnAuto.clicked, self.camera.whiteBalanceAuto) whiteBalanceGrid.addWidget(btnAuto, 1, 0) btnIndoor = OptionButton() btnIndoor.setText("Indoor") _safelyConnect(btnIndoor.clicked, self.camera.whiteBalanceIndoor) whiteBalanceGrid.addWidget(btnIndoor, 2, 0) btnOutdoor = OptionButton() btnOutdoor.setText("Outdoor") _safelyConnect(btnOutdoor.clicked, self.camera.whiteBalanceOutdoor) whiteBalanceGrid.addWidget(btnOutdoor, 3, 0) btnOnePush = OptionButton() btnOnePush.setText("One Push") _safelyConnect(btnOnePush.clicked, self.camera.whiteBalanceOnePush) whiteBalanceGrid.addWidget(btnOnePush, 4, 0) btnOnePushTrigger = ExpandingButton() btnOnePushTrigger.setText("Set") _safelyConnect(btnOnePushTrigger.clicked, self.camera.whiteBalanceOnePushTrigger) btnOnePushTrigger.setEnabled(False) whiteBalanceGrid.addWidget(btnOnePushTrigger, 4, 1) self.wbOpts = QButtonGroup() self.wbOpts.addButton(btnAuto, 1) self.wbOpts.addButton(btnIndoor, 2) self.wbOpts.addButton(btnOutdoor, 3) self.wbOpts.addButton(btnOnePush, 4) self.wbOpts.buttonClicked.connect(lambda: btnOnePushTrigger.setEnabled(self.wbOpts.checkedId() == 4)) layout.addLayout(whiteBalanceGrid) return layout
def __init__(self, dsk, atem, parent=None): super(OverlayControl, self).__init__(parent) self.atem = atem self.dsk = dsk dsk.changedState.connect(self.update_from_dsk) layout = QGridLayout() lbl = QLabel("Overlay on main output:") lbl.setAlignment(Qt.AlignHCenter) layout.addWidget(lbl, 0, 0, 2, 1) self.onAirButton = ExpandingButton() self.onAirButton.setText("On Air") self.onAirButton.setCheckable(True) self.onAirButton.clicked.connect(self.setOnAir) layout.addWidget(self.onAirButton, 0, 1, 2, 1) self.autoButton = ExpandingButton() self.autoButton.setText("Auto Fade") self.autoButton.clicked.connect(self.takeAuto) layout.addWidget(self.autoButton, 2, 1, 2, 1) lblRate = QLabel("Rate:") lblRate.setAlignment(Qt.AlignHCenter | Qt.AlignBottom) layout.addWidget(lblRate, 2, 0) self.rate = FrameRateTouchSpinner() self.rate.setMinimum(1) self.rate.setMaximum(250) self.rate.setValue(25) self.rate.valueChanged.connect(self.setRate) layout.addWidget(self.rate, 3, 0) layout.setRowStretch(0, 1) layout.setRowStretch(1, 1) layout.setRowStretch(2, 1) layout.setRowStretch(3, 1) self.resetParams() self.update_from_dsk() self.setLayout(layout)
def firstPage(self): for i in range( self.mainLayout.count() ): item = self.mainLayout.itemAt(0) item.widget().setParent( None ) title = QLabel( "<p style='color:rgb( 137,129,120 )'>Welcome to the PingoTools Installer</p>" ) title.setFixedHeight( 50 ) titleFont = QFont() titleFont.setPixelSize( 18 ) titleFont.setBold( True ) titleFont.setFamily( "Helvetica [Cronyx]" ) title.setAlignment( QtCore.Qt.AlignCenter ) title.setFont( titleFont ) description = QLabel() description.setAlignment( QtCore.Qt.AlignCenter ) buttonsWidget = QWidget(); buttonsWidget.setMaximumHeight( 50 ) buttonsLayout = QHBoxLayout( buttonsWidget ) emptyArea = QLabel() buttonNext = QPushButton( 'Next > ' ) buttonCancel = QPushButton( 'Cancel' ) buttonsLayout.addWidget( emptyArea ) buttonsLayout.addWidget( buttonNext ); buttonNext.setFixedWidth( 100 ) buttonsLayout.addWidget( buttonCancel ); buttonCancel.setFixedWidth( 100 ) self.mainLayout.addWidget( title ) self.mainLayout.addWidget( description ) self.mainLayout.addWidget( buttonsWidget ) origWidth = 500 frontImage = QImage() frontImage.load( os.path.dirname( __file__ ) + '/images/pingoTools_main.jpg' ) trValue = QTransform().scale( float(origWidth)/frontImage.width(), float(origWidth)/frontImage.width() ) transformedImage = frontImage.transformed( trValue ) pixmap = QPixmap.fromImage( transformedImage ) description.setPixmap( pixmap ) description.setGeometry( 0,0, transformedImage.width() , transformedImage.height() ) description.paintEvent(QPaintEvent(QtCore.QRect( 0,0,self.width(), self.height() ))) QtCore.QObject.connect( buttonNext, QtCore.SIGNAL( 'clicked()' ), self.secondPage ) QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL( 'clicked()' ), self.cmd_cancel )
class TitleWidget(QWidget): """ TitleWidget holds a title. And paints the background with a gradient. """ TitleHeight = 20 def __init__(self, title=None): super(TitleWidget, self).__init__() if sys.platform.startswith("darwin"): color1 = QColor(230, 230, 230, 255) color2 = QColor(177, 177, 177, 255) gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, TitleWidget.TitleHeight) gradient.setColorAt(0, color1) gradient.setColorAt(1, color2) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setPalette(palette) self.setAutoFillBackground(True) self.setMaximumHeight(TitleWidget.TitleHeight) self.setMinimumHeight(TitleWidget.TitleHeight) self.titleLabel = QLabel("", parent=self) font = self.titleLabel.font() font.setPixelSize(11) self.titleLabel.setFont(font) self.titleLabel.setAlignment(Qt.AlignCenter) self.titleLabel.setText(title) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.titleLabel) self.setLayout(layout) def setText(self, title): self.title = title self.titleLabel.setText(self.title)
class TitleWidget(QWidget): """ TitleWidget holds a title. And paints the background with a gradient. """ TitleHeight = 20 def __init__(self, title=None): super(TitleWidget, self).__init__() if sys.platform.startswith("darwin"): color1 = QColor(230, 230, 230, 255) color2 = QColor(177, 177, 177, 255) gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, TitleWidget.TitleHeight) gradient.setColorAt(0, color1) gradient.setColorAt(1, color2) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setPalette(palette) self.setAutoFillBackground(True) self.setMaximumHeight(TitleWidget.TitleHeight) self.setMinimumHeight(TitleWidget.TitleHeight) self.titleLabel = QLabel("", parent=self) font = self.titleLabel.font() font.setPixelSize(11) self.titleLabel.setFont(font) self.titleLabel.setAlignment(Qt.AlignCenter) self.titleLabel.setText(title) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.titleLabel) self.setLayout(layout) def setText(self, title): self.title = title self.titleLabel.setText(self.title)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.h0 = QHBoxLayout() self.lineArray = [] labelArray = [u'時間', u'值班', u'救護勤務', u'備勤', u'待命服勤', u'水源查察', u'消防查察', u'宣導勤務', u'訓(演)練', u'專案勤務', u'南山救護站'] for i in labelArray: label = QLabel(i) label.setFixedWidth(100) label.setAlignment(Qt.AlignCenter) self.h0.addWidget(label) self.h0.addSpacing(15) self.v0 = QVBoxLayout() self.v0.addLayout(self.h0) for i in xrange(24): hn = QHBoxLayout() for j in xrange(len(labelArray)): if j == 0: time = i+8 if (i+8)< 24 else i+8-24 line = QLabel("%s:00~%s:00" % (str(time).zfill(2), str(time+1).zfill(2))) else: line = QLineEdit() self.lineArray.append(line) line.setFixedWidth(100) hn.addSpacing(15) hn.addWidget(line) self.v0.addLayout(hn) self.h1 = QHBoxLayout() self.clearPB = QPushButton("Clear All") self.clearPB.setFixedWidth(200) self.clearPB.setFixedHeight(50) self.clearPB.clicked.connect(self.clear) self.h1.addStretch() self.h1.addWidget(self.clearPB) self.h1.addStretch() self.v0.addLayout(self.h1) self.setLayout(self.v0)
def __init__(self, name=None): super(SensorDisplay, self).__init__() self.graph = pg.PlotWidget(name=name) self.plots = [] title = QLabel(name) title.setStyleSheet('color: white; background-color: black') title.setAlignment(Qt.AlignCenter) self.setFixedHeight(150) mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0,0,0,0) mainLayout.setSpacing(0) self.setLayout(mainLayout) self.dataLayout = QHBoxLayout() self.dataLayout.setContentsMargins(0,0,0,0) self.dataLayout.setSpacing(0) mainLayout.addWidget(title) mainLayout.addWidget(self.graph) mainLayout.addLayout(self.dataLayout)
def __init__(self, preference_name, label, parent=None): super(SensitivityPreference, self).__init__(parent) self.preference_name = preference_name layout = QHBoxLayout() label = QLabel(label) label.setAlignment(Qt.AlignRight) layout.addWidget(label, 1) self.spinner = TouchSpinner() self.spinner.setMaximum(10) self.spinner.setMinimum(1) self.update_from_preferences() Preferences.subscribe(self.update_from_preferences) self.spinner.valueChanged.connect(lambda v: Preferences.set(preference_name, float(v) / 10)) layout.addWidget(self.spinner, 2) self.setLayout(layout)
def setup_ui(self): main_layout = QHBoxLayout(self) edt = QLineEdit(self) edt.setPlaceholderText("Wildcard filter") btn = QToolButton(self) btn.clicked.connect(self.set_icon) layout = QHBoxLayout(self) layout.addWidget(edt) layout.addWidget(btn) layout2 = QVBoxLayout() layout2.addLayout(layout) model = TListModel(self) proxy = QSortFilterProxyModel(self) proxy.setFilterCaseSensitivity(Qt.CaseInsensitive) proxy.setSourceModel(model) edt.textChanged.connect(proxy.setFilterWildcard) list = QListView() list.setModel(proxy) selection_model = list.selectionModel() selection_model.currentChanged.connect(self.currentChanged) layout2.addWidget(list) main_layout.addLayout(layout2) image = QLabel("Select icon", self) image.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) image.setMinimumWidth(256) main_layout.addWidget(image) self.btn = btn self.edt = edt self.image = image self.list = list self.proxy = proxy self.model = model self.selection_model = selection_model
def _init_widgets(self): layout = QHBoxLayout() size_label = QLabel() size_label.setProperty('class', 'ast_viewer_size') size_label.setAlignment(Qt.AlignRight) size_label.setMaximumSize(QSize(24, 65536)) self._size_label = size_label ast_label = QLabel() self._ast_label = ast_label if self._ast is not None: self.reload() if self._display_size: layout.addWidget(self._size_label) layout.addWidget(ast_label) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self, parent=None): super(MainMixControl, self).__init__(parent) layout = QGridLayout() label = QLabel('Main mix', None) label.setAlignment(Qt.AlignHCenter) layout.addWidget(label, 0, 0, 1, 2) btnTake = ExpandingButton() btnTake.setProperty("class", "mainMix") btnTake.setText("Cut") btnTake.clicked.connect(self.cut.emit) layout.addWidget(btnTake, 1, 0) btnFade = ExpandingButton() btnFade.setProperty("class", "mainMix") btnFade.setText("Fade") btnFade.clicked.connect(self.take.emit) layout.addWidget(btnFade, 1, 1) self.setLayout(layout)
class OutputButton(LongPressButtonMixin, ExpandingButton): def __init__(self, myOutput, parent=None): super(OutputButton, self).__init__(parent) self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly ) # Sneakily hide our actual text self.textDisplay = QLabel() self.stateDisplay = QLabel() layout = QVBoxLayout() layout.addWidget(self.textDisplay) layout.addWidget(self.stateDisplay) self.textDisplay.setObjectName("textDisplay") self.stateDisplay.setObjectName("stateDisplay") self.stateDisplay.setAlignment(Qt.AlignHCenter) self.setLayout(layout) self.output = myOutput self.output.changedState.connect(self._update_from_output) self._update_from_output() def _update_from_output(self): self.setText(self.output.label) if self.output.source and hasattr(self.output.source, "label"): self.stateDisplay.setText(self.output.source.label) self.stateDisplay.setProperty( "highlight", (self.output.source.source != VideoSource.ME_1_PROGRAM)) else: self.stateDisplay.setText("-") self.stateDisplay.setProperty("highlight", False) self.stateDisplay.style().unpolish(self.stateDisplay) self.stateDisplay.style().polish(self.stateDisplay) def setText(self, text): self.textDisplay.setText(text) super(OutputButton, self).setText(text)
def __init__(self, *args, **kwargs): super(Widget_textEdit_splitter, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) w_convertButton = QWidget() lay_convertButton = QHBoxLayout(w_convertButton) label_orig = QLabel("Original") label_orig.setAlignment(QtCore.Qt.AlignCenter) label_convert = QLabel("Converted") label_convert.setAlignment(QtCore.Qt.AlignCenter) button = QPushButton(" >> ") lay_convertButton.addWidget(label_orig) lay_convertButton.addWidget(button) lay_convertButton.addWidget(label_convert) w_convertButton.setStyleSheet("font-size:13px") sizePolicy = QSizePolicy() sizePolicy.setVerticalPolicy(QSizePolicy.Fixed) sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding) w_convertButton.setSizePolicy(sizePolicy) splitter = QSplitter() splitter.setStretchFactor(1, 1) textEdit_left = QTextEdit() textEdit_right = QTextEdit() splitter.addWidget(textEdit_left) splitter.addWidget(textEdit_right) textEdit_left.setLineWrapMode(QTextEdit.NoWrap) textEdit_right.setLineWrapMode(QTextEdit.NoWrap) mainLayout.addWidget(w_convertButton) mainLayout.addWidget(splitter) self.textEdit_left = textEdit_left self.textEdit_right = textEdit_right button.clicked.connect(self.load_convertedText)
def __init__(self): super(PlotWidget, self).__init__() if separate_colorbars: vmins = tuple(np.min(u) for u in U) vmaxs = tuple(np.max(u) for u in U) else: vmins = (min(np.min(u) for u in U),) * len(U) vmaxs = (max(np.max(u) for u in U),) * len(U) layout = QHBoxLayout() plot_layout = QGridLayout() plots = [widget(self, grid, vmin=vmin, vmax=vmax, bounding_box=bounding_box, codim=codim) for vmin, vmax in izip(vmins, vmaxs)] if legend: for i, plot, l in izip(xrange(len(plots)), plots, legend): subplot_layout = QVBoxLayout() caption = QLabel(l) caption.setAlignment(Qt.AlignHCenter) subplot_layout.addWidget(caption) if not separate_colorbars or backend == 'matplotlib': subplot_layout.addWidget(plot) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) hlayout.addWidget(ColorBarWidget(self, vmin=vmins[i], vmax=vmaxs[i])) subplot_layout.addLayout(hlayout) plot_layout.addLayout(subplot_layout, int(i/2), (i % 2), 1, 1) else: for i, plot in enumerate(plots): if not separate_colorbars or backend == 'matplotlib': plot_layout.addWidget(plot, int(i/2), (i % 2), 1, 1) else: hlayout = QHBoxLayout() hlayout.addWidget(plot) hlayout.addWidget(ColorBarWidget(self, vmin=vmins[i], vmax=vmaxs[i])) plot_layout.addLayout(plot, int(i/2), (i % 2), 1, 1) layout.addLayout(plot_layout) if not separate_colorbars: layout.addWidget(ColorBarWidget(self, vmin=vmin, vmax=vmax)) self.setLayout(layout) self.plots = plots
def __init__(self, preference_name, label, parent=None): super(SensitivityPreference, self).__init__(parent) self.preference_name = preference_name layout = QHBoxLayout() label = QLabel(label) label.setAlignment(Qt.AlignRight) layout.addWidget(label, 1) self.spinner = TouchSpinner() self.spinner.setMaximum(10) self.spinner.setMinimum(1) self.update_from_preferences() Preferences.subscribe(self.update_from_preferences) self.spinner.valueChanged.connect( lambda v: Preferences.set(preference_name, float(v) / 10)) layout.addWidget(self.spinner, 2) self.setLayout(layout)
class UI_labels(QWidget): def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.installEventFilter(self) self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.text_srcAttr = QLabel('Source Attr') self.text_dstAttr = QLabel('Dest Attr') self.text_srcAttr.setAlignment(QtCore.Qt.AlignCenter) self.text_dstAttr.setAlignment(QtCore.Qt.AlignCenter) self.layout.addWidget(self.text_srcAttr) self.layout.addWidget(self.text_dstAttr) def eventFilter(self, *args, **kwargs): event = args[1] if event.type() == QtCore.QEvent.LayoutRequest or event.type( ) == QtCore.QEvent.Move: pass
class PlusMinusButtons(QWidget): def __init__(self, caption, upBinding, downBinding): super(PlusMinusButtons, self).__init__() self.upButton = CameraButton(upBinding) self.upButton.setIcon(QIcon("icons/list-add.svg")) self.downButton = CameraButton(downBinding) self.downButton.setIcon(QIcon("icons/list-remove.svg")) self.caption = QLabel("<b>" + caption + "</b>") self.caption.setAlignment(Qt.AlignHCenter | Qt.AlignTop) self.initLayout() def initLayout(self): layout = QGridLayout() self.setLayout(layout) layout.addWidget(self.upButton, 0, 0) layout.addWidget(self.caption, 1, 0) layout.addWidget(self.downButton, 2, 0) layout.setRowStretch(0, 2) layout.setRowStretch(1, 2) layout.setRowStretch(2, 2) def connectPressed(self, connection): self.upButton.pressed.connect(connection) self.downButton.pressed.connect(connection) def connectReleased(self, connection): self.upButton.released.connect(connection) self.downButton.released.connect(connection) def connectClicked(self, connection): self.upButton.clicked.connect(connection) self.downButton.clicked.connect(connection)
class UI_labels(QWidget): def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.installEventFilter(self) self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.text_key = QLabel('Float') self.text_value = QLabel('Value') self.text_key.setAlignment(QtCore.Qt.AlignCenter) self.text_value.setAlignment(QtCore.Qt.AlignCenter) self.layout.addWidget(self.text_key) self.layout.addWidget(self.text_value) def eventFilter(self, *args, **kwargs): event = args[1] if event.type() == QtCore.QEvent.LayoutRequest or event.type( ) == QtCore.QEvent.Move: pass
class OutputButton(LongPressButtonMixin, ExpandingButton): def __init__(self, myOutput, parent=None): super(OutputButton, self).__init__(parent) self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) # Sneakily hide our actual text self.textDisplay = QLabel() self.stateDisplay = QLabel() layout = QVBoxLayout() layout.addWidget(self.textDisplay) layout.addWidget(self.stateDisplay) self.textDisplay.setObjectName("textDisplay") self.stateDisplay.setObjectName("stateDisplay") self.stateDisplay.setAlignment(Qt.AlignHCenter) self.setLayout(layout) self.output = myOutput self.output.changedState.connect(self._update_from_output) self._update_from_output() def _update_from_output(self): self.setText(self.output.label) if self.output.source and hasattr(self.output.source, "label"): self.stateDisplay.setText(self.output.source.label) self.stateDisplay.setProperty("highlight", (self.output.source.source != VideoSource.ME_1_PROGRAM)) else: self.stateDisplay.setText("-") self.stateDisplay.setProperty("highlight", False) self.stateDisplay.style().unpolish(self.stateDisplay) self.stateDisplay.style().polish(self.stateDisplay) def setText(self, text): self.textDisplay.setText(text) super(OutputButton, self).setText(text)
class QBigDataDisplay(QDataDisplay): def __init__(self, parent, label, units): QDataDisplay.__init__(self, parent) self.units = units self.buildLabels(label) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(self.label) vbox.addWidget(self.data) vbox.addStretch(1) self.setLayout(vbox) def buildLabels(self, label): self.label = QLabel(label) self.data = QLabel(constants.DEFAULT_LABEL) # Center the text in the labels self.label.setAlignment(Qt.AlignCenter) self.data.setAlignment(Qt.AlignCenter) # Bold the label label labelFont = QFont() labelFont.setBold(True) # Make the data label font obnoxiously large dataFont = QFont() dataFont.setPixelSize(20) self.label.setFont(labelFont) self.data.setFont(dataFont) def setData(self, data): # Show floats with two decimals text = '%.2f' % data if isinstance(data, float) else str(data) self.data.setText('%s%s' % (text, self.units))
class QBigDataDisplay(QDataDisplay): def __init__(self, parent, label, units): QDataDisplay.__init__(self, parent) self.units = units self.buildLabels(label) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(self.label) vbox.addWidget(self.data) vbox.addStretch(1) self.setLayout(vbox) def buildLabels(self, label): self.label = QLabel(label) self.data = QLabel(constants.DEFAULT_LABEL) # Center the text in the labels self.label.setAlignment(Qt.AlignCenter) self.data.setAlignment(Qt.AlignCenter) # Bold the label label labelFont = QFont() labelFont.setBold(True) # Make the data label font obnoxiously large dataFont = QFont() dataFont.setPixelSize(20) self.label.setFont(labelFont) self.data.setFont(dataFont) def setData(self, data): # Show floats with two decimals text = '%.2f' % data if isinstance(data, float) else str(data) self.data.setText('%s%s' % (text, self.units))
def lastPage(self): for i in range( self.mainLayout.count() ): item = self.mainLayout.itemAt(0) item.widget().setParent( None ) title = QLabel( "".decode( 'utf-8' ) ) title.setFixedHeight( 50 ) description = QLabel( "<p style='line-height:150%';'><b>PingoTools</b> 인스톨이 완료되었습니다.<p>".decode( 'utf-8' ) ) description.setAlignment( QtCore.Qt.AlignCenter ) buttonsWidget = QWidget(); buttonsWidget.setMaximumHeight( 50 ) buttonsLayout = QHBoxLayout( buttonsWidget ) emptyArea = QLabel() buttonClose = QPushButton( 'Close' ); buttonClose.setFixedWidth( 100 ) buttonsLayout.addWidget( emptyArea ) buttonsLayout.addWidget( buttonClose ) self.mainLayout.addWidget( title ) self.mainLayout.addWidget( description ) self.mainLayout.addWidget( buttonsWidget ) QtCore.QObject.connect( buttonClose, QtCore.SIGNAL( 'clicked()' ), self.cmd_close )
def __init__(self, title, mainWindow): super(ScreenWithBackButton, self).__init__() self.title = title self.mainWindow = mainWindow layout = QGridLayout() title = QLabel(title) title.setStyleSheet("font-size: 48px;") title.setAlignment(Qt.AlignCenter) layout.addWidget(title, 0, 0, 1, 7) layout.addLayout(self.makeContent(), 1, 0, 1, 7) b = ExpandingButton() b.setText("Back") b.setIcon(QIcon(":icons/go-previous")) b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) b.clicked.connect(mainWindow.stepBack) layout.addWidget(b, 2, 0, 1, 3) layout.setRowStretch(0, 1) layout.setRowStretch(1, 6) layout.setRowStretch(2, 1) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) layout = QHBoxLayout(self) label = QLabel() label.setFixedWidth(120) layout.addWidget(label) labelX = QLabel('X Range') labelY = QLabel('Y Range') labelZ = QLabel('Z Range') labelX.setAlignment(QtCore.Qt.AlignCenter) labelY.setAlignment(QtCore.Qt.AlignCenter) labelZ.setAlignment(QtCore.Qt.AlignCenter) layout.addWidget(labelX) layout.addWidget(labelY) layout.addWidget(labelZ)
class MTTStatusLine(QHBoxLayout): """ Create custom toolbar with collapse Maya Status Line behavior """ viewerToggled = Signal() filterSelectionToggled = Signal(bool) pinModeToggled = Signal(bool) externalVizToggled = Signal() def __init__(self, settings_menu, model, proxy): super(MTTStatusLine, self).__init__() self.settings_menu = settings_menu self.model = model self.proxy = proxy self.__create_ui() self.__init_ui() def __create_ui(self): # FILTERS scroll_area = StatusScrollArea() scroll_area.add_widget(self._create_filter_group()) scroll_area.add_widget(self._create_visibility_group()) scroll_area.add_widget(self._create_folder_group()) scroll_area.add_widget(self._create_auto_group()) scroll_area.add_widget(self._create_mtt_tools_group()) scroll_area.add_widget(self._create_maya_tools_group()) user_grp = self._create_user_group() if user_grp: scroll_area.add_widget(user_grp) self.addWidget(scroll_area) # STATS information self.stat_info = QLabel() self.stat_info.setAlignment(Qt.AlignCenter | Qt.AlignRight) self.stat_info.setText('0 File | 0/0 Node') self.stat_info.setToolTip( 'number of files | number of nodes shown / total number of nodes') self.addWidget(self.stat_info) # SETTINGS button self.info_btn = mttCmdUi.create_status_button(':/tb_config', 'Settings', None, False) self.info_btn.setMenu(self.settings_menu) self.addWidget(self.info_btn) def __init_ui(self): self.setContentsMargins(0, 0, 0, 0) self.setAlignment(Qt.AlignLeft) # FILTER GROUP self.selection_btn.setChecked(MTTSettings.value('onlySelectionState')) self.writable_btn.setChecked(MTTSettings.value('onlyWritableState')) self.reference_btn.setChecked(MTTSettings.value('showReferenceState')) self.wrong_name_btn.setChecked(MTTSettings.value('showWrongNameState')) self.filter_instances_btn.setChecked( MTTSettings.value('filterInstances')) self.filter_grp.set_current_state(MTTSettings.value('filterGroup')) # VISIBILITY GROUP self.wrong_name_visibility_btn.setChecked( MTTSettings.value('vizWrongNameState')) self.wrong_path_visibility_btn.setChecked( MTTSettings.value('vizWrongPathState')) self.external_visibility_btn.setChecked( MTTSettings.value('vizExternalState')) self.basename_visibility_btn.setChecked( MTTSettings.value('showBasenameState')) self.namespace_visibility_btn.setChecked( not MTTSettings.value('showNamespaceState')) self.visibility_grp.set_current_state( MTTSettings.value('visibilityGroup')) # FOLDER GROUP self.folder_grp.set_current_state(MTTSettings.value('folderGroup')) # AUTO GROUP self.auto_reload_btn.setChecked(MTTSettings.value('autoReload')) self.auto_select_btn.setChecked(MTTSettings.value('autoSelect')) self.auto_rename_btn.setChecked(MTTSettings.value('autoRename')) self.auto_grp.set_current_state(MTTSettings.value('autoGroup')) # MTT TOOLS self.viewer_btn.setChecked(MTTSettings.value('viewerState')) self.tool_grp.set_current_state(MTTSettings.value('toolGroup', 1)) # MAYA TOOLS SHORTCUT self.maya_grp.set_current_state(MTTSettings.value('mayaGroup', 1)) def _create_filter_group(self): # create toolbar buttons self.selection_btn = mttCmdUi.create_status_button( ':/tb_onlySelection', 'Show textures applied to current selection', self.on_show_only_selection, True) self.writable_btn = mttCmdUi.create_status_button( ':/tb_onlyWritable', 'Hide read-only textures', self.on_show_only_writable, True) self.reference_btn = mttCmdUi.create_status_button( ':/tb_onlyReference', 'Hide references', self.on_show_reference, True) self.pin_btn = mttCmdUi.create_status_button(':/tb_onlyPinned', 'Pin textures', self.on_pin_nodes, True) self.wrong_name_btn = mttCmdUi.create_status_button( ':/tb_onlyWrongName', 'Show Node name clashing with Texture name', self.on_show_wrong_name, True) self.filter_instances_btn = mttCmdUi.create_status_button( ':/tb_hideInstances', 'Show only one instance per file', self.on_filter_instances, True) # sort toolbar buttons self.filter_grp = StatusCollapsibleLayout( section_name='Show/Hide the filter icons') self.filter_grp.add_button(self.pin_btn) self.filter_grp.add_button(self.selection_btn) self.filter_grp.add_button(self.reference_btn) self.filter_grp.add_button(self.writable_btn) self.filter_grp.add_button(self.wrong_name_btn) self.filter_grp.add_button(self.filter_instances_btn) return self.filter_grp def _create_visibility_group(self): # create toolbar buttons self.wrong_name_visibility_btn = mttCmdUi.create_status_button( ':/tb_vizWrongName', 'Highlight Node name clashing with Texture name', self.on_wrong_name_visibility, True) self.external_visibility_btn = mttCmdUi.create_status_button( ':/tb_vizExternal', 'Highlight Texture path that comes from outside current workspace', self.on_external_visibility, True) self.wrong_path_visibility_btn = mttCmdUi.create_status_button( ':/tb_vizWrongPath', 'Highlight Texture path clashing with user defined path pattern', self.on_wrong_path_visibility, True) self.basename_visibility_btn = mttCmdUi.create_status_button( ':/tb_vizBasename', 'Show files texture name only', self.on_basename_visibility, True) self.namespace_visibility_btn = mttCmdUi.create_status_button( ':/tb_vizNamespace', 'Toggle namespace visibility', self.on_namespace_visibility, True) # sort toolbar buttons self.visibility_grp = StatusCollapsibleLayout( section_name='Show/Hide the visibility icons') self.visibility_grp.add_button(self.namespace_visibility_btn) self.visibility_grp.add_button(self.wrong_name_visibility_btn) self.visibility_grp.add_button(self.external_visibility_btn) self.visibility_grp.add_button(self.wrong_path_visibility_btn) self.visibility_grp.add_button(self.basename_visibility_btn) return self.visibility_grp def _create_folder_group(self): self.folder_grp = StatusCollapsibleLayout( section_name='Show/Hide the folder icons') # create toolbar buttons self.folder_grp.add_button( mttCmdUi.create_status_button(':/tb_folderMap', 'Open sourceimages folder', self.on_open_sourceimages_folder, False)) self.folder_grp.add_button( mttCmdUi.create_status_button(':/tb_folderSrc', 'Open source folder', self.on_open_source_folder, False)) return self.folder_grp def _create_auto_group(self): # create toolbar buttons self.auto_reload_btn = mttCmdUi.create_status_button( ':/tb_toolbar_autoReload', 'Auto Reload Textures', self.on_auto_reload, True) self.auto_select_btn = mttCmdUi.create_status_button( ':/tb_toolbar_autoSelect', 'Auto Select Textures Node', self.on_auto_select, True) self.auto_rename_btn = mttCmdUi.create_status_button( ':/tb_toolbar_autoRename', 'Auto Rename Textures Node', self.on_auto_rename, True) # sort toolbar buttons self.auto_grp = StatusCollapsibleLayout( section_name='Show/Hide the auto actions icons') self.auto_grp.add_button(self.auto_reload_btn) self.auto_grp.add_button(self.auto_select_btn) self.auto_grp.add_button(self.auto_rename_btn) return self.auto_grp def _create_mtt_tools_group(self): # create toolbar buttons self.viewer_btn = mttCmdUi.create_status_button( ':/tb_Viewer', 'Show/Hide Viewer', self.on_toggle_viewer, False) create_node_btn = mttCmdUi.create_status_button( ':/tb_toolCreateNode', 'Create Node', self.on_create_node, False) # sort toolbar buttons self.tool_grp = StatusCollapsibleLayout( section_name='Show/Hide the tools icons') self.tool_grp.add_button(self.viewer_btn) self.tool_grp.add_button(create_node_btn) return self.tool_grp def _create_maya_tools_group(self): # sort toolbar buttons self.maya_grp = StatusCollapsibleLayout( section_name='Show/Hide the Maya tools icons') # create toolbar buttons self.maya_grp.add_button( mttCmdUi.create_status_button(':/tb_Hypershade', 'Hypershade', self.on_open_hypershade, False)) self.maya_grp.add_button( mttCmdUi.create_status_button(':/tb_NodeEditor', 'Node Editor', self.on_open_node_editor, False)) self.maya_grp.add_button( mttCmdUi.create_status_button(':/tb_UVEditor', 'UV Texture Editor', self.on_open_uv_editor, False)) return self.maya_grp def _create_user_group(self): if MTTSettings.CUSTOM_BUTTONS: self.custom_grp = StatusCollapsibleLayout( section_name='Show/Hide custom tools') for btnData in MTTSettings.CUSTOM_BUTTONS: self.custom_grp.add_button( mttCmdUi.create_status_button(btnData[0], btnData[1], eval(btnData[2]), False)) return self.custom_grp def _set_filter_value(self, key, value): self.model.layoutAboutToBeChanged.emit() MTTSettings.set_value(key, value) cmds.optionVar(stringValue=('filtered_instances', '')) self.model.layoutChanged.emit() self.update_node_file_count() def on_show_only_selection(self): """ Filter nodes from current selection """ state = self.selection_btn.isChecked() MTTSettings.set_value('onlySelectionState', state) self.filterSelectionToggled.emit(state) def on_show_only_writable(self): """ Filter nodes with their file state """ self._set_filter_value('onlyWritableState', self.writable_btn.isChecked()) def on_show_reference(self): """ Filter referenced nodes """ self._set_filter_value('showReferenceState', self.reference_btn.isChecked()) def on_pin_nodes(self): """ Filter pinned nodes """ self.pinModeToggled.emit(self.pin_btn.isChecked()) def on_show_wrong_name(self): """ Filter node with the same name as texture """ self._set_filter_value('showWrongNameState', self.wrong_name_btn.isChecked()) def on_wrong_name_visibility(self): """ Highlight node with the same name as texture """ self._set_filter_value('vizWrongNameState', self.wrong_name_visibility_btn.isChecked()) def on_wrong_path_visibility(self): """ Highlight Texture path clashing with user defined path pattern """ self._set_filter_value('vizWrongPathState', self.wrong_path_visibility_btn.isChecked()) def on_external_visibility(self): """ Highlight Texture path that comes from outside current workspace """ state = self.external_visibility_btn.isChecked() self._set_filter_value('vizExternalState', state) if state: self.externalVizToggled.emit() def on_basename_visibility(self): """ Filter file path """ self._set_filter_value('showBasenameState', self.basename_visibility_btn.isChecked()) def on_namespace_visibility(self): """ Filter namespace name """ self._set_filter_value('showNamespaceState', not self.namespace_visibility_btn.isChecked()) def on_filter_instances(self): """ Show only one instance per file """ self._set_filter_value('filterInstances', self.filter_instances_btn.isChecked()) def on_open_sourceimages_folder(self): """ Open sourceimages folder """ folder_path = self.model.get_sourceimages_path() if os.path.isdir(folder_path): os.startfile(folder_path) # launchImageEditor can be an alternative # cmds.launchImageEditor(viewImageFile=directory) @staticmethod def on_open_source_folder(): """ Open source folder """ folder_path = mttCmd.get_texture_source_folder() if os.path.isdir(folder_path): os.startfile(folder_path) @staticmethod def on_auto_reload(): state = MTTSettings.value('autoReload') MTTSettings.set_value('autoReload', not state) @staticmethod def on_auto_select(): state = MTTSettings.value('autoSelect') MTTSettings.set_value('autoSelect', not state) @staticmethod def on_auto_rename(): state = MTTSettings.value('autoRename') MTTSettings.set_value('autoRename', not state) def on_toggle_viewer(self): self.viewerToggled.emit() @staticmethod def on_create_node(): mttFilterFileDialog.create_nodes() @staticmethod def on_open_hypershade(): """ Open Maya Hypershade """ cmds.HypershadeWindow() @staticmethod def on_open_node_editor(): """ Open Maya Hypershade """ cmds.NodeEditorWindow() @staticmethod def on_open_uv_editor(): """ Open Maya UV Texture Editor """ cmds.TextureViewWindow() def update_node_file_count(self): file_count = self.model.get_file_count() file_str = 'file{}'.format(['', 's'][file_count > 1]) node_shown_count = self.proxy.rowCount() node_count = self.model.get_node_count() node_str = 'node' if node_count < 1 else 'nodes' self.stat_info.setText( '%d %s | %d/%d %s' % (file_count, file_str, node_shown_count, node_count, node_str)) def save_states(self): # buttons states MTTSettings.set_value('onlySelectionState', self.selection_btn.isChecked()) MTTSettings.set_value('onlyWritableState', self.writable_btn.isChecked()) MTTSettings.set_value('showReferenceState', self.reference_btn.isChecked()) MTTSettings.set_value('showWrongNameState', self.wrong_name_btn.isChecked()) MTTSettings.remove('pinnedNode') MTTSettings.set_value('vizWrongNameState', self.wrong_name_visibility_btn.isChecked()) MTTSettings.set_value('showBasenameState', self.basename_visibility_btn.isChecked()) MTTSettings.set_value('filterInstances', self.filter_instances_btn.isChecked()) # groups states MTTSettings.set_value('filterGroup', self.filter_grp.current_state()) MTTSettings.set_value('visibilityGroup', self.visibility_grp.current_state()) MTTSettings.set_value('folderGroup', self.folder_grp.current_state()) MTTSettings.set_value('autoGroup', self.auto_grp.current_state()) MTTSettings.set_value('toolGroup', self.tool_grp.current_state()) MTTSettings.set_value('mayaGroup', self.maya_grp.current_state())
class TipOfTheDayDialog(QWizard): """ Subclass of `QWizard`_ Tip Of The Day Dialog Class .. sphinx_generate_methods_summary:: TipOfTheDayDialog """ def __init__(self, parent): super(TipOfTheDayDialog, self).__init__(parent) """ Default class constructor. :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ ## qDebug("TipOfTheDayDialog constructor") self.mainWin = parent self.setAttribute(Qt.WA_DeleteOnClose) self.setWizardStyle(QWizard.ModernStyle) self.setMinimumSize(550, 400) ## self.setOption(QWizard.HaveHelpButton, True) page = QWizardPage(self) self.imgBanner = ImageWidget(self.mainWin.gImgDir, self.mainWin.gIconDir, self) # Read in the tips.txt file. # fileOpen = open(self.mainWin.gAppDir + os.sep + 'tips.txt') # tips = fileOpen.read() # fileOpen.close() # self.tipsList = [tip for tip in tips.split('\n') if tip] # remove the blank lines also. self.tipsList = [tip for tip in TIPS_TXT.split('\n') if tip] # remove the blank lines also. # Make sure we don't cause an IndexError. # DEV-We might be adding tips to the txt at runtime. The easy way to add and check tips. if int(self.mainWin.settings_general_current_tip) >= len(self.tipsList): self.mainWin.settings_general_current_tip = 0 self.labelTipOfTheDay = QLabel(self) self.labelTipOfTheDay.setText(self.tipsList[int(self.mainWin.settings_general_current_tip)]) self.labelTipOfTheDay.setWordWrap(True) # Forget about a standardish QCheckBox, real powerusers keep the lights on! self.lightswitch = LightSwitchWidget(self.mainWin.gImgDir, self.mainWin, self) self.showOnStartupLabel = QLabel(self) self.showOnStartupLabel.setText(self.tr('Show tips on startup')) layout = QVBoxLayout(self) hblayout = QHBoxLayout() hblayout2 = QHBoxLayout() hblayout.addStretch(1) hblayout.addWidget(self.imgBanner) hblayout.addStretch(1) layout.addLayout(hblayout) layout.addStrut(1) layout.addSpacerItem(QSpacerItem(0, 5)) layout.addWidget(self.labelTipOfTheDay) layout.addStretch(1) hblayout2.addWidget(self.lightswitch) hblayout2.addWidget(self.showOnStartupLabel) hblayout2.addStretch(1) self.showOnStartupLabel.setAlignment(Qt.AlignBottom) layout.addLayout(hblayout2) page.setLayout(layout) self.addPage(page) self.setWindowTitle(self.tr('Tip of the Day')) buttonPrevious = QPushButton(self) buttonPrevious.setText(self.tr('&Previous')) buttonPrevious.setIcon(QIcon(self.mainWin.gIconDir + os.sep + 'undo.png')) buttonPrevious.setIconSize(QSize(24, 24)) buttonNext = QPushButton(self) buttonNext.setText(self.tr('&Next')) buttonNext.setIcon(QIcon(self.mainWin.gIconDir + os.sep + 'redo.png')) buttonNext.setIconSize(QSize(24, 24)) buttonClose = QPushButton(self) buttonClose.setText(self.tr('&Close')) buttonClose.setIcon(QIcon(self.mainWin.gIconDir + os.sep + 'windowclose.png')) buttonClose.setIconSize(QSize(24, 24)) self.setButton(QWizard.CustomButton1, buttonPrevious) self.setButton(QWizard.CustomButton2, buttonNext) self.setButton(QWizard.CustomButton3, buttonClose) self.setOption(QWizard.HaveCustomButton1, True) self.setOption(QWizard.HaveCustomButton2, True) self.setOption(QWizard.HaveCustomButton3, True) self.customButtonClicked.connect(self.buttonTipOfTheDayClicked) listTipOfTheDayButtons = [QWizard.Stretch, QWizard.CustomButton1, QWizard.CustomButton2, QWizard.CustomButton3] self.setButtonLayout(listTipOfTheDayButtons) self.DoSetWhatsThis() def checkBoxTipOfTheDayStateChanged(self, checked): """ Set whether the Tip Of The Day dialog shows on application startup. :param `checked`: :type `checked`: int """ ## qDebug('checked = %s' % checked) self.mainWin.settings_general_tip_of_the_day = checked def buttonTipOfTheDayClicked(self, button): """ Depending on the button pressed, Advance the current displayed tip backwards or forwards or close the Tip Of The Day Dialog. :param `button`: :type `button`: int """ ## qDebug("buttonTipOfTheDayClicked(%d)" % button) if button == QWizard.CustomButton1: if self.mainWin.settings_general_current_tip > 0: self.mainWin.settings_general_current_tip = int(self.mainWin.settings_general_current_tip) - 1 self.mainWin.gSettings.setValue("CurrentTip", str(int(self.mainWin.settings_general_current_tip) - 1)) else: self.mainWin.settings_general_current_tip = len(self.tipsList) - 1 self.mainWin.gSettings.setValue("CurrentTip", str(len(self.tipsList) - 1)) self.labelTipOfTheDay.setText(self.tipsList[self.mainWin.settings_general_current_tip]) elif button == QWizard.CustomButton2: self.mainWin.settings_general_current_tip = int(self.mainWin.settings_general_current_tip) + 1 self.mainWin.gSettings.setValue("CurrentTip", str(int(self.mainWin.settings_general_current_tip) + 1)) if self.mainWin.settings_general_current_tip >= len(self.tipsList): self.mainWin.settings_general_current_tip = 0 self.mainWin.gSettings.setValue("CurrentTip", str(int(0))) self.labelTipOfTheDay.setText(self.tipsList[self.mainWin.settings_general_current_tip]) elif button == QWizard.CustomButton3: self.close() if button in (QWizard.CustomButton1, QWizard.CustomButton2): self.DoSetWhatsThis() def DoSetWhatsThis(self): """""" huh = (self.tr('Did you know...') + '\n' + self.tr('This is tip number:') + ' %d' % int(self.mainWin.settings_general_current_tip)) self.labelTipOfTheDay.setWhatsThis(huh)