[PyKDE] porting qtdemo example
phil at riverbankcomputing.co.uk
Mon Jan 16 10:08:03 GMT 2006
On Sunday 15 January 2006 12:24 am, Andreas Pakulat wrote:
> I'm currently porting the qtdemo example, so far the code has no or
> (hopefully) only little obvious errors. The whole drawing-stuff does not
> yet work but I have to work my way through the different classes to get
> that fixed.
That's great - thanks.
> However, there are some things I'd like to discuss here, as the version
> that is running now only shows the Qt4 examples (i.e. the C++ versions).
> qtdemo reads 2 xml files, one for the demos, one for the examples
> containing all important information (categories, example names,
> example directory name) and checks wether the examples can be found. The
> first question that arises here: Is there a way in PyQt4 to get the path
> were the examples lie around, other than using qtdemo's path and going
> up 2 directories? Phil are there any plans to "install" the examples,
> like into $PYTHONDIR/share/PyQt4/examples?
I think it's best if we keep everything relative to the qtdemo directory, then
it doesn't matter where they reside - so long as they are kept together.
Let's say there will be a "Examples and Demos" directory (specific name is
unimportant) containing the current examples directory, a possible future
demos directory and a qtdemo directory. You can assume that the qtdemo
directory will be current when qtdemo is executed (or there might be a sanity
check you can do and display an error message if this isn't the case).
Therefore the "location" of the foo/bar example will be ../examples/foo/bar.
> Next question is: Will the demos get ported? Until now I can only see
> work is done on the examples dir, but I think the demos are also GPL and
> can thus also be ported.
Assume they will be at some point.
> The next "problem" is documentation and images. The qtdemo shows the
> information from the Qt docs about the examples/demos including
> screenshots when they're available. As far as I can see PyQt4 doesn't
> provide any documentation and PyQt3 also didn't, so I guess I should
> just use the (hopefully already installed) Qt documentation?
There will be documentation - but you might as well go with the Qt docs for
> And the last thing is: Execution of the examples/demos. The C++ qtdemo
> just looks for a executable file in
> which of course doesn't work with PyQt4. One problem here is, that some
> examples do have their own directory, while others don't. I think the
> best way to approach this is to extend the existing xml files and add an
> executableScript and a hasDir-flag attribute. Any better ideas?
I've followed a very strict convention which will allow you to do the
following to find the main Python file. For an example "foo/bar"...
if ../examples/foo/bar.py exists
else if ../examples/foo/bar/bar.py exists
More information about the PyQt