I started learning PyQt from zetcode, as far as i know sys.argv reads in the parameter from coomandline and first being the name of file itself, so if sys.argv is a list then what being passed to QtGui.QApplication() in

def main():
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

Because this call invokes an underlying C++ function which uses argv and doesn't know about python. Qt understand a set of command line arguments, see here for example.

ok then what is in the sys.argv list ?

Here is an example program

#!/usr/bin/env python
# testargv.py

if __name__ == "__main__":
    import sys
    print(sys.argv)

"""my command line -->

testargv.py -foo bar --baz qux -o foobar.txt bazqux.pdf

my output -->

['./testargv.py', '-foo', 'bar', '--baz', 'qux', '-o', 'foobar.txt', 'bazqux.pdf']
"""

sys.argv is the list of command line arguments that were given to the program.

well i do understand that what would it be incase of app = QtGui.QApplication(sys.argv)

Try -style motif for example, or any of the arguments listed here

Let's give it a try:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)

# ----- start your widget test code ----


# create the label
label = QLabel()
label.show()
# insert a text string
label.setText('Hello fron DaniWeb!')
print(sys.argv)


# ---- end of widget test code -----

app.exec_()

''' my console output -->
['C:\\Python33\\BS\\pqt_sys_argv.py']
'''

QApplication() expects a list, but you can feed it an empty list if you don't want to putz around with sys.argv

from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication([])

# ----- start your widget test code ----


# create the label
label = QLabel()
label.show()
# insert a text string
label.setText('Hello fron DaniWeb!')


# ---- end of widget test code -----

app.exec_()
commented: good help +13

nice thanks, i am learning now, i think it would good if i buy book though.. however now another question strikes, i cant avoid asking back so here it goes, if QApplication() expects a list, and we can pass in [] empty list then why sys.argv is used in every tutorial of zetcode, like Gribouillis said why not pass the -style "motif"... ?

why not pass the -style "motif"... ?

I tried sneekula's code with -widgetcount and it worked as described in the doc. The best thing to do is to run your code with various arguments and see what it does.