<s> import os <EOL> import sys <EOL> import json <EOL> from PySide import QtGui , QtCore <EOL> from kraken . ui import images_rc <EOL> from kraken . ui . kraken_menu import KrakenMenu <EOL> from kraken . ui . kraken_ui import KrakenUI <EOL> from kraken . ui . preferences import Preferences <EOL> from kraken . plugins . logger import OutputLog <EOL> class KrakenWindow ( QtGui . QMainWindow ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent = None ) : <EOL> super ( KrakenWindow , self ) . __init__ ( parent ) <EOL> self . setObjectName ( '<STR_LIT>' ) <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> self . setWindowIcon ( QtGui . QIcon ( '<STR_LIT>' ) ) <EOL> self . setAttribute ( QtCore . Qt . WA_DeleteOnClose ) <EOL> self . outputLog = OutputLog ( ) <EOL> sys . stdout = self . outputLog <EOL> QtCore . QCoreApplication . setOrganizationName ( "<STR_LIT>" ) <EOL> QtCore . QCoreApplication . setApplicationName ( "<STR_LIT>" ) <EOL> self . settings = QtCore . QSettings ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . preferences = Preferences ( ) <EOL> cssPath = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> styleData = '<STR_LIT>' <EOL> with open ( cssPath ) as cssFile : <EOL> styleData = cssFile . read ( ) <EOL> self . setStyleSheet ( styleData ) <EOL> self . createLayout ( ) <EOL> self . createConnections ( ) <EOL> def createLayout ( self ) : <EOL> statusBar = self . statusBar ( ) <EOL> self . outputLogButton = QtGui . QPushButton ( '<STR_LIT>' , self ) <EOL> self . outputLogButton . setObjectName ( '<STR_LIT>' ) <EOL> statusBar . insertPermanentWidget ( <NUM_LIT:0> , self . outputLogButton ) <EOL> mainWidget = QtGui . QWidget ( ) <EOL> self . mainLayout = QtGui . QVBoxLayout ( ) <EOL> self . mainLayout . setContentsMargins ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . krakenUI = KrakenUI ( self ) <EOL> self . krakenMenu = KrakenMenu ( self ) <EOL> self . krakenUI . graphViewWidget . setGuideRigName ( '<STR_LIT>' ) <EOL> self . krakenMenu . updateRigNameLabel ( ) <EOL> self . mainLayout . addWidget ( self . krakenMenu ) <EOL> self . mainLayout . addWidget ( self . krakenUI , <NUM_LIT:1> ) <EOL> mainWidget . setLayout ( self . mainLayout ) <EOL> self . setCentralWidget ( mainWidget ) <EOL> self . statusBar ( ) . showMessage ( '<STR_LIT>' , <NUM_LIT> ) <EOL> self . setGeometry ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . center ( ) <EOL> self . readSettings ( ) <EOL> def createConnections ( self ) : <EOL> self . outputLogButton . clicked . connect ( self . showOutputLog ) <EOL> self . krakenMenu . newAction . triggered . connect ( self . krakenUI . graphViewWidget . newRigPreset ) <EOL> self . krakenUI . graphViewWidget . rigLoaded . connect ( self . krakenMenu . buildRecentFilesMenu ) <EOL> self . krakenUI . graphViewWidget . rigNameChanged . connect ( self . krakenMenu . updateRigNameLabel ) <EOL> def getKrakenUI ( self ) : <EOL> return self . krakenUI <EOL> def center ( self ) : <EOL> qr = self . frameGeometry ( ) <EOL> cp = QtGui . QDesktopWidget ( ) . availableGeometry ( ) . center ( ) <EOL> qr . moveCenter ( cp ) <EOL> self . move ( qr . topLeft ( ) ) <EOL> def getSettings ( self ) : <EOL> return self . settings <EOL> def writeSettings ( self ) : <EOL> self . settings . beginGroup ( '<STR_LIT>' ) <EOL> self . settings . setValue ( '<STR_LIT:size>' , self . size ( ) ) <EOL> self . settings . setValue ( '<STR_LIT>' , self . pos ( ) ) <EOL> self . settings . setValue ( '<STR_LIT>' , json . dumps ( self . preferences . getPreferences ( ) ) ) <EOL> self . settings . endGroup ( ) <EOL> self . krakenMenu . writeSettings ( self . settings ) <EOL> self . krakenUI . writeSettings ( self . settings ) <EOL> def readSettings ( self ) : <EOL> self . settings . beginGroup ( '<STR_LIT>' ) <EOL> self . resize ( self . settings . value ( '<STR_LIT:size>' , self . size ( ) ) ) <EOL> self . move ( self . settings . value ( '<STR_LIT>' , self . pos ( ) ) ) <EOL> self . preferences . loadPreferences ( json . loads ( self . settings . value ( '<STR_LIT>' , '<STR_LIT:{}>' ) ) ) <EOL> self . settings . endGroup ( ) <EOL> self . krakenMenu . readSettings ( self . settings ) <EOL> self . krakenUI . readSettings ( self . settings ) <EOL> def closeEvent ( self , event ) : <EOL> msgBox = QtGui . QMessageBox ( self ) <EOL> msgBox . setObjectName ( '<STR_LIT>' ) <EOL> msgBox . setWindowTitle ( "<STR_LIT>" ) <EOL> msgBox . setText ( "<STR_LIT>" ) <EOL> msgBox . setInformativeText ( "<STR_LIT>" ) <EOL> msgBox . setStandardButtons ( QtGui . QMessageBox . Save | QtGui . QMessageBox . Discard | QtGui . QMessageBox . Cancel ) <EOL> msgBox . setDefaultButton ( QtGui . QMessageBox . Save ) <EOL> ret = msgBox . exec_ ( ) <EOL> if ret == QtGui . QMessageBox . Cancel : <EOL> event . ignore ( ) <EOL> return <EOL> elif ret == QtGui . QMessageBox . Save : <EOL> self . kraken_ui . graphViewWidget . saveRigPreset ( ) <EOL> self . statusBar ( ) . showMessage ( '<STR_LIT>' ) <EOL> self . writeSettings ( ) <EOL> def showOutputLog ( self ) : <EOL> outputDialog = OutputLogDialog ( self ) <EOL> outputDialog . show ( ) <EOL> outputDialog . setText ( self . outputLog . getLog ( ) ) <EOL> outputDialog . textWidget . moveCursor ( QtGui . QTextCursor . End ) <EOL> class OutputLogDialog ( QtGui . QDialog ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent = None ) : <EOL> super ( OutputLogDialog , self ) . __init__ ( parent ) <EOL> self . setObjectName ( '<STR_LIT>' ) <EOL> self . resize ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> self . createLayout ( ) <EOL> self . createConnections ( ) <EOL> def createLayout ( self ) : <EOL> """<STR_LIT>""" <EOL> self . textWidget = QtGui . QTextEdit ( ) <EOL> self . textWidget . setLineWrapMode ( QtGui . QTextEdit . NoWrap ) <EOL> self . textWidget . setReadOnly ( True ) <EOL> self . textWidget . setContextMenuPolicy ( QtCore . Qt . CustomContextMenu ) <EOL> self . outputLogLayout = QtGui . QVBoxLayout ( self ) <EOL> self . outputLogLayout . addWidget ( self . textWidget ) <EOL> self . setLayout ( self . outputLogLayout ) <EOL> def createConnections ( self ) : <EOL> """<STR_LIT>""" <EOL> self . textWidget . customContextMenuRequested . connect ( self . createContextMenu ) <EOL> def setText ( self , text ) : <EOL> """<STR_LIT>""" <EOL> self . textWidget . setText ( text ) <EOL> def createContextMenu ( self ) : <EOL> self . contextMenu = QtGui . QMenu ( self ) <EOL> selectAllAction = self . contextMenu . addAction ( "<STR_LIT>" ) <EOL> copyAction = self . contextMenu . addAction ( "<STR_LIT>" ) <EOL> self . contextMenu . addSeparator ( ) <EOL> clearAction = self . contextMenu . addAction ( "<STR_LIT>" ) <EOL> selectAllAction . triggered . connect ( self . contextSelectAll ) <EOL> copyAction . triggered . connect ( self . contextCopy ) <EOL> clearAction . triggered . connect ( self . contextClear ) <EOL> self . contextMenu . exec_ ( QtGui . QCursor . pos ( ) ) <EOL> def contextSelectAll ( self ) : <EOL> self . textWidget . selectAll ( ) <EOL> def contextCopy ( self ) : <EOL> self . textWidget . copy ( ) <EOL> def contextClear ( self ) : <EOL> outputLog = self . parent ( ) . outputLog <EOL> outputLog . clear ( ) <EOL> self . textWidget . clear ( ) <EOL> def createSplash ( app ) : <EOL> """<STR_LIT>""" <EOL> splashPixmap = QtGui . QPixmap ( '<STR_LIT>' ) <EOL> splash = QtGui . QSplashScreen ( splashPixmap ) <EOL> splash . setMask ( splashPixmap . mask ( ) ) <EOL> splash . showMessage ( "<STR_LIT>" , <EOL> QtCore . Qt . AlignBottom | QtCore . Qt . AlignLeft , <EOL> QtCore . Qt . white ) <EOL> splash . show ( ) <EOL> app . processEvents ( ) <EOL> return splash <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> splash = createSplash ( app ) <EOL> window = KrakenWindow ( ) <EOL> window . show ( ) <EOL> splash . finish ( window ) <EOL> sys . exit ( app . exec_ ( ) ) </s>
