def LaunchPreamble(self, arg_parse_result): # Initialize concurrency limit as early as possible so that it is # respected by subsequent imports. from pxr import Work Work.SetConcurrencyLimitArgument(arg_parse_result.numThreads) if arg_parse_result.clearSettings: AppController.clearSettings() # Find the resource directory resourceDir = os.path.dirname(os.path.realpath(__file__)) + "/" # Create the Qt application app = QtWidgets.QApplication(sys.argv) # Apply the style sheet to it sheet = open(os.path.join(resourceDir, 'usdviewstyle.qss'), 'r') # Qt style sheet accepts only forward slashes as path separators sheetString = sheet.read().replace('RESOURCE_DIR', resourceDir.replace("\\", "/")) app.setStyleSheet(sheetString) appController = AppController(arg_parse_result) return (app, appController)
def main(): if not env.isInMaya(): app = QtWidgets.QApplication(sys.argv) _bind() sys.exit(app.exec_()) else: from zoo.libs.maya.qt import mayaui return _bind(parent=None) # mayaui.getMayaWindow())
def __LaunchProcess(self, arg_parse_result): ''' after the arguments have been parsed, launch the UI in a forked process ''' # Initialize concurrency limit as early as possible so that it is # respected by subsequent imports. from pxr import Work Work.SetConcurrencyLimitArgument(arg_parse_result.numThreads) from mainWindow import MainWindow if arg_parse_result.clearSettings: MainWindow.clearSettings() # Find the resource directory resourceDir = os.path.dirname(os.path.realpath(__file__)) + "/" # Create the Qt application app = QtWidgets.QApplication(sys.argv) # Apply the style sheet to it sheet = open(os.path.join(resourceDir, 'usdviewstyle.qss'), 'r') # Qt style sheet accepts only forward slashes as path separators sheetString = sheet.read().replace('RESOURCE_DIR', resourceDir.replace("\\", "/")) app.setStyleSheet(sheetString) mainWindow = MainWindow(None, arg_parse_result) if arg_parse_result.quitAfterStartup: # Before we quit, process events one more time to make sure the # UI is fully populated (and to capture all the timing information # we'd want). app.processEvents() mainWindow._cleanAndClose() return app.exec_()
frame.rect = proxyStyle.subControlRect( QtWidgets.QStyle.CC_GroupBox, option, QtWidgets.QStyle.SC_GroupBoxFrame, self) proxyStyle.drawPrimitive(QtWidgets.QStyle.PE_FrameGroupBox, frame, painter, self) # now draw the title if option.text: painter.setPen(QtGui.QPen(option.palette.windowText(), 1)) alignment = int(option.textAlignment) if not proxyStyle.styleHint(QtWidgets.QStyle.SH_UnderlineShortcut, option, self): alignment = alignment | QtCore.Qt.TextHideMnemonic style.proxy().drawItemText( painter, textRect, QtCore.Qt.TextShowMnemonic | QtCore.Qt.AlignLeft | alignment, option.palette, option.state & QtWidgets.QStyle.State_Enabled, option.text, QtGui.QPalette.NoRole) # deal with the arrow icons proxyStyle.drawItemPixmap( painter, checkBoxRect, QtCore.Qt.AlignLeft, self.minusPixmap if self.isChecked() else self.plusPixmap) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) box = CollapsibleGroupBox() box.setTitle("test") box.setLayout(QtWidgets.QVBoxLayout(box)) box.layout().addWidget(QtWidgets.QPushButton("test", parent=box)) box.show() sys.exit(app.exec_())
msz.width(), self.searchButton.sizeHint().width() + self.clearButton.sizeHint().width() + frameWidth * 2 + 2), max(msz.height(), self.clearButton.sizeHint().height() + frameWidth * 2 + 2)) def resizeEvent(self, event): sz = self.clearButton.sizeHint() frameWidth = self.style().pixelMetric( QtWidgets.QStyle.PM_DefaultFrameWidth) rect = self.rect() yPos = (rect.bottom() + 1 - sz.height()) * 0.5 self.clearButton.move(self.rect().right() - frameWidth - sz.width(), yPos) self.searchButton.move(self.rect().left() + 1, yPos) def updateCloseButton(self, text): if text: self.clearButton.setVisible(True) return self.clearButton.setVisible(False) if __name__ == "__name__": app = QtWidgets.QApplication([]) searchIcon = QtGui.QPixmap(iconlib.icon("magnifier"), 16) closeIcon = QtGui.QPixmap(iconlib.icon("code", 16)) w = SearchLineEdit(searchIcon, closeIcon) w.show() app.exec_()
def standalone(): app = QtWidgets.QApplication(sys.argv) app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) win = embed() win.show() sys.exit(app.exec_())