Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Qt, multiple inheritance: QApplication and new-style class not possible

Reply
Thread Tools

Qt, multiple inheritance: QApplication and new-style class not possible

 
 
Sibylle Koczian
Guest
Posts: n/a
 
      05-12-2004
I want to try out several applications, all doing the same thing but
using different GUI libraries (Tkinter, Qt, wxWindows). Using an example
I found in a book I wrote a class containing the GUI independent methods
of the application, let's call it MyAppClass. The book is written before
Python 2.2, so it uses classic classes, but I want some properties, so I
made MyAppClass a new style class.

For the Tkinter GUI I derive another class, TkAppClass, from this, whose
methods use Tkinter. As Qt applications need an application class
derived from QApplication, I wanted to derive my QAppClass from both
classes, QApplication and MyAppClass, but got a TypeError: "cannot
create a class derived from a SIP generated class (QApplication) and a
new-style class - use SIP v4 or later instead".

Now I see three different ways out of this:

a) use SIP v4, but it's pre-release. Moreover I'm just starting with
Linux anyway, so I'd like to keep to ready-made rpm packages for my
distribution (SuSE 9.1) and I can't find any.

b) make MyAppClass a classic class.

c) instead of deriving my QAppClass from QApplication and from
MyAppClass, derive it only from QApplication and put a reference to a
MyAppClass instance into it as an attribute.

What's the best way (and why), or is there a d)?

Thank you,
Koczian

--
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : http://www.velocityreviews.com/forums/(E-Mail Removed)-Augsburg.DE

 
Reply With Quote
 
 
 
 
John J. Lee
Guest
Posts: n/a
 
      05-12-2004
Sibylle Koczian <(E-Mail Removed)-Augsburg.de> writes:
[...]
> a) use SIP v4, but it's pre-release. Moreover I'm just starting with

[...]

I'd say the acceptability of this depends on what kinds of people the
program needs to be distributed to -- yourself being a special case of
distributee If I know I'll never distribute something, or won't
for, say, a year or so, I feel few qualms about using new code.
Depends what people have said about the stability of the code, of
course, but I'd be surprised if Phil Thompson's pre-release code was
bug-ridden.


> Linux anyway, so I'd like to keep to ready-made rpm packages for my
> distribution (SuSE 9.1) and I can't find any.


If you want to get into good habits, you could make your own rpm by
copying the spec files from old sip / PyQt packages -- it's not too
hard, I'm told.

Personally, I have slovenly habits and just compile from the original
tarball when it's not on a distro CD or automatically fetch-able with
dependencies (using apt-get, in my case).


> b) make MyAppClass a classic class.


A shame to lose properties, assuming you have a good use for them.


> c) instead of deriving my QAppClass from QApplication and from
> MyAppClass, derive it only from QApplication and put a reference to a
> MyAppClass instance into it as an attribute.
>
> What's the best way (and why),


c).


> or is there a d)?


Surely.


John
 
Reply With Quote
 
 
 
 
Phil Thompson
Guest
Posts: n/a
 
      05-12-2004
On Wednesday 12 May 2004 12:01 pm, Sibylle Koczian wrote:
> I want to try out several applications, all doing the same thing but
> using different GUI libraries (Tkinter, Qt, wxWindows). Using an example
> I found in a book I wrote a class containing the GUI independent methods
> of the application, let's call it MyAppClass. The book is written before
> Python 2.2, so it uses classic classes, but I want some properties, so I
> made MyAppClass a new style class.
>
> For the Tkinter GUI I derive another class, TkAppClass, from this, whose
> methods use Tkinter. As Qt applications need an application class
> derived from QApplication, I wanted to derive my QAppClass from both
> classes, QApplication and MyAppClass, but got a TypeError: "cannot
> create a class derived from a SIP generated class (QApplication) and a
> new-style class - use SIP v4 or later instead".
>
> Now I see three different ways out of this:
>
> a) use SIP v4, but it's pre-release. Moreover I'm just starting with
> Linux anyway, so I'd like to keep to ready-made rpm packages for my
> distribution (SuSE 9.1) and I can't find any.
>
> b) make MyAppClass a classic class.
>
> c) instead of deriving my QAppClass from QApplication and from
> MyAppClass, derive it only from QApplication and put a reference to a
> MyAppClass instance into it as an attribute.
>
> What's the best way (and why), or is there a d)?


I'd recommend a). The only reason SIP v4 is still a pre-release is that I said
that I'd only release the final version when the documentation was complete.
The code itself is stable with no known outstanding issues.

Phil

 
Reply With Quote
 
Sibylle Koczian
Guest
Posts: n/a
 
      05-13-2004
Phil Thompson schrieb:

>>Now I see three different ways out of this:
>>
>>a) use SIP v4, but it's pre-release. Moreover I'm just starting with
>>Linux anyway, so I'd like to keep to ready-made rpm packages for my
>>distribution (SuSE 9.1) and I can't find any.
>>

> I'd recommend a). The only reason SIP v4 is still a pre-release is that I said
> that I'd only release the final version when the documentation was complete.
> The code itself is stable with no known outstanding issues.
>

In that case I think I'll try it, thank you!

--
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : (E-Mail Removed)-Augsburg.DE

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
QPaintDevice: Must construct a QApplication before a QPaintDevice boris.smirnov@gmail.com Python 15 02-28-2007 09:58 AM
is it possible to dividing up a class in multiple files? =?ISO-8859-15?Q?Martin_H=F6fling?= Python 11 08-08-2006 08:45 PM
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM



Advertisments