def buildUI(self): #Original Author: Jeremy Ernst #create the main window self.mainWin = QtWidgets.QMainWindow(self.mainUI) self.mainWin.setStyleSheet( "background-color: rgb(0, 0, 0);, color: rgb(0,0,0);") styleSheetFile = utils.returnNicePath( self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.mainWin.setStyleSheet(self.style) #create the main widget self.mainWidget = QtWidgets.QWidget() self.mainWin.setCentralWidget(self.mainWidget) #set qt object name self.mainWin.setObjectName("ART_RigHistWin") self.mainWin.setWindowTitle("Rig History") #font headerFont = QtGui.QFont() headerFont.setPointSize(8) headerFont.setBold(True) #set size policy mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) #create the mainLayout for the rig creator UI self.layout = QtWidgets.QVBoxLayout(self.mainWidget) self.mainWin.resize(400, 240) self.mainWin.setSizePolicy(mainSizePolicy) self.mainWin.setMinimumSize(QtCore.QSize(400, 240)) self.mainWin.setMaximumSize(QtCore.QSize(400, 240)) #create the QFrame for this page self.background = QtWidgets.QFrame() self.layout.addWidget(self.background) self.mainLayout = QtWidgets.QVBoxLayout(self.background) self.background.setObjectName("epic") #detailed information self.infoText = QtWidgets.QTextEdit() self.mainLayout.addWidget(self.infoText) self.infoText.setMinimumSize(QtCore.QSize(360, 200)) self.infoText.setMaximumSize(QtCore.QSize(360, 200)) self.infoText.setReadOnly(True) self.infoText.setWordWrapMode(QtGui.QTextOption.WordWrap) #show the window self.mainWin.show() self.getHistory()
def gitCredsUI(parent): """ Create an interface that allows user to enter github username and password. :param parent: interface that this interface will be a child of. """ credsDialog = QtWidgets.QDialog(parent) credsDialog.setWindowTitle("Github Credentials") credsDialog.setMinimumSize(QtCore.QSize(200, 120)) credsDialog.setMaximumSize(QtCore.QSize(200, 120)) layout = QtWidgets.QVBoxLayout(credsDialog) userName = QtWidgets.QLineEdit() userName.setPlaceholderText("Github User Name..") layout.addWidget(userName) password = QtWidgets.QLineEdit() password.setPlaceholderText("Github Password..") layout.addWidget(password) password.setEchoMode(QtWidgets.QLineEdit.Password) confirmButton = QtWidgets.QPushButton("Confirm") layout.addWidget(confirmButton) confirmButton.setObjectName("blueButton") confirmButton.clicked.connect( partial(gitWriteCreds, userName, password, credsDialog)) credsDialog.exec_()
def setBoneCountTarget(self): """ Builds a UI that allows the user to set the target bone count. .. image:: /images/boneCountTarget.png """ # launch a UI to get the name information self.targetWindow = QtWidgets.QMainWindow() # size policies mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # create the main widget self.targetWindow_mainWidget = QtWidgets.QWidget() self.targetWindow.setCentralWidget(self.targetWindow_mainWidget) # set qt object name self.targetWindow.setObjectName("ART_setBoneCountTarget_UI") self.targetWindow.setWindowTitle("Bone Count") # create the mainLayout for the rig creator UI self.targetWindow_topLayout = QtWidgets.QVBoxLayout(self.targetWindow_mainWidget) self.targetWindow_mainLayout = QtWidgets.QFormLayout() self.targetWindow_topLayout.addLayout(self.targetWindow_mainLayout) self.targetWindow_topLayout.setContentsMargins(10, 10, 10, 10) self.targetWindow.resize(250, 70) self.targetWindow.setSizePolicy(mainSizePolicy) self.targetWindow.setMinimumSize(QtCore.QSize(250, 70)) self.targetWindow.setMaximumSize(QtCore.QSize(250, 70)) # add label label = QtWidgets.QLabel("Enter a target bone count: ") self.targetWindow_mainLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, label) # add spinBox self.targetWindow_SpinBox = QtWidgets.QSpinBox() self.targetWindow_SpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) self.targetWindow_SpinBox.setRange(1, 9999) self.targetWindow_SpinBox.setMinimumWidth(70) self.targetWindow_SpinBox.setStyleSheet("background-color: rgb(255,255,255); color: rgb(0,0,0);") self.targetWindow_mainLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.targetWindow_SpinBox) self.targetWindow_SpinBox.setValue(100) self.targetWindow_SpinBox.setObjectName("ART_targetWindowSpinBox") # add a confirm button self.targetWindow_confirmButton = QtWidgets.QPushButton("Confirm") self.targetWindow_topLayout.addWidget(self.targetWindow_confirmButton) buttonImage = utils.returnNicePath(self.iconsPath, "System/blue_field_background.png") self.targetWindow_confirmButton.setStyleSheet( "background-image: url(" + buttonImage + "); background-color: rgb(0,0,0);") self.targetWindow_confirmButton.clicked.connect(self.setBoneCountTarget_Confirm) # show the window self.targetWindow.show()
def buildUI(self): if cmds.window("pyART_AddToCanvasWIN", exists=True): cmds.deleteUI("pyART_AddToCanvasWIN", wnd=True) #create the main window self.mainWin = QtWidgets.QMainWindow(self.pickerUI) #create the main widget self.mainWidget = QtWidgets.QWidget() self.mainWin.setCentralWidget(self.mainWidget) #create the mainLayout self.layout = QtWidgets.QVBoxLayout(self.mainWidget) #load stylesheet styleSheetFile = utils.returnNicePath( self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/animPicker.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.mainWin.setStyleSheet(self.style) self.mainWin.setMinimumSize(QtCore.QSize(250, 400)) self.mainWin.setMaximumSize(QtCore.QSize(250, 400)) self.mainWin.resize(250, 400) #set qt object name self.mainWin.setObjectName("pyART_AddToCanvasWIN") self.mainWin.setWindowTitle("Remove Module From Canvas") #label, listWidget, button label = QtWidgets.QLabel("Available Modules:") label.setProperty("boldFont", True) self.layout.addWidget(label) self.moduleList = QtWidgets.QListWidget() self.moduleList.setMaximumSize(230, 300) self.moduleList.setMinimumSize(230, 300) self.layout.addWidget(self.moduleList) #add modules to listWidget self.addModulesToList() #create remove button button = QtWidgets.QPushButton("Remove From Canvas") self.layout.addWidget(button) button.setObjectName("blueButton") button.clicked.connect(self.removeFromCanvas) #show ui self.mainWin.show()
def writeQSS(filePath): # this function takes the qss file given, and finds and replaces any image path URLs using the user's settings for # the icons path and changes the file on disk settings = QtCore.QSettings("Epic Games", "ARTv2") scriptsPath = settings.value("scriptPath") scriptsPath = utils.returnFriendlyPath(scriptsPath) iconPath = settings.value("iconPath") iconPath = utils.returnFriendlyPath(iconPath) f = open(filePath, "r") lines = f.readlines() f.close() newLines = [] for line in lines: if line.find("url(") != -1: oldPath = line.partition("(")[2].rpartition("/")[0] replacePath = utils.returnNicePath(iconPath, "System") newLine = line.replace(oldPath, replacePath) newLines.append(newLine) else: newLines.append(line) os.chmod(filePath, S_IWUSR | S_IREAD) f = open(filePath, "w") for line in newLines: f.write(line) f.close()
def __init__(self, mainUI): """ Instantiates the class, getting the QSettings and then calling on the function to build the UI for the tool. :param mainUI: The instance of the Rig Creator UI that this class was called from. .. seealso:: ART_BuildProgressUI.buildUI """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.projectPath = settings.value("projectPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI self.rigData = [] self.warnings = 0 self.errors = 0 # images self.imageBkgrd = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/toolbar_background.png")) self.imageBtnBkrd = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/blue_field_background.png")) self.frameBackground = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/field_background.png")) # build the UI if cmds.window("ART_BuildProgressWin", exists=True): cmds.deleteUI("ART_BuildProgressWin", wnd=True) self.buildUI()
def getInfo(self): #need to eventually swap this with the real file request = urllib2.Request( "https://raw.githubusercontent.com/epicernst/Test/master/ARTv2_VersionInfo.json" ) base64String = base64.encodestring( '%s:%s' % (self.credentials[0], self.credentials[1])).replace( '\n', '') request.add_header("Authorization", "Basic %s" % base64String) try: result = urllib2.urlopen(request) except Exception, e: self.infoText.setTextColor(QtGui.QColor(249, 241, 12)) self.infoText.append(str(e)) self.infoText.append( "Your Github login credentials may be invalid or you do not have access to this repo.\n\n" ) self.infoText.setTextColor(QtGui.QColor(255, 255, 255)) settings = QtCore.QSettings("Epic Games", "ARTv2") settings.remove("gitUser") settings.remove("gitPass") return
def __init__(self, mainUI): """ Instantiate the class, getting the QSettings, and building the interface. :param mainUI: The instance of the Rig Creator UI from which this class was called. """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.projectPath = settings.value("projectPath") self.mainUI = mainUI # images self.imageBkgrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/toolbar_background.png")) self.imageBtnBkrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/blue_field_background.png")) self.frameBackground = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/field_background.png")) # build the UI if cmds.window("ART_DebugRigsWin", exists=True): cmds.deleteUI("ART_DebugRigsWin", wnd=True) self.buildUI()
def __init__(self, animPickerUI, showUI, parent=None): super(ART_SelectControls, self).__init__() # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.scriptPath = settings.value("scriptPath") self.projectPath = settings.value("projectPath") self.pickerUI = animPickerUI self.showUI = showUI # write out qss based on user settings stylesheetDir = utils.returnNicePath(self.scriptPath, "Interfaces/StyleSheets/") stylesheets = os.listdir(stylesheetDir) for sheet in stylesheets: interfaceUtils.writeQSS(os.path.join(stylesheetDir, sheet)) # build the UI or just go straight to selecting all controls if self.showUI: self.buildUI() else: self.selectControls()
def __init__(self, mainUI): #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.scriptPath = settings.value("scriptPath") self.projectPath = settings.value("projectPath") self.mainUI = mainUI self.rigData = [] self.warnings = 0 self.errors = 0 #images self.imageBkgrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/toolbar_background.png")) self.imageBtnBkrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/blue_field_background.png")) self.frameBackground = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/field_background.png")) #build the UI if cmds.window("ART_RigHistWin", exists=True): cmds.deleteUI("ART_RigHistWin", wnd=True) self.buildUI()
def saveSettings(self): #get data from ui mayaToolsDir = self.locationPath.text() scriptDir = self.scriptsPath.text() iconsDir = self.iconPath.text() projectsDir = self.projectsPath.text() #save data settings = QtCore.QSettings("Epic Games", "ARTv2") settings.setValue("toolsPath", mayaToolsDir) settings.setValue("scriptPath", scriptDir) settings.setValue("iconPath", iconsDir) settings.setValue("projectPath", projectsDir) #Give message regarding data being saved, but it won't take effect until Maya is restarted. cmds.confirmDialog( title="Settings Saved", message= "Please close Maya and reopen in order to have these settings take effect." ) #close UI if cmds.window("pyArtSettingsWin", exists=True): cmds.deleteUI("pyArtSettingsWin", wnd=True)
def __init__(self, title, parent=None): super(ProgressBar, self).__init__() settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") # load stylesheet styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.setStyleSheet(self.style) self.setWindowTitle(title) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.WindowTitleHint | QtCore.Qt.CustomizeWindowHint) self.setMinimumSize(QtCore.QSize(400, 40)) self.setMaximumSize(QtCore.QSize(400, 40))
def __init__(self, mainUI): #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI #build the UI self.buildResetModeUI(mainUI)
def __init__(self, mainUI): #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI self.skinCluster = None #build the UI self.buildMoveInfsUI()
def __init__(self, mainUI, skinToolsInst): #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI self.skinToolsInst = skinToolsInst #build the UI self.finalizeSetup_UI()
def gitWriteCreds(username, password, ui): """ Set the QSettings values for the username and password with the supplied information. :param username: user-entered github username :param password: user-entered github password :param ui: instance of UI where use enters above information """ settings = QtCore.QSettings("Epic Games", "ARTv2") settings.setValue("gitUser", username.text()) settings.setValue("gitPass", password.text()) ui.close()
def __init__(self, parent=None): super(ART_Reporter, self).__init__(parent) #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.scriptPath = settings.value("scriptPath") self.projPath = settings.value("projectPath") #build the UI self.buildSettingsUi()
def __init__(self, mainUI): """ Instantiate the class, getting the settings from QSettings, then build the interface. :param mainUI: instance of the rig creator interface """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI # build the UI self.buildImportWeightsUI()
def getGitCreds(): """ Get the github credentials stored in the QSettings :return: github username and password """ settings = QtCore.QSettings("Epic Games", "ARTv2") user = settings.value("gitUser") password = settings.value("gitPass") if user is not None and password is not None: return [user, password] else: return None
def __init__(self, mainUI): """ Instantiates the class, getting the QSettings for the tool, and building the Aim Mode interface. :param mainUI: The instance of the Rig Creator UI this tool was called from. """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI # build the UI self.buildAimModeUI()
def skeletonSettings_UI(self, name): #groupbox all modules get ART_RigModule.skeletonSettings_UI(self, name, 335, 85, False) #add a label to the root module saying this module cannot be edited or removed self.layout = QtWidgets.QVBoxLayout(self.groupBox) self.label = QtWidgets.QLabel( "All rigs must have a root module. This module cannot be edited or removed." ) self.layout.addWidget(self.label) self.label.setGeometry(QtCore.QRect(10, 20, 300, 60)) self.label.setMinimumHeight(60) self.label.setWordWrap(True) #add to the rig cretor UI's module settings layout VBoxLayout self.rigUiInst.moduleSettingsLayout.addWidget(self.groupBox)
def __init__(self, mainUI): """ Instantiates the class, taking in the instance of the rig creator skin tools interface. Get settings values from QSettings. Build the interface. :param mainUI: Instance of the skin tools interface. """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI # build the UI self.buildInterface()
def __init__(self, animPickerUI, modulesToAdd, parent=None): super(ART_MovePickerToTab, self).__init__() #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.scriptPath = settings.value("scriptPath") self.projectPath = settings.value("projectPath") self.pickerUI = animPickerUI self.modulesToAdd = modulesToAdd #assign close event self.closeEvent = self.closeWin #build the UI self.buildUI()
def __init__(self, mainUI): """ Instantiates this class, getting the QSettings and calling on the method to build the interface for the tool. :param mainUI: The instance of the Rig Creator UI from which this class was called. .. seealso:: ART_BoneCounter.buildBoneCounterUI """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI # build the UI self.buildBoneCounterUI()
def __init__(self, mainUI): """ Instantiates the class, getting the QSettings and then calling on ART_BakeOffsetsUI.buildBakeOffsetsUI to create the interface. :param mainUI: The instance of the Rig Creator UI where this class was called from. .. seealso:: ART_BakeOffsetsUI.buildBakeOffsetsUI """ # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI # build the UI self.buildBakeOffsetsUI()
def fbxFileBrowse(self): settings = QtCore.QSettings("Epic Games", "ARTv2") path = settings.value("ImportPath") if path == None: path = self.projectPath #see if export node exists, and if it does, see if there is an existing export path try: path = cmds.fileDialog2(fm=1, okc="Import FBX", dir=path, ff="*.fbx") nicePath = utils.returnFriendlyPath(path[0]) self.fbxFilePath.setText(nicePath) settings.setValue("ImportPath", nicePath) except: pass
def __init__(self, parent=None): super(ART_Updater, self).__init__(parent) #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.scriptPath = settings.value("scriptPath") self.iconsPath = settings.value("iconPath") self.projPath = settings.value("projectPath") #get github credentials self.credentials = git.getGitCreds() if self.credentials == None: git.gitCredsUI(self) self.credentials = git.getGitCreds() #build the UI self.buildSettingsUi()
def __init__(self, edit, add, parent=None): """ Instantiates the class, getting the QSettings and building the interface. :param edit: Whether or not the operation is to edit the rig. :param add: Whether or not the operation is to add the character for animation. """ super(ART_EditRigUI, self).__init__(parent) self.edit = edit self.add = add # get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.iconsPath = settings.value("iconPath") self.scriptPath = settings.value("scriptPath") self.projectPath = settings.value("projectPath") # build the UI self.createUI()
def __init__(self, rigUiInst, moduleUserName): """Initiate the class, taking in the instance to the interface and the user specified name. :param rigUiInst: This is the rig creator interface instance being passed in. :param moduleUserName: This is the name specified by the user on module creation. Instantiate the following class variables as well: * **self.rigUiInst:** take the passed in interface instance and make it a class var * **self.moduleUserName:** take the passed in moduleUserName and make it a class var * **self.outlinerWidget:** an empty list that will hold all of the widgets added to the outliner Also, read the QSettings to find out where needed paths are. """ self.rigUiInst = rigUiInst self.moduleUserName = moduleUserName self.outlinerWidgets = {} settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") ART_RigModule.__init__(self, "ART_Chain_Module", "ART_Chain", moduleUserName)
def __init__(self, mainUI, moviePath): #Original Author: Jeremy Ernst #get the directory path of the tools settings = QtCore.QSettings("Epic Games", "ARTv2") self.toolsPath = settings.value("toolsPath") self.projectPath = settings.value("projectPath") self.iconsPath = settings.value("iconPath") self.mainUI = mainUI #images self.imageBkgrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/toolbar_background.png")) self.imageBtnBkrd = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/blue_field_background.png")) self.frameBackground = utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/field_background.png")) #build the UI if cmds.window("ART_HelpMovieWin", exists=True): cmds.deleteUI("ART_HelpMovieWin", wnd=True) self.buildHelpMovieUI(moviePath)