Created
November 10, 2014 20:15
-
-
Save hogjonny/f88e281ccbb2c7329da6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------- | |
# ------------------------------------------------------------------------- | |
# bp_newTool.py | |
# Tool for blah, blah, blah | |
# version: 1.0 | |
# date: 5/1/2013 | |
# author: jGalloway | |
# ------------------------------------------------------------------------- | |
# ------------------------------------------------------------------------- | |
import os | |
import sip | |
from PyQt4 import QtGui, QtCore | |
import maya.cmds as cmds | |
import uiTool as uiTools # generates UI classes from pyqt designer, .ui file | |
# ------------------------------------------------------------------------- | |
#Loads the ui files into the form and base classes | |
form_class, base_class = uiTools.generateUiClasses('bp_newTool.ui', os.path.dirname(__file__)) | |
# ------------------------------------------------------------------------- | |
class NewTool_UI(base_class, form_class): | |
def __init__(self, parent= uiTools.getMayaMainWindow()): | |
'''A custom window with a demo set of ui widgets''' | |
#Check to see if the window already exists and remove it if necessary | |
self.mainWindowName = 'NewToolWindow' | |
if cmds.window(self.mainWindowName, exists=True ): | |
cmds.deleteUI(self.mainWindowName, window=True ) | |
super(base_class, self).__init__(parent) | |
#uic adds a function to our class called setupUi, calling this creates all the widgets from the .ui file | |
self.setupUi(self) | |
#set UI defaults | |
#self.myGroupBox.setChecked(True) | |
#Connect the interface controls | |
self.connect_interface() | |
#Setup Help Menu | |
self.helpMenu = uiTools.SetupHelpMenu(self, 'NewTool Help...', 'http://bp.com/NewTool') | |
#Setup the settings .ini | |
self.qSettings = uiTools.bp_setupQtSettings(self.mainWindowName) | |
#Read the saved settings | |
self.readSettings() | |
#---------------------------------------------------------------------- | |
def connect_interface(self): | |
"""""" | |
#Connect widgets to methods | |
#QtCore.QObject.connect(self.renameButton, QtCore.SIGNAL("clicked()"), self.NewCommand) | |
pass | |
#---------------------------------------------------------------------- | |
def NewCommand(self): | |
"""""" | |
pass | |
#---------------------------------------------------------------------- | |
def closeEvent(self, event): | |
"""Event which is run when window closes""" | |
self.writeSettings() | |
#---------------------------------------------------------------------- | |
def writeSettings(self): | |
"""Writes out the windows settings""" | |
#main window | |
self.qSettings.setValue("geometry", self.saveGeometry()) #saves window size and position | |
self.qSettings.setValue("windowState", self.saveState()) #saves the state of window's toolbars and dockWidgets | |
##widgets | |
#self.qSettings.setValue("textFilePath", self.textFileLineEdit.text()) | |
#---------------------------------------------------------------------- | |
def readSettings(self): | |
"""Reads in the windows settings""" | |
#main window | |
self.restoreGeometry(self.qSettings.value("geometry").toByteArray()) #restores window size and position | |
self.restoreState(self.qSettings.value("windowState").toByteArray()) #restores the state of window's toolbars and dockWidgets | |
##widgets | |
#if self.qSettings.value("textFilePath"): | |
#textFile = self.qSettings.value("textFilePath",).toString() | |
#self.textFileLineEdit.setText(textFile) | |
def main(): | |
global toolWindow | |
toolWindow = NewTool_UI() | |
toolWindow.show() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment