[PyKDE] Some fundamentals
tomchance at gmx.net
Tue Feb 25 11:56:01 GMT 2003
Well thank you to all who replied - that's much clearer now. By the time I'm
finished with Python, I sweat I'm going to be half-way towards knowing C/C++
as well, as so many docs (even the O'Reilly books) seem to assume you're
coming from it, and explain everything in terms of it! Anyway, I understand that
all now, and I've worked out how to use it which is the important thing :)
There's one other thing that has puzzled me lately, and I can only assume
that it's either a misunderstanding or a bug on my part. I've got some code
which, on the push of a button, scans the DVD device, then populates the
ListView with items for each track. Currently, the code works like so:
print "Scanning DVD"
(popen command to get number of tracks)
for i in range(numtracks):
(popen command to get track info)
print (info about track)
Now I would expect that the ListViewItems would appear one by one as the for
loop scans each track. But what happens is that it prints out the info for
each track as it goes along, but only populates the ListView with the items
when it's done. Why is this?
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> On Tuesday 25 February 2003 01:13, Tom Chance wrote:
> > Hello,
> > I've only just started out with PyQt, so please bear with me as I ask
> > boring questions :)
> > I've been reading through the book "GUI Programming with Python: QT
> > Edition" by Boudewijn Rempt online (the paper copy is just too expensive
> > for a poorly student like me :-), and though it covers a lot of ground,
> > it's written in a very confusing order, jumping around between ideas.
> I guess it doesn't help that the online version misses all screenshots
> and the helpful titlepages between sections. Start with
> http://www.opendocs.org/pyqt/index.lxp?lxpwrap=c1036%2ehtm, that shows
> how to write a simple script to start with.
> > Anyway, enough rambling. I'm using Qt Designer to create my GUI, and I'm
> > then importing the class in my main program file. At the moment, the
> > program file contains one class that inherits the GUI class, and that
> > contains all my functions. I'm sure this isn't the best way to do things
> > I'm used to creating multiple classes, each one for a different task,
> > it seems a little messy having all my function code in one class. What's
> > the best way of laying out the code?
> Doesn't matter much. You don't even need to inherit the gui class; there
> are cases where simple instantiation is enough, if you connect the signals
> >from the gui class widgets to slots in your own code.
> > Also, I'm struggling with connecting signals and slots. I understand the
> > principle, and I'm getting the hang of working wiht Qt Designer and my
> > to create empty functions in Designer, and then create the actual
> > in my main code, but I don't really understand the signal parameter in a
> > connection.
> > E.g. I can guess what "pressed(QListViewItem*)" means? But why the
> > QListViewItem with an asterisk? And what really confuses me is the "int,
> > const Qstring&" stuff. What do they signify, and why are they in the
> > for a rightButtonClicked(), whilst clicked() has no parameters, and
> > only has QListViewItem?
> The signal parameter from C++ signals is a simple name. In C++, the
> define the kind of data passed to the slot; but in Python it's simply used
> distinguish between signals with the same name but different parameter
> The funny things, like int, & and * are simply copied from C++, where they
> denote the type of parameter. They're present in the Python bindings
> it makes it easier to use the Qt C++ docs.
> > Back to the docs for now!
> You might also want to take a look at the tutorial I wrote for Dr Dobbs
> (January 2001 issue), which covers the first steps and principles, but in
> a lot less detail than the book.
> - --
> Boudewijn Rempt | http://www.valdyas.org/index2.html
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> -----END PGP SIGNATURE-----
> PyKDE mailing list PyKDE at mats.gmd.de
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!
More information about the PyQt