473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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_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
Oct 6 '08 #1
0 815

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: simo | last post by:
OK, so I'm at the stage where I want to make a choice between wxPython and PyQt. Currently I'm using wxPython mainly due to the fact that it has GPL Linux and Windows versions. I prefer Qt to...
2
by: Florian Lindner | last post by:
Hello, I've this tiny Python sample: - - - - #!/usr/bin/python from optparse import OptionParser, OptionValueError def option_callback(option, opt, value, parser, *args, **kwargs): pass
2
by: Дамјан Георгиевски | last post by:
Hi, I'm making a small PyQT app, and it will also have a config file (any type is ok) for several options. I would also like to add a gui for changing the config options but I don't want to...
5
by: hue | last post by:
I am trying to parse command line options using getopt module. I have written the following Code import string import getopt def usage(): print '''haarp_make.py -- uses getopt to...
18
by: Jeff Rodriguez | last post by:
If main is prototyped as: int main(int argc, char *argv); You will end up with a bunch of arguments in *argv, and the number in argc. Now what I want to do is emulate that same action on a...
3
by: Steven W. Orr | last post by:
I decided I could be more articulate. I hope this helps. I'm writing a program that needs to process options. Due to the nature of the program with its large number of commandline options, I...
3
by: Rocky Zhou | last post by:
I wonder is there any way to make the wrapper program can wrap options && arguments for the the subprocess/command the wrapper will execute? by getopt or optparse module? This is something...
1
by: jakebbohio | last post by:
I have a user-defined XPath function implemented using a custom context and the IXsltContextFunction interface. For its arguments, it accepts 3: { XPathResultType.Any, XPathResultType.Any,...
1
by: hellt | last post by:
today i've decided to use optionparser instead of GetOpt and unfortunately i've got an error which i cant handle my pice of code: from optparse import OptionParser def main(): usage =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.