OptionParser: options and args passed to PyQT app

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pierreroth64@gmail.com

    #1

    OptionParser: options and args passed to PyQT app

    Hi,

    New with python, I've developped a small cmd line script parsing opts
    and args with an OptionParser:

    in myApp.py:

    ....blablabla.. .
    parser.add_opti on(...)
    parser.add_opti on(...)
    (options, args) = parser.parse_ar gs()
    doCheckParams(p arser, options, args)
    ....blablabla.. .

    I'm trying now to integrate it into a PyQt GUI app: Then options and
    args are coming from my app fields.

    here's my app:

    from PyQt4 import QtCore, QtGui
    from gui import Ui_my_app_gui
    import myApp

    class MyAppDialog(QtG ui.QDialog):
    def __init__(self):
    QtGui.QDialog._ _init__(self)
    self.ui = Ui_my_app_gui()
    self.ui.setupUi (self)

    self.connect(se lf.ui.launch_bu tton, QtCore.SIGNAL(" clicked()"),
    self._run)

    def _run(self):

    options = {}
    options['opt1'] = self.ui.opt1_va lue.text
    options['opt2'] = self.ui.opt2_va lue.text

    args = str(self.ui.arg 1_value.text)

    try:
    myApp.doCheckPa rams(parser=Non e, options=options , args=args)
    # code does not reach this line!
    myApp.run()
    except Exception, message:
    self.ui.output_ value.setEnable d(True)
    self.ui.output_ value.text = message


    if __name__=="__ma in__":
    app = QtGui.QApplicat ion(sys.argv)
    dialog = MyAppDialog()
    dialog.show()
    app.exec_()

    When clicking on my launch_button button, I can see that some code is
    executed but my code never reaches the "# code does not reach this
    line!" line....

    Thanks a lot for your precious help!

    Pierre
Working...