def main(): if len(sys.argv) > 1: try: opts, args = getopt.gnu_getopt(sys.argv, 'd:fhiqset', ['decimals=', 'fixed-decimals', 'help', 'interactive', 'quiet', 'sci-notation', 'eng-notation', 'test']) except getopt.GetoptError: # check that arguments aren't Qt GUI options if sys.argv[1][:3] not in ['-ba', '-bg', '-bt', '-bu', '-cm', '-di', '-do', '-fg', '-fn', '-fo', '-ge', '-gr', '-im', '-in', '-na', '-nc', '-no', '-re', '-se', '-st', '-sy', '-ti', '-vi', '-wi']: app = QCoreApplication(sys.argv) setupTranslator(app) import cmdline cmdline.printUsage() sys.exit(2) else: app = QCoreApplication(sys.argv) setupTranslator(app) import cmdline try: cmdline.parseArgs(opts, args[1:]) except KeyboardInterrupt: pass return userStyle = '-style' in ' '.join(sys.argv) app = QApplication(sys.argv) setupTranslator(app) # must be before importing any convertall modules import convertdlg if not userStyle and not sys.platform.startswith('win'): QApplication.setStyle('plastique') win = convertdlg.ConvertDlg() win.show() signal.signal(signal.SIGINT, signal.SIG_IGN) app.exec_()
for arg in sys.argv[1:]: for opt in qtOpts: if arg.startswith(opt): return False return True if __name__ == '__main__': if hasCmdLineArgs(): import getopt import cmdline try: opts, args = getopt.gnu_getopt(sys.argv, cmdline.availOptions, cmdline.availLongOptions) except getopt.GetoptError: cmdline.printUsage() sys.exit(2) cmdline.parseArgs(opts, args[1:]) else: import signal from PyQt4 import QtGui import convertdlg userStyle = '-style' in ' '.join(sys.argv) app = QtGui.QApplication(sys.argv) if not userStyle and not sys.platform.startswith('win'): QtGui.QApplication.setStyle('plastique') win = convertdlg.ConvertDlg() win.show() signal.signal(signal.SIGINT, signal.SIG_IGN) app.exec_()