OptionParser: options and args passed to PyQT app

pierreroth64 at gmail.com pierreroth64 at gmail.com
Mon Oct 6 11:10:22 EDT 2008


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_option(...)
parser.add_option(...)
(options, args) = parser.parse_args()
doCheckParams(parser, 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(QtGui.QDialog):
	def __init__(self):
		QtGui.QDialog.__init__(self)
		self.ui = Ui_my_app_gui()
		self.ui.setupUi(self)

		self.connect(self.ui.launch_button, QtCore.SIGNAL("clicked()"),
self._run)

	def _run(self):

		options = {}
		options['opt1'] = self.ui.opt1_value.text
		options['opt2'] = self.ui.opt2_value.text

		args = str(self.ui.arg1_value.text)

		try:
			myApp.doCheckParams(parser=None, options=options, args=args)
                        # code does not reach this line!
			myApp.run()
		except Exception, message:
			self.ui.output_value.setEnabled(True)
			self.ui.output_value.text = message


if __name__=="__main__":
	app = QtGui.QApplication(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



More information about the Python-list mailing list