def __init__(self): QtGui.QWidget.__init__(self) title = 'Qt RegExp checker CGRU ' + cgruconfig.VARS['CGRU_VERSION'] self.setWindowTitle(title) layout = QtGui.QVBoxLayout(self) self.leName = QtGui.QLineEdit('render01', self) layout.addWidget(self.leName) QtCore.QObject.connect(self.leName, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.lePattern = QtGui.QLineEdit('((render|workstation)0[1-4]+)', self) layout.addWidget(self.lePattern) QtCore.QObject.connect(self.lePattern, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.leResult = QtGui.QLineEdit( 'render01-render04 or workstation01-workstation04', self) layout.addWidget(self.leResult) self.leResult.setReadOnly(True) self.leResult.setAutoFillBackground(True) self.resize(500, 100) self.show()
def __init__(self, parent=None): QtGui.QTextEdit.__init__(self, parent) self.setWindowTitle( 'Configuration: %s version %s' % (cgruconfig.VARS['company'], cgruconfig.VARS['CGRU_VERSION'])) self.ftitle = QtGui.QTextCharFormat() self.ftitle.setFontWeight(QtGui.QFont.Bold) self.ftitle.setFontItalic(True) self.fname = QtGui.QTextCharFormat() self.fname.setFontWeight(QtGui.QFont.Bold) self.fvalue = QtGui.QTextCharFormat() self.fundefined = QtGui.QTextCharFormat() self.fundefined.setFontItalic(True) self.textCursor().insertText('Python:\n', self.ftitle) self.appendVar(cgrupyqt.PythonQtType, str(cgrupyqt.PythonQt)) self.appendVar('sys.prefix', sys.prefix) self.appendVar('Executable', os.getenv('CGRU_PYTHONEXE')) self.appendVar('Version', sys.version) self.textCursor().insertText('\nVariables:\n', self.ftitle) self.appendVars(cgruconfig.VARS) self.textCursor().insertText('\nAFANASY Environment:\n', self.ftitle) self.appendEnvVar('AF_ROOT') self.appendEnvVar('AF_RENDER_CMD') self.appendEnvVar('AF_WATCH_CMD') self.textCursor().insertText('\nPython Environment:\n', self.ftitle) self.appendEnvVar('PYTHONHOME') self.appendEnvVar('PYTHONPATH') self.appendEnvVar('CGRU_PYTHON') self.appendEnvVar('AF_PYTHON') self.textCursor().insertText('\nSystem Environment:\n', self.ftitle) self.appendEnvVar('PATH') self.appendVar('PWD', os.getcwd()) for afile in cgruconfig.VARS['filenames']: self.appendConfigFile(afile) # Set window icon: iconpath = cgruutils.getIconFileName('info') if iconpath is not None: self.setWindowIcon(QtGui.QIcon(iconpath)) self.resize(self.viewport().size()) self.moveCursor(QtGui.QTextCursor.Start) self.setReadOnly(True) self.show()
def addAction(self, menuname, separator, actionname, function, iconname=None): if separator: self.menu[menuname].addSeparator() if iconname is None: iconname = actionname.lower().replace(' ', '_').replace('.', '') iconpath = cgruutils.getIconFileName(iconname) action = QtGui.QAction(actionname, self) if iconpath is not None: action.setIcon(QtGui.QIcon(iconpath)) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), function) self.menu[menuname].addAction(action)
def __init__(self, parent, name, command, iconpath=None): QtGui.QAction.__init__(self, name, parent) if iconpath is not None: iconpath = cgruutils.getIconFileName(iconpath) if iconpath is not None: self.setIcon(QtGui.QIcon(iconpath)) else: print('WARNING: Icon "%s" does not exist.' % iconpath) self.name = name self.cmd = command
def __init__(self): QtGui.QWidget.__init__(self) self.setWindowTitle(sys.argv[0]) layout = QtGui.QVBoxLayout(self) self.cmdField = QtGui.QTextEdit(self) self.cmdField.setReadOnly(True) layout.addWidget(self.cmdField) self.outputField = QtGui.QTextEdit(self) self.outputField.setReadOnly(True) layout.addWidget(self.outputField) command = '' for arg in sys.argv[1:]: if command != '': command += ' ' command += '"%s"' % arg if sys.version_info[0] < 3: command = command.decode('utf-8') else: command = str(command, 'utf-8') self.cmdField.setText(command) arguments = [] if sys.platform.find('win') == 0: shell = 'cmd.exe' arguments.append('/c') else: shell = '/bin/bash' arguments.append('-c') arguments.append(command) self.process = QtCore.QProcess(self) self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) QtCore.QObject.connect(self.process, QtCore.SIGNAL('finished( int)'), self.processfinished) QtCore.QObject.connect(self.process, QtCore.SIGNAL('readyRead()'), self.processoutput) self.process.start(shell, arguments)
def addMenu(self, parentmenu, menuname, iconname=None): if menuname in self.menu: return False if iconname is None: iconname = menuname.lower().replace(' ', '_').replace('.', '') iconpath = cgruutils.getIconFileName(iconname) if iconpath is not None: self.menu[menuname] = parentmenu.addMenu(QtGui.QIcon(iconpath), menuname) else: self.menu[menuname] = parentmenu.addMenu(menuname) return True
def showInfo(tray=None): renders = af.Cmd().renderGetLocal() if renders is None or len(renders) == 0: if tray is not None: tray.showMessage('Render information:', 'No local render client found.') return global WndInfo WndInfo = QtGui.QTextEdit() WndInfo.setPlainText(json.dumps(renders[0], sort_keys=True, indent=4)) WndInfo.setReadOnly(True) WndInfo.resize(WndInfo.viewport().size()) WndInfo.setWindowTitle('AFANASY Render Information:') WndInfo.show()
def __init__(self): # Main Window QtGui.QWidget.__init__(self) self.constructed = False self.evaluated = False self.output = '' self.setWindowTitle('Afanasy Starter CGRU ' + os.getenv('CGRU_VERSION', '')) self.fields = dict() self.labels = dict() # Get File Type dependant dicts self.labelNode_name = labelNodeNameDict() self.labelNode_tooltip = labelNodeTooltipsDict() self.labelTake_name = labelTakeNameDict() self.labelTake_tooltip = labelTakeTooltipsDict() # Top level layouts: topLayout = QtGui.QVBoxLayout(self) tabwidget = QtGui.QTabWidget(self) topLayout.addWidget(tabwidget) # General Tab: generalwidget = QtGui.QWidget(self) tabwidget.addTab(generalwidget, 'Scene') generallayout = QtGui.QVBoxLayout(generalwidget) # Job Tab: jobwidget = QtGui.QWidget(self) tabwidget.addTab(jobwidget, 'Job') joblayout = QtGui.QVBoxLayout(jobwidget) # Advanced Tab: auxwidget = QtGui.QWidget(self) tabwidget.addTab(auxwidget, 'Advanced') advlayout = QtGui.QVBoxLayout(auxwidget) # Service Type: lFileType = QtGui.QHBoxLayout() generallayout.addLayout(lFileType) lFileType.addWidget(QtGui.QLabel('Override Service Type:', self)) self.fields['servicetype'] = QtGui.QComboBox(self) lFileType.addWidget(self.fields['servicetype']) QtCore.QObject.connect(self.fields['servicetype'], QtCore.SIGNAL('currentIndexChanged(int)'), self.setFileType) # Scene: lScene = QtGui.QHBoxLayout() generallayout.addLayout(lScene) lScene.addWidget(QtGui.QLabel('File:', self)) self.fields['scenefile'] = QtGui.QLineEdit(Scene, self) lScene.addWidget(self.fields['scenefile']) QtCore.QObject.connect(self.fields['scenefile'], QtCore.SIGNAL('editingFinished()'), self.evaluate) bBrowseScene = QtGui.QPushButton('Browse', self) lScene.addWidget(bBrowseScene) QtCore.QObject.connect(bBrowseScene, QtCore.SIGNAL('pressed()'), self.browseScene) # Working Directory: lWDir = QtGui.QHBoxLayout() generallayout.addLayout(lWDir) lWDir.addWidget(QtGui.QLabel('Working Directory/Project:', self)) self.fields['wdir'] = QtGui.QLineEdit(self) lWDir.addWidget(self.fields['wdir']) QtCore.QObject.connect(self.fields['wdir'], QtCore.SIGNAL('editingFinished()'), self.evaluate) self.fields['scenewdir'] = QtGui.QCheckBox('Use Scene Folder', self) self.fields['scenewdir'].setChecked(True) QtCore.QObject.connect(self.fields['scenewdir'], QtCore.SIGNAL('stateChanged(int)'), self.evaluate) lWDir.addWidget(self.fields['scenewdir']) # Output images: lImages = QtGui.QHBoxLayout() generallayout.addLayout(lImages) lImages.addWidget(QtGui.QLabel('Output Images:', self)) self.fields['outimages'] = QtGui.QLineEdit(self) lImages.addWidget(self.fields['outimages']) QtCore.QObject.connect(self.fields['outimages'], QtCore.SIGNAL('editingFinished()'), self.evaluate) lImages.addWidget(QtGui.QLabel('Browse')) bBrowseOutImages = QtGui.QPushButton('File', self) lImages.addWidget(bBrowseOutImages) QtCore.QObject.connect(bBrowseOutImages, QtCore.SIGNAL('pressed()'), self.browseOutImages) bBrowseOutFolder = QtGui.QPushButton('Dir', self) lImages.addWidget(bBrowseOutFolder) QtCore.QObject.connect(bBrowseOutFolder, QtCore.SIGNAL('pressed()'), self.browseOutFolder) # Frames: lFrames = QtGui.QHBoxLayout() generallayout.addLayout(lFrames) lFrames.addWidget(QtGui.QLabel('Frames:', self)) self.fields['framestart'] = QtGui.QSpinBox(self) self.fields['framestart'].setRange(-1000000000, 1000000000) self.fields['framestart'].setValue(1) QtCore.QObject.connect(self.fields['framestart'], QtCore.SIGNAL('editingFinished()'), self.evaluate) lFrames.addWidget(self.fields['framestart']) self.fields['frameend'] = QtGui.QSpinBox(self) self.fields['frameend'].setRange(-1000000000, 1000000000) self.fields['frameend'].setValue(1) QtCore.QObject.connect(self.fields['frameend'], QtCore.SIGNAL('editingFinished()'), self.evaluate) lFrames.addWidget(self.fields['frameend']) lFrames.addWidget(QtGui.QLabel('by', self)) self.fields['frameby'] = QtGui.QSpinBox(self) lFrames.addWidget(self.fields['frameby']) QtCore.QObject.connect(self.fields['frameby'], QtCore.SIGNAL('editingFinished()'), self.evaluate) self.fields['frameby'].setRange(1, 1000000000) lFrames.addWidget(QtGui.QLabel('per task', self)) self.fields['framespt'] = QtGui.QSpinBox(self) lFrames.addWidget(self.fields['framespt']) QtCore.QObject.connect(self.fields['framespt'], QtCore.SIGNAL('editingFinished()'), self.evaluate) self.fields['framespt'].setRange(1, 1000000000) # Node / Camera / Take: lNode = QtGui.QHBoxLayout() generallayout.addLayout(lNode) self.labels['node'] = QtGui.QLabel(self.labelNode_name['default']) lNode.addWidget(self.labels['node']) self.labels['node'].setToolTip(self.labelNode_tooltip['default']) self.fields['node'] = QtGui.QLineEdit(self) lNode.addWidget(self.fields['node']) QtCore.QObject.connect(self.fields['node'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.labels['take'] = QtGui.QLabel(self.labelTake_name['default']) lNode.addWidget(self.labels['take']) self.labels['take'].setToolTip(self.labelTake_tooltip['default']) self.fields['take'] = QtGui.QLineEdit(self) lNode.addWidget(self.fields['take']) QtCore.QObject.connect(self.fields['take'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Advanced: # OS Type: osLayout = QtGui.QHBoxLayout() advlayout.addLayout(osLayout) osLayout.addWidget(QtGui.QLabel('Operating System Type:')) self.fields['os'] = QtGui.QLineEdit(self) osLayout.addWidget(self.fields['os']) QtCore.QObject.connect(self.fields['os'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Tasks Command: exelayout = QtGui.QHBoxLayout() advlayout.addLayout(exelayout) label = QtGui.QLabel('Tasks Executable:') label.setToolTip('Override launching programm') exelayout.addWidget(label) self.fields['exec'] = QtGui.QLineEdit(self) exelayout.addWidget(self.fields['exec']) QtCore.QObject.connect(self.fields['exec'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.execBrowseButton = QtGui.QPushButton('Browse', self) exelayout.addWidget(self.execBrowseButton) QtCore.QObject.connect(self.execBrowseButton, QtCore.SIGNAL('pressed()'), self.browseExec) # Extra Arguments: exarglayout = QtGui.QHBoxLayout() advlayout.addLayout(exarglayout) exarglayout.addWidget(QtGui.QLabel('Extra Arguments:')) self.fields['extrargs'] = QtGui.QLineEdit(self) exarglayout.addWidget(self.fields['extrargs']) QtCore.QObject.connect(self.fields['extrargs'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Preview: prvlayout = QtGui.QHBoxLayout() advlayout.addLayout(prvlayout) prvlayout.addWidget(QtGui.QLabel('Preview:')) self.fields['preview'] = QtGui.QLineEdit(self) prvlayout.addWidget(self.fields['preview']) QtCore.QObject.connect(self.fields['preview'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Job: lJobName = QtGui.QHBoxLayout() joblayout.addLayout(lJobName) lJobName.addWidget(QtGui.QLabel('Name:', self)) self.fields['jobname'] = QtGui.QLineEdit(self) lJobName.addWidget(self.fields['jobname']) QtCore.QObject.connect(self.fields['jobname'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.fields['jobnamescene'] = QtGui.QCheckBox('Use Scene Name', self) lJobName.addWidget(self.fields['jobnamescene']) self.fields['jobnamescene'].setChecked(True) QtCore.QObject.connect(self.fields['jobnamescene'], QtCore.SIGNAL('stateChanged(int)'), self.evaluate) # Capacity, max run tasks, priority: lCapMax = QtGui.QHBoxLayout() joblayout.addLayout(lCapMax) lCapMax.addWidget(QtGui.QLabel('Capacity:', self)) self.fields['capacity'] = QtGui.QSpinBox(self) lCapMax.addWidget(self.fields['capacity']) self.fields['capacity'].setRange(-1, 1000000) self.fields['capacity'].setValue(-1) QtCore.QObject.connect(self.fields['capacity'], QtCore.SIGNAL('valueChanged(int)'), self.evaluate) lCapMax.addWidget(QtGui.QLabel('Maximum Running Tasks:', self)) self.fields['maxruntasks'] = QtGui.QSpinBox(self) lCapMax.addWidget(self.fields['maxruntasks']) self.fields['maxruntasks'].setRange(-1, 1000000) self.fields['maxruntasks'].setValue(-1) QtCore.QObject.connect(self.fields['maxruntasks'], QtCore.SIGNAL('valueChanged(int)'), self.evaluate) lCapMax.addWidget(QtGui.QLabel('Priority:', self)) self.fields['priority'] = QtGui.QSpinBox(self) lCapMax.addWidget(self.fields['priority']) self.fields['priority'].setRange(-1, 250) self.fields['priority'].setValue(-1) QtCore.QObject.connect(self.fields['priority'], QtCore.SIGNAL('valueChanged(int)'), self.evaluate) # Depend Masks: lDepends = QtGui.QHBoxLayout() joblayout.addLayout(lDepends) lDepends.addWidget(QtGui.QLabel('Depend Mask:', self)) self.fields['dependmask'] = QtGui.QLineEdit(self) lDepends.addWidget(self.fields['dependmask']) QtCore.QObject.connect(self.fields['dependmask'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) lDepends.addWidget(QtGui.QLabel('Global:', self)) self.fields['dependglobal'] = QtGui.QLineEdit(self) lDepends.addWidget(self.fields['dependglobal']) QtCore.QObject.connect(self.fields['dependglobal'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Host Masks: lHostMasks = QtGui.QHBoxLayout() joblayout.addLayout(lHostMasks) lHostMasks.addWidget(QtGui.QLabel('Hosts Mask:', self)) self.fields['hostsmask'] = QtGui.QLineEdit(self) lHostMasks.addWidget(self.fields['hostsmask']) QtCore.QObject.connect(self.fields['hostsmask'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) lHostMasks.addWidget(QtGui.QLabel('Exclude:', self)) self.fields['hostsexclude'] = QtGui.QLineEdit(self) lHostMasks.addWidget(self.fields['hostsexclude']) QtCore.QObject.connect(self.fields['hostsexclude'], QtCore.SIGNAL('textEdited(QString)'), self.evaluate) # Presets: presetsLayout = QtGui.QHBoxLayout() topLayout.addLayout(presetsLayout) presetsLayout.addWidget(QtGui.QLabel('Recent:', self)) self.cbRecent = QtGui.QComboBox(self) presetsLayout.addWidget(self.cbRecent) self.bBrowseLoad = QtGui.QPushButton('Load', self) presetsLayout.addWidget(self.bBrowseLoad) QtCore.QObject.connect(self.bBrowseLoad, QtCore.SIGNAL('pressed()'), self.browseLoad) self.bBrowseSave = QtGui.QPushButton('Save', self) presetsLayout.addWidget(self.bBrowseSave) QtCore.QObject.connect(self.bBrowseSave, QtCore.SIGNAL('pressed()'), self.browseSave) # Command Field: self.teCmd = QtGui.QTextEdit(self) topLayout.addWidget(self.teCmd) # Buttons: buttonsLayout = QtGui.QHBoxLayout() topLayout.addLayout(buttonsLayout) self.bStart = QtGui.QPushButton('&Start', self) buttonsLayout.addWidget(self.bStart) QtCore.QObject.connect(self.bStart, QtCore.SIGNAL('pressed()'), self.start) self.fields['paused'] = QtGui.QCheckBox('Paused', self) buttonsLayout.addWidget(self.fields['paused']) QtCore.QObject.connect(self.fields['paused'], QtCore.SIGNAL('stateChanged(int)'), self.evaluate) self.bRefresh = QtGui.QPushButton('&Refresh', self) buttonsLayout.addWidget(self.bRefresh) QtCore.QObject.connect(self.bRefresh, QtCore.SIGNAL('pressed()'), self.evaluate) self.bQuitSave = QtGui.QPushButton('&Quit&&Store', self) buttonsLayout.addWidget(self.bQuitSave) QtCore.QObject.connect(self.bQuitSave, QtCore.SIGNAL('pressed()'), self.quitsave) self.constructed = True # Set window icon: iconpath = cgruutils.getIconFileName('afanasy') if iconpath is not None: self.setWindowIcon(QtGui.QIcon(iconpath)) # Refresh recent: self.refreshRecent() # Load last settings: if not self.load(FileLast): self.evaluate()
self.process.start(command) def processfinished(self, exitCode): print('Exit code = %d' % exitCode) if exitCode != 0: return self.saveRecent() self.save(FileLast) self.output += '\n The job successfully sent.' self.teCmd.setText(self.output) self.bStart.setEnabled(False) def processoutput(self): output = self.process.readAll() print(output.__class__.__name__) if sys.version_info[0] < 3: output = str(output) else: if output.__class__.__name__ == 'QByteArray': output = str(output.data(), 'utf-8') else: output = str(output, 'utf-8') print(output) self.teCmd.insertPlainText(output) self.teCmd.moveCursor(QtGui.QTextCursor.End) self.output += output app = QtGui.QApplication(sys.argv) dialog = Dialog() dialog.show() app.exec_()
def __init__(self, parent=None): QtGui.QSystemTrayIcon.__init__(self, parent) self.parent = parent # Menu: self.menu = dict() self.menu['menu'] = QtGui.QMenu() # Update item only if CGRU_UPDATE_CMD defined: if cgruconfig.VARS['CGRU_UPDATE_CMD'] is not None: action = QtGui.QAction('Update', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.update) self.menu['menu'].addAction(action) self.menu['menu'].addSeparator() # Load menu: menu_path = os.path.join( os.path.join(cgruconfig.VARS['CGRU_LOCATION'], 'start') ) # TODO: why to use os.path.join() two times here, to add '/' at the end ??? menu_paths = cgruconfig.VARS['menu_path'] if menu_paths is None: menu_paths = menu_path if menu_paths.find(';') != -1: menu_paths = menu_paths.split(';') elif sys.platform.find('win') == -1: menu_paths = menu_paths.split(':') else: menu_paths = [menu_paths] if not menu_path in menu_paths: menu_paths.append(menu_path) for menu_path in menu_paths: if not os.path.isdir(menu_path): continue for dirpath, dirnames, filenames in os.walk( menu_path, True, None, True): if dirpath.find('/.') != -1: continue if dirpath.find('\\.') != -1: continue menuname = os.path.basename(dirpath) if menuname == os.path.basename(menu_path): menuname = 'menu' else: self.addMenu(self.menu['menu'], menuname) filenames.sort() was_separator = True for filename in filenames: if filename[0] == '.' or filename[0] == '_': continue if sys.platform[:3] == 'win': if filename[-4:] != '.cmd': continue itemname = filename[:-4] else: if filename[-3:] != '.sh': continue itemname = filename[:-3] filename = os.path.join(dirpath, filename) with open(filename, 'r') as f: lines = f.readlines() iconpath = None separator = False for line in lines: if line.find('Name=') != -1: itemname = line.split('Name=')[-1].strip() if line.find('Icon=') != -1: iconpath = line.split('Icon=')[-1].strip() if line.find('Separator') != -1: separator = True if separator: if not was_separator: self.menu[menuname].addSeparator() was_separator = True else: was_separator = False action = ActionCommand(self, itemname, filename, iconpath) self.menu[menuname].addAction(action) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), action.runCommand) if separator: self.menu[menuname].addSeparator() # Add permanent items to 'Afanasy': if not self.addMenu(self.menu['menu'], 'AFANASY'): self.menu['AFANASY'].addSeparator() action = QtGui.QAction('Web GUI', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.afwebgui) self.menu['AFANASY'].addAction(action) self.menu['AFANASY'].addSeparator() self.action_user = QtGui.QAction('Set User...', self) QtCore.QObject.connect(self.action_user, QtCore.SIGNAL('triggered()'), render.setUserDialog) self.action_user.setToolTip('Change local render user name.') self.menu['AFANASY'].addAction(self.action_user) action = QtGui.QAction('Set nimby', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), nimby.setnimby) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Set NIMBY', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), nimby.setNIMBY) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Set Free', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), nimby.setFree) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Eject Tasks', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), nimby.ejectTasks) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Eject Not My Tasks', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), nimby.ejectNotMyTasks) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Render Info', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), self.renderInfo) self.menu['AFANASY'].addAction(action) self.menu['AFANASY'].addSeparator() action = QtGui.QAction('Nimby Schedule...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), self.editNimby) self.menu['AFANASY'].addAction(action) self.menu['AFANASY'].addSeparator() action = QtGui.QAction('Set Server...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.setAFANASYServer) self.menu['AFANASY'].addAction(action) self.menu['AFANASY'].addSeparator() action = QtGui.QAction('Exit Render', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.exitRender) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Exit Watch', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.exitMonitor) self.menu['AFANASY'].addAction(action) action = QtGui.QAction('Exit All Clients', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.exitClients) self.menu['AFANASY'].addAction(action) self.menu['menu'].addSeparator() # Add Software menu if it was not created by custom files: if not 'Software' in self.menu: self.addMenu(self.menu['menu'], 'Software') self.menu['menu'].addSeparator() action = QtGui.QAction( QtGui.QIcon(cgruutils.getIconFileName('folder')), '[ browse ]', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), software.browse) self.menu['Software'].addAction(action) for soft in software.Names: icon = software.getIcon(soft) if icon is None: action = QtGui.QAction(soft, self) else: action = QtGui.QAction(icon, soft, self) eval("QtCore.QObject.connect(action," " QtCore.SIGNAL('triggered()')," " software.start%s)" % soft) self.menu['Software'].addAction(action) # Software setup: self.menu['Setup Soft'] = QtGui.QMenu('Setup Soft') self.menu['Software'].addMenu(self.menu['Setup Soft']) for soft in software.Names: action = QtGui.QAction(soft, self) eval("QtCore.QObject.connect(action," " QtCore.SIGNAL('triggered()')," " software.locate%s)" % soft) self.menu['Setup Soft'].addAction(action) # Software examples: self.menu['Examples'] = QtGui.QMenu('Examples') self.menu['Software'].addMenu(self.menu['Examples']) for soft in software.Names: action = QtGui.QAction(soft, self) eval("QtCore.QObject.connect(action," " QtCore.SIGNAL('triggered()')," " software.example%s)" % soft) self.menu['Examples'].addAction(action) # Add permanent items to 'Configure': if not self.addMenu(self.menu['menu'], 'Configure'): self.menu['Configure'].addSeparator() action = QtGui.QAction('Reload Config', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.confReload) self.menu['Configure'].addAction(action) action = QtGui.QAction('Set Docs URL...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.setDocsURL) self.menu['Configure'].addAction(action) action = QtGui.QAction('Edit Config...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.editCGRUConfig) self.menu['Configure'].addAction(action) action = QtGui.QAction('Set Web Browser...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.setWebBrowser) self.menu['Configure'].addAction(action) action = QtGui.QAction('Set Text Editor...', self) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), cmd.setTextEditor) self.menu['Configure'].addAction(action) self.addAction('menu', True, 'Show Info...', self.cgruInfo, 'info') self.addAction('menu', True, 'Documentation', cmd.cgruDocs) self.addAction('menu', True, 'Restart', cmd.restart) self.addAction('menu', False, 'Quit && Exit Clients', cmd.quitExitClients) self.addAction('menu', False, 'Quit', cmd.quit) self.setContextMenu(self.menu['menu']) # Prepare Icons: self.icons = dict() icon_filename = cgruconfig.VARS['tray_icon'] if icon_filename is None: icon_filename = 'keeper' icon_filename = cgruutils.getIconFileName(icon_filename) self.icon_epmty = QtGui.QPixmap(icon_filename) self.icons['empty'] = QtGui.QIcon(self.icon_epmty) self.makeIcon('offline_free', online=False, nimby=False, busy=False) self.makeIcon('online_free', online=True, nimby=False, busy=False) self.makeIcon('offline_nimby', online=False, nimby=True, busy=False) self.makeIcon('online_nimby', online=True, nimby=True, busy=False) self.makeIcon('offline_free_busy', online=False, nimby=False, busy=True) self.makeIcon('online_free_busy', online=True, nimby=False, busy=True) self.makeIcon('offline_nimby_busy', online=False, nimby=True, busy=True) self.makeIcon('online_nimby_busy', online=True, nimby=True, busy=True) # Decorate and show: self.showIcon() self.setToolTip('%s Keeper %s' % (cgruconfig.VARS['company'].upper(), os.getenv('CGRU_VERSION', ''))) QtCore.QObject.connect( self, QtCore.SIGNAL('activated( QSystemTrayIcon::ActivationReason)'), self.activated_slot) self.show()
def makeIcon(self, name, online, nimby, busy): painting = self.icon_epmty painter = QtGui.QPainter(painting) icon_size = painting.width() text_font = QtGui.QFont('Arial', icon_size / 3) text_font.setBold(True) rect_back = QtCore.QRect(icon_size * 3 / 10, icon_size * 3 / 10, icon_size * 2 / 5, icon_size * 2 / 5) text_color = QtGui.QColor(0, 0, 0) back_color = QtGui.QColor(150, 150, 150) if online: if nimby: if busy: text_color = QtGui.QColor(255, 0, 0) back_color = QtGui.QColor(50, 50, 250) else: text_color = QtGui.QColor(190, 190, 190) back_color = QtGui.QColor(40, 40, 240) else: if busy: text_color = QtGui.QColor(255, 0, 0) back_color = QtGui.QColor(90, 90, 90) else: text_color = QtGui.QColor(0, 200, 0) back_color = QtGui.QColor(90, 90, 90) elif nimby: back_color = QtGui.QColor(140, 140, 250) rect_render = QtCore.QRect(icon_size / 4, icon_size / 4, icon_size / 2, icon_size / 2) painter.fillRect(rect_back, back_color) painter.setFont(text_font) painter.setPen(text_color) painter.drawText(rect_render, QtCore.Qt.AlignCenter, 'R') self.icons[name] = QtGui.QIcon(painting)
def getIcon(soft): iconpath = cgruutils.getIconFileName(os.path.join('software', soft.lower())) if iconpath is not None: return QtGui.QIcon(iconpath) return None
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.setWindowTitle('Edit Nimby') rows = ['day', 'begin', 'dash', 'end', 'enable', 'allow', 'eject'] self.weekdays = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] self.days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'] self.time_format = 'hh:mm' self.te_begin = dict() self.te_end = dict() self.cb_enable = dict() self.cb_allow = dict() self.cb_eject = dict() toplayout = QtGui.QVBoxLayout(self) columns = QtGui.QHBoxLayout() toplayout.addLayout(columns) vlayouts = dict() for row in rows: vlayouts[row] = QtGui.QVBoxLayout() columns.addLayout(vlayouts[row]) daynum = 0 for day in self.days: time_begin = '00:00' time_end = '00:00' enable = False allow = True eject = False var = 'nimby_' + day if var in cgruconfig.VARS: line = cgruconfig.VARS[var] if line is None: continue lines = line.split(' ') if len(lines) < 2: continue time_begin = lines[0] time_end = lines[1] enable = False allow = True eject = False if 'nimby' in lines: allow = True if 'NIMBY' in lines: allow = False if 'Eject' in lines: eject = True if 'Enable' in lines: enable = True vlayouts['day'].addWidget(QtGui.QLabel(self.weekdays[daynum], self)) self.te_begin[day] = QtGui.QTimeEdit( QtCore.QTime.fromString(time_begin, self.time_format)) self.te_begin[day].setDisplayFormat(self.time_format) vlayouts['begin'].addWidget(self.te_begin[day]) label = QtGui.QLabel(' - ', self) label.setFixedWidth(16) vlayouts['dash'].addWidget(label) self.te_end[day] = QtGui.QTimeEdit( QtCore.QTime.fromString(time_end, self.time_format)) self.te_end[day].setDisplayFormat(self.time_format) vlayouts['end'].addWidget(self.te_end[day]) self.cb_enable[day] = QtGui.QCheckBox('Enable', self) self.cb_enable[day].setChecked(enable) vlayouts['enable'].addWidget(self.cb_enable[day]) self.cb_allow[day] = QtGui.QCheckBox('Allow My Jobs', self) self.cb_allow[day].setChecked(allow) vlayouts['allow'].addWidget(self.cb_allow[day]) self.cb_eject[day] = QtGui.QCheckBox('Eject Running Tasks', self) self.cb_eject[day].setChecked(eject) vlayouts['eject'].addWidget(self.cb_eject[day]) daynum += 1 hlayout = QtGui.QHBoxLayout() b_accept = QtGui.QPushButton('Accept', self) b_cancel = QtGui.QPushButton('Cancel', self) hlayout.addWidget(b_accept) hlayout.addWidget(b_cancel) toplayout.addLayout(hlayout) QtCore.QObject.connect(b_accept, QtCore.SIGNAL('pressed()'), self.applySettings) QtCore.QObject.connect(b_cancel, QtCore.SIGNAL('pressed()'), self.close) # Set window icon: iconpath = cgruutils.getIconFileName('afanasy') if iconpath is not None: self.setWindowIcon(QtGui.QIcon(iconpath)) self.show()
def __init__(self): QtGui.QWidget.__init__(self) self.constructed = False self.evaluated = False self.test = False self.setWindowTitle('Scan Scan - CGRU ' + cgruconfig.VARS['CGRU_VERSION']) self.mainLayout = QtGui.QVBoxLayout(self) self.tabwidget = QtGui.QTabWidget(self) self.generalwidget = QtGui.QWidget(self) self.tabwidget.addTab(self.generalwidget, 'General') self.generallayout = QtGui.QVBoxLayout(self.generalwidget) self.parameterswidget = QtGui.QWidget(self) self.tabwidget.addTab(self.parameterswidget, 'Parameters') self.parameterslayout = QtGui.QVBoxLayout(self.parameterswidget) self.mainLayout.addWidget(self.tabwidget) # General: self.lFormat = QtGui.QHBoxLayout() self.tFormat = QtGui.QLabel('Format:', self) self.tFormat.setToolTip('Movie resolution.\n' 'Format presets located in\n' + FormatsPath) self.cbFormat = QtGui.QComboBox(self) i = 0 for format in FormatValues: self.cbFormat.addItem(FormatNames[i], format) if format == Options.format: self.cbFormat.setCurrentIndex(i) i += 1 QtCore.QObject.connect(self.cbFormat, QtCore.SIGNAL('currentIndexChanged(int)'), self.evaluate) self.tCodec = QtGui.QLabel('Codec:', self) self.tCodec.setToolTip('Codec presets located in\n' + CodecsPath) self.cbCodec = QtGui.QComboBox(self) i = 0 for name in CodecNames: self.cbCodec.addItem(name, CodecFiles[i]) if os.path.basename(CodecFiles[i]) == Options.codec: self.cbCodec.setCurrentIndex(i) i += 1 QtCore.QObject.connect(self.cbCodec, QtCore.SIGNAL('currentIndexChanged(int)'), self.evaluate) self.tFPS = QtGui.QLabel('FPS:', self) self.tFPS.setToolTip('Frame rate.') self.cbFPS = QtGui.QComboBox(self) self.cbFPS.addItem('24') self.cbFPS.addItem('25') self.cbFPS.addItem('30') self.cbFPS.setCurrentIndex(0) QtCore.QObject.connect(self.cbFPS, QtCore.SIGNAL('currentIndexChanged(int)'), self.evaluate) self.lFormat.addWidget(self.tFormat) self.lFormat.addWidget(self.cbFormat) self.lFormat.addWidget(self.tFPS) self.lFormat.addWidget(self.cbFPS) self.lFormat.addWidget(self.tCodec) self.lFormat.addWidget(self.cbCodec) self.generallayout.addLayout(self.lFormat) self.lInput = QtGui.QHBoxLayout() self.tInput = QtGui.QLabel('Scan Folder', self) self.lInput.addWidget(self.tInput) self.editInput = QtGui.QLineEdit(InputFolder, self) QtCore.QObject.connect(self.editInput, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.lInput.addWidget(self.editInput) self.btnInputBrowse = QtGui.QPushButton('Browse', self) QtCore.QObject.connect(self.btnInputBrowse, QtCore.SIGNAL('pressed()'), self.inputBrowse) self.lInput.addWidget(self.btnInputBrowse) self.generallayout.addLayout(self.lInput) self.lExtensions = QtGui.QHBoxLayout() self.tExtensions = QtGui.QLabel('Search extensions:', self) tooltip = 'Comma separated list.\n' \ 'Leave empty to find all known:\n' for ext in Extensions: tooltip += ext + ' ' self.tExtensions.setToolTip(tooltip) self.lExtensions.addWidget(self.tExtensions) self.editExtensions = QtGui.QLineEdit(Options.extensions, self) QtCore.QObject.connect(self.editExtensions, QtCore.SIGNAL('editingFinished()'), self.evaluate) self.lExtensions.addWidget(self.editExtensions) self.generallayout.addLayout(self.lExtensions) self.lInclude = QtGui.QHBoxLayout() self.tInclude = QtGui.QLabel('Include pattern:', self) self.lInclude.addWidget(self.tInclude) self.editInclude = QtGui.QLineEdit(Options.include, self) QtCore.QObject.connect(self.editInclude, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.lInclude.addWidget(self.editInclude) self.generallayout.addLayout(self.lInclude) self.lExclude = QtGui.QHBoxLayout() self.tExclude = QtGui.QLabel('Exclude pattern:', self) self.lExclude.addWidget(self.tExclude) self.editExclude = QtGui.QLineEdit(Options.exclude, self) QtCore.QObject.connect(self.editExclude, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.lExclude.addWidget(self.editExclude) self.generallayout.addLayout(self.lExclude) self.lDateTime = QtGui.QHBoxLayout() self.cDateTime = QtGui.QCheckBox('Skip folders ealier than:', self) QtCore.QObject.connect(self.cDateTime, QtCore.SIGNAL('stateChanged(int)'), self.evaluate) self.lDateTime.addWidget(self.cDateTime) self.eDateTime = QtGui.QDateTimeEdit( QtCore.QDateTime.currentDateTime(), self) self.eDateTime.setCalendarPopup(True) self.eDateTime.setDisplayFormat(DateTimeFormat) QtCore.QObject.connect(self.cDateTime, QtCore.SIGNAL('dateTimeChanged( QDateTime)'), self.evaluate) self.lDateTime.addWidget(self.eDateTime) self.generallayout.addLayout(self.lDateTime) self.lOutput = QtGui.QHBoxLayout() self.tOutput = QtGui.QLabel('Output Folder:', self) self.lOutput.addWidget(self.tOutput) self.editOutput = QtGui.QLineEdit(OutputFolder, self) QtCore.QObject.connect(self.editOutput, QtCore.SIGNAL('editingFinished()'), self.evaluate) self.lOutput.addWidget(self.editOutput) self.btnOutputBrowse = QtGui.QPushButton('Browse', self) QtCore.QObject.connect(self.btnOutputBrowse, QtCore.SIGNAL('pressed()'), self.browseOutput) self.lOutput.addWidget(self.btnOutputBrowse) self.generallayout.addLayout(self.lOutput) # Parameters: self.cAbsPath = QtGui.QCheckBox( 'Prefix movies names with images absolute input files path', self) self.cAbsPath.setChecked(Options.abspath) QtCore.QObject.connect(self.cAbsPath, QtCore.SIGNAL('stateChanged(int)'), self.evaluate) self.parameterslayout.addWidget(self.cAbsPath) self.lTemplates = QtGui.QHBoxLayout() self.tTemplate = QtGui.QLabel('Frame Template:', self) self.tTemplate.setToolTip('Frame template.\n' 'Templates are located in\n' + TemplatesPath) self.cbTemplate = QtGui.QComboBox(self) for template in Templates: self.cbTemplate.addItem(template) self.cbTemplate.setCurrentIndex(Template) self.lTemplates.addWidget(self.tTemplate) self.lTemplates.addWidget(self.cbTemplate) QtCore.QObject.connect(self.cbTemplate, QtCore.SIGNAL('currentIndexChanged(int)'), self.evaluate) self.parameterslayout.addLayout(self.lTemplates) self.lAspect = QtGui.QHBoxLayout() self.lAspect.addWidget(QtGui.QLabel('Input Images Aspect', self)) self.dsbAspect = QtGui.QDoubleSpinBox(self) self.dsbAspect.setRange(-1.0, 10.0) self.dsbAspect.setDecimals(6) self.dsbAspect.setValue(Options.aspect_in) QtCore.QObject.connect(self.dsbAspect, QtCore.SIGNAL('valueChanged(double)'), self.evaluate) self.lAspect.addWidget(self.dsbAspect) self.lAspect.addWidget(QtGui.QLabel(' (-1 = no changes) ', self)) self.parameterslayout.addLayout(self.lAspect) self.lAutoAspect = QtGui.QHBoxLayout() self.tAutoAspect = QtGui.QLabel('Auto Input Aspect', self) self.tAutoAspect.setToolTip( 'Images with width/height ratio > this value will be ' 'treated as 2:1.') self.lAutoAspect.addWidget(self.tAutoAspect) self.dsbAutoAspect = QtGui.QDoubleSpinBox(self) self.dsbAutoAspect.setRange(-1.0, 10.0) self.dsbAutoAspect.setDecimals(3) self.dsbAutoAspect.setValue(Options.aspect_auto) QtCore.QObject.connect(self.dsbAutoAspect, QtCore.SIGNAL('valueChanged(double)'), self.evaluate) self.lAutoAspect.addWidget(self.dsbAutoAspect) self.lAutoAspect.addWidget(QtGui.QLabel(' (-1 = no changes) ', self)) self.parameterslayout.addLayout(self.lAutoAspect) self.gCorrectionSettings = QtGui.QGroupBox('Image Correction') self.lCorr = QtGui.QHBoxLayout() self.gCorrectionSettings.setLayout(self.lCorr) self.tGamma = QtGui.QLabel('Gamma:', self) self.dsbGamma = QtGui.QDoubleSpinBox(self) self.dsbGamma.setRange(0.1, 10.0) self.dsbGamma.setDecimals(1) self.dsbGamma.setSingleStep(0.1) self.dsbGamma.setValue(1.0) QtCore.QObject.connect(self.dsbGamma, QtCore.SIGNAL('valueChanged(double)'), self.evaluate) self.lCorr.addWidget(self.tGamma) self.lCorr.addWidget(self.dsbGamma) self.parameterslayout.addWidget(self.gCorrectionSettings) # Bottom tab: self.cmdField = QtGui.QTextEdit(self) self.cmdField.setReadOnly(True) self.mainLayout.addWidget(self.cmdField) self.lProcess = QtGui.QHBoxLayout() self.btnStart = QtGui.QPushButton('Start', self) self.btnStart.setEnabled(False) QtCore.QObject.connect(self.btnStart, QtCore.SIGNAL('pressed()'), self.execute) self.btnStop = QtGui.QPushButton('Stop', self) self.btnStop.setEnabled(False) QtCore.QObject.connect(self.btnStop, QtCore.SIGNAL('pressed()'), self.processStop) self.btnTest = QtGui.QPushButton('Test', self) self.btnTest.setEnabled(False) QtCore.QObject.connect(self.btnTest, QtCore.SIGNAL('pressed()'), self.executeTest) self.lProcess.addWidget(self.btnTest) self.lProcess.addWidget(self.btnStart) self.lProcess.addWidget(self.btnStop) self.mainLayout.addLayout(self.lProcess) self.lAfanasy = QtGui.QHBoxLayout() self.cAfanasy = QtGui.QCheckBox('Afanasy', self) self.cAfanasy.setChecked(Options.afanasy != 0) QtCore.QObject.connect(self.cAfanasy, QtCore.SIGNAL('stateChanged(int)'), self.afanasy) self.tAfCapacity = QtGui.QLabel('Capacity:', self) self.sbAfCapacity = QtGui.QSpinBox(self) self.sbAfCapacity.setRange(-1, 1000000) self.sbAfCapacity.setValue(Options.afanasy) QtCore.QObject.connect(self.sbAfCapacity, QtCore.SIGNAL('valueChanged(int)'), self.evaluate) self.tAfMaxHosts = QtGui.QLabel('Maximum Hosts:', self) self.sbAfMaxHosts = QtGui.QSpinBox(self) self.sbAfMaxHosts.setRange(-1, 1000000) self.sbAfMaxHosts.setValue(Options.maxhosts) QtCore.QObject.connect(self.sbAfMaxHosts, QtCore.SIGNAL('valueChanged(int)'), self.evaluate) self.cAfPause = QtGui.QCheckBox('Pause', self) self.lAfanasy.addWidget(self.cAfanasy) self.lAfanasy.addWidget(self.tAfCapacity) self.lAfanasy.addWidget(self.sbAfCapacity) self.lAfanasy.addWidget(self.tAfMaxHosts) self.lAfanasy.addWidget(self.sbAfMaxHosts) self.lAfanasy.addWidget(self.cAfPause) self.mainLayout.addLayout(self.lAfanasy) self.constructed = True self.afanasy() self.evaluate()
def processoutput(self): output = self.process.readAll().data() if not isinstance(output, str): output = str(output, 'utf-8') output = output.strip() print(output) self.cmdField.insertPlainText(output + '\n') self.cmdField.moveCursor(QtGui.QTextCursor.End) def processStop(self): self.process.terminate() def getComboBoxString(comboBox): data = comboBox.itemData(comboBox.currentIndex()) if data is None: return '' if isinstance(data, str): return data if isinstance(data, unicode): return data return comboBox.itemData(comboBox.currentIndex()).toString() app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(cgruutils.getIconFileName(Options.wndicon))) dialog = Dialog() dialog.show() app.exec_()
self.lePattern = QtGui.QLineEdit('((render|workstation)0[1-4]+)', self) layout.addWidget(self.lePattern) QtCore.QObject.connect(self.lePattern, QtCore.SIGNAL('textEdited(QString)'), self.evaluate) self.leResult = QtGui.QLineEdit( 'render01-render04 or workstation01-workstation04', self) layout.addWidget(self.leResult) self.leResult.setReadOnly(True) self.leResult.setAutoFillBackground(True) self.resize(500, 100) self.show() def evaluate(self): rx = QtCore.QRegExp(self.lePattern.text()) if not rx.isValid(): self.leResult.setText('ERROR: %s' % rx.errorString()) return if rx.exactMatch(self.leName.text()): self.leResult.setText('MATCH') else: self.leResult.setText('NOT MATCH') app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(cgruutils.getIconFileName('regexp'))) dialog = Dialog() app.exec_()