Hi,
I have a subclassed PyQt class:
class Node(object):
def move(self, x,y): pass
class CRhomb(QCanvasP olygon, Node): pass
$ python
v2.4.1 CRhomb.mro()
[<class '__main__.CRhom b'>, <class 'qtcanvas.QCanv asPolygon'>, <class
'qtcanvas.QCanv asPolygonalItem '>, <class 'qtcanvas.QCanv asItem'>, <class
'qt.Qt'>, <type 'sip.wrapper'>, <class '__main__.Node' >, <type 'object'>]
a = CRhomb() a.move(1,2)
This executes also Node.move(a, 1,2)
Why?
Because even QCanvasItem.mov e delegates the call to the derived object? But
qt.Qt does not have a move() method... how does it get passed on to Node?
Thanks in advance,
Ciao
Uwe 3 1502
"Uwe Mayer" <me*****@hadiko .de> wrote in message
news:d9******** **@news2.rz.uni-karlsruhe.de... I have a subclassed PyQt class:
class Node(object): def move(self, x,y): pass
class CRhomb(QCanvasP olygon, Node): pass
$ python v2.4.1 CRhomb.mro() [<class '__main__.CRhom b'>, <class 'qtcanvas.QCanv asPolygon'>, <class 'qtcanvas.QCanv asPolygonalItem '>, <class 'qtcanvas.QCanv asItem'>, <class 'qt.Qt'>, <type 'sip.wrapper'>, <class '__main__.Node' >, <type 'object'>]
For those who don't know, 'mro' stands for 'method resolution order'. The
method returns a list of classes (all except the first are base or super
classes of the first) in the order in which their dictionaries are searched
for method (or other attribute) names.
a = CRhomb() a.move(1,2) This executes also Node.move(a, 1,2) Why?
In the absence of other information, I would presume that none of the other
classes have a move() method.
Because even QCanvasItem.mov e delegates the call to the derived object? But qt.Qt does not have a move() method... how does it get passed on to Node?
Are you sure that QCanvasItem has a move method? What results from print qtcanvas.QCanva sItem.move # ?
If so, I would need to see its code to try to answer.
Terry J. Reedy
Thursday 23 June 2005 19:22 pm Terry Reedy wrote:
[...] In the absence of other information, I would presume that none of the other classes have a move() method.
move() is implemented in the class qtcanvas.QCanva sItem
I checked the pyqt sources and it is linked via sip to the C++ object file.
In C++, QCanvasItem.mov e is delegated to QCanvasItem.mov eBy.
-- snip: C++ sources --
void QCanvasItem::mo ve( double x, double y ){
moveBy( x-myx, y-myy );
}
void QCanvasItem::mo veBy( double dx, double dy ){
if ( dx || dy ) {
removeFromChunk s();
myx += dx;
myy += dy;
addToChunks();
}
}
-- snip --
Are you sure that QCanvasItem has a move method? What results from print qtcanvas.QCanva sItem.move # ? If so, I would need to see its code to try to answer. import qtcanvas qtcanvas.QCanva sItem.move
<built-in function move>
Here is a working portion which recreates the strange output:
-- snip --
from qtcanvas import *
class Node(object):
def move(self, x,y):
print "Node: move(%d,%d)"%(x ,y)
class Rhomb(QCanvasPo lygon, Node):
def __init__(self, parent):
QCanvasPolygon. __init__(self, parent)
Node.__init__(s elf)
print Rhomb.mro()
r = Rhomb(None)
r.move(1,2)
-- snip --
This prints:
[<class '__main__.Rhomb '>, <class 'qtcanvas.QCanv asPolygon'>, <class
'qtcanvas.QCanv asPolygonalItem '>, <class 'qtcanvas.QCanv asItem'>, <class
'qt.Qt'>, <type 'sip.wrapper'>, <class '__main__.Node' >, <type 'object'>]
Node: move(1,2)
Ciao
Uwe
Uwe Mayer wrote: Thursday 23 June 2005 19:22 pm Terry Reedy wrote:
[...]
In the absence of other information, I would presume that none of the other classes have a move() method.
move() is implemented in the class qtcanvas.QCanva sItem I checked the pyqt sources and it is linked via sip to the C++ object file. In C++, QCanvasItem.mov e is delegated to QCanvasItem.mov eBy.
-- snip: C++ sources -- void QCanvasItem::mo ve( double x, double y ){ moveBy( x-myx, y-myy ); }
void QCanvasItem::mo veBy( double dx, double dy ){ if ( dx || dy ) { removeFromChunk s(); myx += dx; myy += dy; addToChunks(); } }
I wonder if it is to do with the signature of these methods. they
accept two doubles and perhaps the python bindings do not automatically
convert from integers, therefore these methods are not called and the
rules of mro kick in (thus calling the python move method)
-- snip --
Are you sure that QCanvasItem has a move method? What results from
>print qtcanvas.QCanva sItem.move # ?
If so, I would need to see its code to try to answer.
import qtcanvas qtcanvas.QC anvasItem.move
<built-in function move>
Here is a working portion which recreates the strange output:
-- snip -- from qtcanvas import *
class Node(object): def move(self, x,y): print "Node: move(%d,%d)"%(x ,y)
class Rhomb(QCanvasPo lygon, Node): def __init__(self, parent): QCanvasPolygon. __init__(self, parent) Node.__init__(s elf)
print Rhomb.mro() r = Rhomb(None) r.move(1,2) -- snip --
This prints:
[<class '__main__.Rhomb '>, <class 'qtcanvas.QCanv asPolygon'>, <class 'qtcanvas.QCanv asPolygonalItem '>, <class 'qtcanvas.QCanv asItem'>, <class 'qt.Qt'>, <type 'sip.wrapper'>, <class '__main__.Node' >, <type 'object'>] Node: move(1,2)
Ciao Uwe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
In the context of LATEX, some Pythonista asked what the big
successes of Lisp were. I think there were at least three *big*
successes.
a. orbitz.com web site uses Lisp for algorithms, etc.
b. Yahoo store was originally written in Lisp.
c. Emacs
The issues with these will probably come up, so I might as well
mention them myself (which...
|
by: Bart |
last post by:
Hi all
I don't understand globals between multiple modules in a python program. I
really don't. I've narrowed it down to the following two very simple
programs a.py and b.py. When I run a.py I get the following output:
inc: 2
A: 2
inc: 3
B: 3
|
by: Robert Nicholson |
last post by:
So I've got one page where I have an image inside a DIV with
text-align: center and the
image is correctly centered in that block. Making me think that
text-align will center the contents of a block.
Another page I have a series of thumbnails which are themselves a DIV
block wrapping both an image and a caption (float: left) inside a DIV...
|
by: Jace Benson |
last post by:
Ok I have read alot of things on zend.com, php.net and other sites went
to the wikibooks to try to understand how to use a class. I have this
project I want to do that I am sure would work great with a class. I
just don't grasp the whole concept, and how to do it.
I want to make a Collectable Card Game Draft Engine...(if any of you
play...
|
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= |
last post by:
Hello,
I have build a website with approximately 30 html-pages.
When I search this website in Google, I see the index.html or home.html on
this website, but also other html-pages on this website.
When I click in Google on one of these pages (not index.html or home.html),
I am only linked to that one html-page and not to the website itself....
| |
by: Jo |
last post by:
class A {
public:
char text_a;
A() { *text_a=0; }
~A() {}
};
//-----------------------------------------------------------------------------
|
by: jehugaleahsa |
last post by:
Hello:
I had an hour-long discussion with my boss today. Last night, right
before I dozed off, I realized some of his code resulted in duplicate
processing. I tried to explain it to him and he kept saying, "I'm
afraid to say it's 'OK' to change it because everything I did was for
a reason." Well, I know better.
My boss' old code is...
|
by: Ben Thomas |
last post by:
Hello,
I have the following code which I don't understand why it works :
#include <iostream>
using namespace std;
void DontWork (unsigned int& i) {
cout << i << endl;
}
|
by: Stef Mientki |
last post by:
Terry Reedy wrote:
sorry, don't know how this happened, as I always copy/paste ?
AFAIK locals() == sys._getframe(0).f_locals
AFAIK, again one level up
weird, I use it in 2.5 and if I remember well it already worked in 2.4.
but exchanging the function with the statement yields exactly the same
results
Yes ;-)
done.
|
by: Thierry |
last post by:
Hello fellow pythonists,
I'm a relatively new python developer, and I try to adjust my
understanding about "how things works" to python, but I have hit a
block, that I cannot understand.
I needed to output unicode datas back from a web service, and could
not get back unicode/multibyte text before applying an hack that I
don't understand...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |