def main(): import sys app = QApplication(sys.argv) QApplication.setOrganizationName('Akond Lab') QApplication.setOrganizationDomain('akond.com') QApplication.setApplicationName('WD Wrapper') QApplication.setApplicationVersion(__version__) tcl = CommandLineSettings() parser = QCommandLineParser() result = tcl.parseCommandLine(parser) if result.result == CommandLineParseResult.CommandLineError: print(result.errorMessage, "\n\n", parser.helpText(), file=sys.stderr) return 1 elif result.result == CommandLineParseResult.CommandLineVersionRequested: print(QCoreApplication.applicationName(), QCoreApplication.applicationVersion(), "\n") return 0 elif result.result == CommandLineParseResult.CommandLineHelpRequested: parser.showHelp() return 0 mainWin = MainWindow() # mainWin.resize(800, 600) # now in config, see: MainWindow.readWindowSettings mainWin.show() sys.exit(app.exec_())
def process_arguments(app): """Arguments parser""" parser = QCommandLineParser() # -h, --help, -? (on windows) parser.addHelpOption() # --version show_version = QCommandLineOption( ["version"], QCoreApplication.translate( "main", "Display the version of Cutevariant and exit."), ) parser.addOption(show_version) # -v, --verbose modify_verbosity = QCommandLineOption( ["v", "verbose"], QCoreApplication.translate("main", "Modify verbosity."), "notset|debug|info|error", # options available (value name) "notset", # default value ) parser.addOption(modify_verbosity) # Process the actual command line arguments given by the user parser.process(app) # args = parser.positionalArguments() if parser.isSet(show_version): print("Cutevariant " + __version__) exit() if parser.isSet(modify_verbosity): # Set log level cm.log_level(parser.value(modify_verbosity).upper())
def __init__(self): super(SerialProgramLoader, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.loaderFrameLayout = QVBoxLayout(self.ui.loaderFrame) self.ui.loaderFrameLayout.setMargin(0) self.ui.loaderFrame.setLayout(self.ui.loaderFrameLayout) self.ui.loader = Loader(self) self.ui.loaderFrameLayout.addWidget(self.ui.loader) if __name__ == '__main__': app = QApplication(sys.argv) app.setApplicationName('Serial Program Loader') app.setApplicationVersion('0.0.0') parser = QCommandLineParser() parser.setApplicationDescription( 'Program to send Machining routines to CNC machines via serial port') startFullScreen = QCommandLineOption(('f', 'fullscreen'), "Start in fullscreen mode") parser.addOption(startFullScreen) parser.addHelpOption() parser.addVersionOption() parser.process(app) globalSettings = QSettings('settings.ini', QSettings.IniFormat) window = SerialProgramLoader() if parser.isSet(startFullScreen): window.showFullScreen() else: window.showMaximized() ret = app.exec_()
def __init__(self, eui_class): self._eui_class = eui_class self._app = QApplication(sys.argv) parser = QCommandLineParser() parser.addHelpOption() parser.addVersionOption() noSplash = QCommandLineOption(["n", "no-splash"], "don't show splash screen") parser.addOption(noSplash) parser.process(self._app) self._loop = QEventLoop(self._app) asyncio.set_event_loop(self._loop) self._comms = [] self._splash = not (parser.isSet(noSplash)) self._eui = None
app.setApplicationVersion("0.1.0") # # Command line languageListOption = QCommandLineOption( ["language-list"], QCoreApplication.translate("main", "Lists available application languages.")) languageOption = QCommandLineOption( ["language"], QCoreApplication.translate("main", "Adjusts application language."), QCoreApplication.translate("main", "language code")) parser = QCommandLineParser() parser.setApplicationDescription( QCoreApplication.translate( "main", "{0} - An editor tool for documents with character-separated values" ).format(app.applicationName())) parser.addHelpOption() parser.addVersionOption() parser.addOption(languageListOption) parser.addOption(languageOption) parser.addPositionalArgument("files", "Documents to open.", "[files...]") parser.process(app) # Command line: Language list if parser.isSet(languageListOption): sys.exit(showLanguageList())