Re: [PyQt] Get platform?

2011-02-16 Thread Philippe Crave
maybe something from the platform module ?
http://docs.python.org/library/platform.html

platform.system()
Returns the system/OS name, e.g. 'Linux', 'Windows', or 'Java'. An
empty string is returned if the value cannot be determined.


2011/2/16 Hans-Peter Jansen h...@urpla.net

 On Tuesday 15 February 2011, 17:57:01 mw wrote:
  import os
  os.name
 
  http://docs.python.org/library/os.html
 
  On Tue, Feb 15, 2011 at 8:51 AM, todd rme toddrme2...@gmail.com
 wrote:
   Is there any way inside pyqt, or in python, to determine what
   platform you are using?  Specifically, I want to know if the widget
   is done in x11.  I don't think I can check for x11 environment
   variables since I at least think mac can have x11 installed without
   using it for Qt.  I need to know if the actual pyqt4 window is
   using X11.

 Just try to instantiate e.g. QtGui.QX11Info(), it will throw an
 NameError exception, if this platform isn't X11 aware. This call will
 succeed even if X isn't running, btw. You might check that with
 QtGui.QX11Info.appRootWindow().

 This procedure will fail, it somebody builds PyQt with a X11 disabled
 Qt, but that's pretty unlikely..

 Pete
 ___
 PyQt mailing list    PyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGrahics / textItemSize

2011-02-09 Thread Philippe Crave
thank you !!
it works well now.

2011/2/9 KONTRA, Gergely pihent...@gmail.com

 Maybe because you set the font size in POINTs.

 See:
 http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#QFont-2

 and also


 http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#setPixelSize
 +-[ Gergely Kontra pihent...@gmail.com ]--+
 |   |
 | Mobile:(+36 20)356 9656   |
 |   |
 +- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



 On Sun, Feb 6, 2011 at 16:54, Philippe Crave philippe.cr...@gmail.com
 wrote:
  Thanks for testing !
 
  I attach a new code with Arial (maybe you're under windows) and a new
 png.
  this time, I also draw a rectangle. 200x40px, red.
 
  you can check that the scene produced my the pyqt code gives a rectangle
  like the one in the png. I did it in inkscape. a 200x40px red rect.
 
  but for the font, hello 1 is too big. hello 2 seems to be of similar
  size. but it was scale.
  I attach the .svg too.
  in the svg (and the png), i wrote hello in arial/40
 
  why should I scale the text (with a ratio of .75) to get a correct size ?
 
  2011/2/6 KONTRA, Gergely pihent...@gmail.com
 
  For me the 2 texts are sized equal if I remove the line, which scales
 the
  text.
 
  But I guess I do not have the font Norasi (rendered as some
  sans-serirf font on my PC).
 
  Gergo
  +-[ Gergely Kontra pihent...@gmail.com ]--+
  |   |
  | Mobile:(+36 20)356 9656   |
  |   |
  +- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
 
 
 
  On Sat, Feb 5, 2011 at 11:14, Philippe Crave philippe.cr...@gmail.com
  wrote:
   Hello,
  
   When I add to the Scene some rectangles and texts, rectangles are
   perfect,
   but text are too big.
  
   If I add a QGraphicsSimpleTextItem with a font_size of 40, it will
   display
   bigger than the same text/font/size if I draw it in inkscape (or
   anywhere
   else).
   Seems that I have to scale with a ratio of 0.75 to get a correct size.
  
   What am I doing wrong ?
  
   here is my sample (I also attach a png with a text in Norasi with a
 size
   of
   40):
  
   from PyQt4 import QtGui
  
   import sys
  
   app = QtGui.QApplication(sys.argv)
  
   scene = QtGui.QGraphicsScene(0, 0, 400, 400)
  
   scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
  
   t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
  
   t.setY(100)
  
   t.scale(.75, .75)
  
   view = QtGui.QGraphicsView(scene)
  
   view.setRenderHint(QtGui.QPainter.Antialiasing)
  
  
  
 view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
  
   view.show()
  
   sys.exit(app.exec_())
  
  
  
   ___
   PyQt mailing listPyQt@riverbankcomputing.com
   http://www.riverbankcomputing.com/mailman/listinfo/pyqt
  
 
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGrahics / textItemSize

2011-02-08 Thread Philippe Crave
sorry to bring this up again.
but I still haven't found what was wrong.

If I draw a rectangle and a text on a QGraphicsScene, and do the same in
inkscape, the rectangles will have same size (like 200x40px) but the text
will be different. the text on the QGraphics will be bigger that the text in
inkscape.

is it a bug ?
I think that I am doing something wrong, but do not find what.

thanks for your help.

2011/2/6 Philippe Crave philippe.cr...@gmail.com

 Thanks for testing !

 I attach a new code with Arial (maybe you're under windows) and a new png.
 this time, I also draw a rectangle. 200x40px, red.

 you can check that the scene produced my the pyqt code gives a rectangle
 like the one in the png. I did it in inkscape. a 200x40px red rect.

 but for the font, hello 1 is too big. hello 2 seems to be of similar
 size. but it was scale.
 I attach the .svg too.
 in the svg (and the png), i wrote hello in arial/40

 why should I scale the text (with a ratio of .75) to get a correct size ?

 2011/2/6 KONTRA, Gergely pihent...@gmail.com

 For me the 2 texts are sized equal if I remove the line, which scales the
 text.

 But I guess I do not have the font Norasi (rendered as some
 sans-serirf font on my PC).

 Gergo
 +-[ Gergely Kontra pihent...@gmail.com ]--+
 |   |
 | Mobile:(+36 20)356 9656   |
 |   |
 +- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



 On Sat, Feb 5, 2011 at 11:14, Philippe Crave philippe.cr...@gmail.com
 wrote:
  Hello,
 
  When I add to the Scene some rectangles and texts, rectangles are
 perfect,
  but text are too big.
 
  If I add a QGraphicsSimpleTextItem with a font_size of 40, it will
 display
  bigger than the same text/font/size if I draw it in inkscape (or
 anywhere
  else).
  Seems that I have to scale with a ratio of 0.75 to get a correct size.
 
  What am I doing wrong ?
 
  here is my sample (I also attach a png with a text in Norasi with a size
 of
  40):
 
  from PyQt4 import QtGui
 
  import sys
 
  app = QtGui.QApplication(sys.argv)
 
  scene = QtGui.QGraphicsScene(0, 0, 400, 400)
 
  scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
 
  t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
 
  t.setY(100)
 
  t.scale(.75, .75)
 
  view = QtGui.QGraphicsView(scene)
 
  view.setRenderHint(QtGui.QPainter.Antialiasing)
 
 
 view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
 
  view.show()
 
  sys.exit(app.exec_())
 
 
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGrahics / textItemSize

2011-02-06 Thread Philippe Crave
Thanks for testing !

I attach a new code with Arial (maybe you're under windows) and a new png.
this time, I also draw a rectangle. 200x40px, red.

you can check that the scene produced my the pyqt code gives a rectangle
like the one in the png. I did it in inkscape. a 200x40px red rect.

but for the font, hello 1 is too big. hello 2 seems to be of similar
size. but it was scale.
I attach the .svg too.
in the svg (and the png), i wrote hello in arial/40

why should I scale the text (with a ratio of .75) to get a correct size ?

2011/2/6 KONTRA, Gergely pihent...@gmail.com

 For me the 2 texts are sized equal if I remove the line, which scales the
 text.

 But I guess I do not have the font Norasi (rendered as some
 sans-serirf font on my PC).

 Gergo
 +-[ Gergely Kontra pihent...@gmail.com ]--+
 |   |
 | Mobile:(+36 20)356 9656   |
 |   |
 +- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



 On Sat, Feb 5, 2011 at 11:14, Philippe Crave philippe.cr...@gmail.com
 wrote:
  Hello,
 
  When I add to the Scene some rectangles and texts, rectangles are
 perfect,
  but text are too big.
 
  If I add a QGraphicsSimpleTextItem with a font_size of 40, it will
 display
  bigger than the same text/font/size if I draw it in inkscape (or anywhere
  else).
  Seems that I have to scale with a ratio of 0.75 to get a correct size.
 
  What am I doing wrong ?
 
  here is my sample (I also attach a png with a text in Norasi with a size
 of
  40):
 
  from PyQt4 import QtGui
 
  import sys
 
  app = QtGui.QApplication(sys.argv)
 
  scene = QtGui.QGraphicsScene(0, 0, 400, 400)
 
  scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
 
  t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
 
  t.setY(100)
 
  t.scale(.75, .75)
 
  view = QtGui.QGraphicsView(scene)
 
  view.setRenderHint(QtGui.QPainter.Antialiasing)
 
 
 view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
 
  view.show()
 
  sys.exit(app.exec_())
 
 
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 



test.py
Description: Binary data
attachment: rect2820.pngattachment: test_font_size.svg___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QGrahics / textItemSize

2011-02-05 Thread Philippe Crave
Hello,

When I add to the Scene some rectangles and texts, rectangles are perfect,
but text are too big.

If I add a QGraphicsSimpleTextItem with a font_size of 40, it will display
bigger than the same text/font/size if I draw it in inkscape (or anywhere
else).
Seems that I have to scale with a ratio of 0.75 to get a correct size.

What am I doing wrong ?

here is my sample (I also attach a png with a text in Norasi with a size of
40):

 from PyQt4 import QtGui

import sys

app = QtGui.QApplication(sys.argv)

scene = QtGui.QGraphicsScene(0, 0, 400, 400)

scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))

t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))

t.setY(100)

t.scale(.75, .75)

view = QtGui.QGraphicsView(scene)

view.setRenderHint(QtGui.QPainter.Antialiasing)

view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)

view.show()

sys.exit(app.exec_())
attachment: text2985.png#!/usr/bin/env python

from PyQt4 import QtGui

import sys

app = QtGui.QApplication(sys.argv)

scene = QtGui.QGraphicsScene(0, 0, 400, 400)
scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
t.setY(100)
t.scale(.75, .75)

view = QtGui.QGraphicsView(scene)
view.setRenderHint(QtGui.QPainter.Antialiasing)
view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
view.show()

sys.exit(app.exec_())
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] how to make a simple client/server app using TCP to communicate ?

2010-09-04 Thread Philippe Crave
an overview here:
http://doc.qt.nokia.com/4.6/network-programming.html
or here
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtnetwork.html

and in the source:
http://www.riverbankcomputing.co.uk/software/pyqt/download
you can find an /examples/network/ folder with some nice scripts.

hope it helps.


2010/9/4 Strato p...@p0w.org:
 Hi there,

 I am searching how I can build a simple client/server application, that use
 a TCP port to communicate.

 I've searched in the PyQt API but I wasn't able to see some kind of class
 that permits me to make my application to bind to a TCP port, waiting for
 incoming messages.

 My goal is only to send some simple, plain-text messages, no XML or HTTP or
 HTML or particular protocol is required for this to work.

 I've seen some methods that permits to send some stuff in HTTP but nothing
 that is to receive HTTP requests.

 I suppose I missed something, so can anybody points me in the right
 direction ?

 Thanks,

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] old binaries

2010-09-01 Thread Philippe Crave
Hi,

Where can I find old Binary Packages for windows ?
I would like to keep the same version that I have in my Linux distribution.
Actually, the one proposed for windows on
http://www.riverbankcomputing.co.uk/software/pyqt/download is more
recent.

thanks,

Philippe
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4 does not recognize the *shape* of QGraphicsItems for collision detection

2010-08-14 Thread Philippe Crave
not sure, but maybe you should set this flag: ItemClipsToShape

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qgraphicsitem.html#GraphicsItemFlag-enum


2010/8/14 Konrad Koller koko9...@googlemail.com

 In many games collision detection is important. In my case the game's stones 
 are mostly convex polygons.
 Therefore their bounding rectangle is not adequate for collision detection 
 and therefore I create them
 in the constructor of the class Stone(QGraphicsItem) as QPainterPaths like so:

 self.path=QPainterPath()
 self.path.addPolygon(polygon)
 self.path.closeSubpath()

 Then their shape is simple:

 def shape(self): return self.path

 Their boundingRect (used elsewhere) is:

 def boundingRect(self): return self.path.boundingRect()

 For collision detection with already placed stones I write:

 for item in self.collidingItems(Qt.IntersectsItemShape):
     if isinstance(item,Stone): print Collision!

 To my surprise the detection does not recognize the shape but obviously the 
 boundingRect.
 For example:
 _
 |__    |
   ___    |   |___
  |     |    |_|
  | |
  | |_
  ||

 This reports a collision. Why?

  Thanks for any hint. Konrad


 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] how to launch a pyqt app from another pyqt app

2010-07-18 Thread Philippe Crave
Thanks, almost done!
I use: subprocess.Popen(python pyro_launcher.py)

it launch correctly my pyqt app that embed a Pyro server.
I have 2 pyqt app. that's good, but when I quit the first one, it
kills also pyro_launcher.py.
I would like the pyro_launcher.py to still be alive.

any idea ?


2010/7/18 Jonathan Noble jonnobl...@gmail.com

 The subprocess module?

 On 17 July 2010 19:58, Philippe Crave philippe.cr...@gmail.com wrote:

 Hi,

 I have two pyqt application app1 and app2.
 I am trying to launch app2 from app1.
 I do not want any parent/child relation.
 Both apps could be QMainWindow.

 The idea is that I do not want to start app2 whenvere I start app1.
 app2 is a server. app1 checks if the server is live, and launch it if 
 necessary.

 thanks for your help,
 Philippe

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] how to launch a pyqt app from another pyqt app

2010-07-18 Thread Philippe Crave
solved using pythonw instead of python


2010/7/18 Philippe Crave philippe.cr...@gmail.com:
 Thanks, almost done!
 I use: subprocess.Popen(python pyro_launcher.py)

 it launch correctly my pyqt app that embed a Pyro server.
 I have 2 pyqt app. that's good, but when I quit the first one, it
 kills also pyro_launcher.py.
 I would like the pyro_launcher.py to still be alive.

 any idea ?


 2010/7/18 Jonathan Noble jonnobl...@gmail.com

 The subprocess module?

 On 17 July 2010 19:58, Philippe Crave philippe.cr...@gmail.com wrote:

 Hi,

 I have two pyqt application app1 and app2.
 I am trying to launch app2 from app1.
 I do not want any parent/child relation.
 Both apps could be QMainWindow.

 The idea is that I do not want to start app2 whenvere I start app1.
 app2 is a server. app1 checks if the server is live, and launch it if 
 necessary.

 thanks for your help,
 Philippe

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] how to launch a pyqt app from another pyqt app

2010-07-17 Thread Philippe Crave
Hi,

I have two pyqt application app1 and app2.
I am trying to launch app2 from app1.
I do not want any parent/child relation.
Both apps could be QMainWindow.

The idea is that I do not want to start app2 whenvere I start app1.
app2 is a server. app1 checks if the server is live, and launch it if
necessary.

thanks for your help,
Philippe
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Signals with QGraphicsPixmapItem

2010-06-12 Thread Philippe Crave
you should inherit qgraphicsobject
http://doc.qt.nokia.com/4.6/qgraphicsobject.html

2010/6/11 dizou di_...@yahoo.com:

 I am using QGraphicsPixmapItems in a QGraphicsScene. How can I get the
 QGraphicsPixmapItems to emit a signal since they don't inherit QObject?
 There is no multiple inheritance support either.
 --
 View this message in context: 
 http://old.nabble.com/Signals-with-QGraphicsPixmapItem-tp28859505p28859505.html
 Sent from the PyQt mailing list archive at Nabble.com.

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Signals with QGraphicsPixmapItem

2010-06-12 Thread Philippe Crave
you can then overload the paint()

class BasePage(QGraphicsObject):

def __init__(self, parent):
super(BasePage, self).__init__(parent)
self.pic = QGraphicsPixmapItem(QPixmap(path_to_your_pic), self)

def paint(self, painter, option, widget=None):
painter.drawPixmap(QPointF(0, 0), self.pic)


2010/6/12 dizou di_...@yahoo.com:


 I want the setPixmap functionality though.


 Philippe Crave wrote:

 you should inherit qgraphicsobject
 http://doc.qt.nokia.com/4.6/qgraphicsobject.html




 --
 View this message in context: 
 http://old.nabble.com/Signals-with-QGraphicsPixmapItem-tp28859505p28865807.html
 Sent from the PyQt mailing list archive at Nabble.com.

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] network-chat sample

2010-06-05 Thread Philippe Crave
thanks, I will check that.

What I am looking for, is a way to get several applications (made with
pyqt) exchanging data. they will be on different PCs, on a local
network.
and there will be 2 or 3 applications on each PC.

I would like that each application send its data, when ready, to all
the others (other application on the same PC, and other applications
on the other PCs).

so far, the best I could find is that each application should send a
socket to all the others, one by one.
I did not find a way to broadcast. If someone know how to do it, that will help.
and then, each application runs a threaded QTcpServer.

then, I am looking for a way for the applications to find the others
on the network (ie, find the adress/port)
that's why I try to understand the chat sample.


2010/6/5 Gustavo A. Díaz gustavo.d...@gmail.com:
 Ehmmm... now that I see better is another example, but maybe you could have
 some code as example.

 2010/6/5 Gustavo A. Díaz gustavo.d...@gmail.com

 I used it for my application with some improvements. Read it in these
 classes:


 http://opencoffee.lnxteam.org/trac/browser/trunk/opencoffee-server/core/workstations/workstations.py#L503

 http://opencoffee.lnxteam.org/trac/browser/trunk/opencoffee-client/core/chat/chatClient.py

 Cheers.


 2010/6/5 Philippe Crave philippe.cr...@gmail.com

 Hello,

 is there somewhere the network-chat example in python ?
 http://doc.qt.nokia.com/4.6/network-network-chat.html

 thank you,

 philippe
 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



 --
 Gustavo A. Díaz
 GDNet Projects
 www.gdnet.com.ar



 --
 Gustavo A. Díaz
 GDNet Projects
 www.gdnet.com.ar

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Model/View programming

2010-05-06 Thread Philippe Crave
Hello,

I am reading the chapter 14 of Mark Summerfield.
I work with custom model and custom delegate.

in the sample from the book, we have 1 tableView linked to one model.
It's simple to get 2 tableView linked to the same model.

my Model has got 4 columns.
I would like that TableView_1 show the 2 first column only, and
TableView_2 show the 2 others.

what is the good way to do it ?
actually, the content of the model will be given to the view in the
data(self, index, role=Qt.DisplayRole) method from the custom model.
is there a way to know which view needs data in that data method ?

thanks,

Philippe
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Model/View programming

2010-05-06 Thread Philippe Crave
looks like that I have to do a QAbstractTableModel for each QTableView, no ?
sounds strange, I thought that the idea was to have only one model
that will serve data to several views.

2010/5/6 Philippe Crave philippe.cr...@gmail.com:
 Hello,

 I am reading the chapter 14 of Mark Summerfield.
 I work with custom model and custom delegate.

 in the sample from the book, we have 1 tableView linked to one model.
 It's simple to get 2 tableView linked to the same model.

 my Model has got 4 columns.
 I would like that TableView_1 show the 2 first column only, and
 TableView_2 show the 2 others.

 what is the good way to do it ?
 actually, the content of the model will be given to the view in the
 data(self, index, role=Qt.DisplayRole) method from the custom model.
 is there a way to know which view needs data in that data method ?

 thanks,

 Philippe

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Model/View programming

2010-05-06 Thread Philippe Crave
actually, I just want to loop over the rows.
I do not find a max_row, or an iterator over the rows of a Table.

2010/5/6 Philippe Crave philippe.cr...@gmail.com:
 thank you, both of you !
 I will check the filtering solution.
 I am now implementing the setColumnHidden. just have to customize a
 QTableView class. seems simple.

 by the way, do you know how to get the total number of row in a table ?
 i must be blind, but I could not find it.

 2010/5/6 Christian Brugger brugger@googlemail.com:
 Just to outline my idea a bit more:
 Yeah one model class and one view class. But with different filters between
 model and views. You wouldn't just attach your 2 views to your model, but
 rather would attach each view to an individual filter (could be two objects
 of the same custom filter class) and then would attach both filters to your
 model. Such a custom filter could be created as described in the docs:
 http://doc.trolltech.com/4.6/model-view-proxy-models.html#custom-filtering-models
 But as far as I see, Benjamin has found a much simpler solution, if you only
 want so hide columns. I would test his suggestion first and check if it fits
 your needs.
 Christian

 On Thu, May 6, 2010 at 5:15 PM, Philippe Crave philippe.cr...@gmail.com
 wrote:

 looks like that I have to do a QAbstractTableModel for each QTableView, no
 ?
 sounds strange, I thought that the idea was to have only one model
 that will serve data to several views.

 2010/5/6 Philippe Crave philippe.cr...@gmail.com:
  Hello,
 
  I am reading the chapter 14 of Mark Summerfield.
  I work with custom model and custom delegate.
 
  in the sample from the book, we have 1 tableView linked to one model.
  It's simple to get 2 tableView linked to the same model.
 
  my Model has got 4 columns.
  I would like that TableView_1 show the 2 first column only, and
  TableView_2 show the 2 others.
 
  what is the good way to do it ?
  actually, the content of the model will be given to the view in the
  data(self, index, role=Qt.DisplayRole) method from the custom model.
  is there a way to know which view needs data in that data method ?
 
  thanks,
 
  Philippe
 
 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Model/View programming

2010-05-06 Thread Philippe Crave
Yes, I use that in the model also.
but now, I need to iterate over the row, in the tableView. I want to
hide row when the data is an empty string.
I found that I can get the string with self.currentIndex().data().toString()
so, I suppose that I have to find a way to modify the currentIndex


2010/5/6 Scott Frankel fran...@circlesfx.com:

 On May 6, 2010, at 9:46 AM, Philippe Crave wrote:

 actually, I just want to loop over the rows.
 I do not find a max_row, or an iterator over the rows of a Table.

 Take a look at your model's rowCount() and record() methods.  I think you'll
 want to be iterating over the records in your model, not the tableview
 itself.

 Scott


 2010/5/6 Philippe Crave philippe.cr...@gmail.com:

 thank you, both of you !
 I will check the filtering solution.
 I am now implementing the setColumnHidden. just have to customize a
 QTableView class. seems simple.

 by the way, do you know how to get the total number of row in a table ?
 i must be blind, but I could not find it.

 2010/5/6 Christian Brugger brugger@googlemail.com:

 Just to outline my idea a bit more:
 Yeah one model class and one view class. But with different filters
 between
 model and views. You wouldn't just attach your 2 views to your model,
 but
 rather would attach each view to an individual filter (could be two
 objects
 of the same custom filter class) and then would attach both filters to
 your
 model. Such a custom filter could be created as described in the docs:

 http://doc.trolltech.com/4.6/model-view-proxy-models.html#custom-filtering-models
 But as far as I see, Benjamin has found a much simpler solution, if you
 only
 want so hide columns. I would test his suggestion first and check if it
 fits
 your needs.
 Christian

 On Thu, May 6, 2010 at 5:15 PM, Philippe Crave
 philippe.cr...@gmail.com
 wrote:

 looks like that I have to do a QAbstractTableModel for each QTableView,
 no
 ?
 sounds strange, I thought that the idea was to have only one model
 that will serve data to several views.

 2010/5/6 Philippe Crave philippe.cr...@gmail.com:

 Hello,

 I am reading the chapter 14 of Mark Summerfield.
 I work with custom model and custom delegate.

 in the sample from the book, we have 1 tableView linked to one model.
 It's simple to get 2 tableView linked to the same model.

 my Model has got 4 columns.
 I would like that TableView_1 show the 2 first column only, and
 TableView_2 show the 2 others.

 what is the good way to do it ?
 actually, the content of the model will be given to the view in the
 data(self, index, role=Qt.DisplayRole) method from the custom model.
 is there a way to know which view needs data in that data method ?

 thanks,

 Philippe

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] scene and layers

2010-04-30 Thread Philippe Crave
http://doc.qt.nokia.com/4.6/graphicsview.html
was not bad to start to learn it.

I also recomand the 12th chapter of
http://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/product-description/0132354187
samples are here
http://www.qtrac.eu/pyqtbook.html


2010/4/30 Jan Ekholm jan.ekh...@smultron.net

 On Friday 30 April 2010, Christopher M. Nahler wrote:
  I have found that there is some layers support with a graphics scene. I
  just have not been able to figure out how it works.
 
  As far as I understand there is at least a background, standard layerand
  a foreground (drawn in this order).
 
  But how do I assign items to a layer?
 
  Or are all added items in the standard layer and I have to draw directly
  on the fore- and backgroundlayers?

 The foregound and background aren't really layers where you can put items.
 They allow you to draw a custom background and something extra in the
 foreground on top of everything else.

 I'd look at the z property of items to create virtual layers.

 --
 Jan Ekholm
 jan.ekh...@smultron.net
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] RE : Re: DLL Problem with PyQt-Py3.1-gpl-4.7.3-1.exe

2010-04-20 Thread Philippe Crave
I was using python 2.6.2. In 2.6.5 no more problems.

Le 20 avr. 2010, 10:12 AM, Phil Thompson p...@riverbankcomputing.com a
écrit :

On Mon, 19 Apr 2010 22:34:09 -0700, Scott Ballard sc...@scottballard.net
wrote:

 Phil,   I investigated the DLL problem and found the following. Still
not sure  what is causi...
  C:Usersscottset path=C:Python26Libsite-packagesPyQt4bin;C:Python26
  C:Usersscottpython

 Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit 
(Intel)] on win32  Type ...
  C:Usersscottset PATH=C:Python26Libsite-packagesPyQt4bin;C:Python26
  C:Usersscottpython

 Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit 
(Intel)] on win32  Type ...
  � File , line 1, in

 ImportError: DLL load failed: The specified procedure could not be found.
 
Based on Glenn's feedback, can you try with Python v2.6.5?

Phil ___ PyQt mailing list
p...@riverbankcomputing.c...
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] DLL Problem with PyQt-Py3.1-gpl-4.7.3-1.exe

2010-04-19 Thread Philippe Crave
I have same problem as Michael with the latest pyqt on 2 configurations:
python 26 / XP
python 26 / Vista

in the path (1rst position), I have C:\Python26\Lib\site-packages\PyQt4\bin also
I get the DLL Load Failed: The specified procedure could not be found.

is there a way to download older pyqt binary ? I did not find any on
the site. older one worked well.

thanks
Philippe


2010/4/20 Scott Ballard sc...@scottballard.net

 Phil,

 I investigated the DLL problem and found the following. Still not sure what 
 is causing it though. I tested 2 different PyQt installers under Windows 7 
 64-bit, uninstalling each before testing the other. I made a clean PATH env 
 var to just PyQt and Python.

 -- PyQt-Py2.6-gpl-4.7-1.exe  - Works fine

 From a command prompt:
 C:\Users\scottset path=C:\Python26\Lib\site-packages\PyQt4\bin;C:\Python26
 C:\Users\scottpython
 Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] 
 on win32
 Type help, copyright, credits or license for more information.
  from PyQt4 import QtCore
 

 -- PyQt-Py2.6-gpl-4.7.3-1.exe - Errors out

 From a command prompt:
 C:\Users\scottset PATH=C:\Python26\Lib\site-packages\PyQt4\bin;C:\Python26
 C:\Users\scottpython
 Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] 
 on win32
 Type help, copyright, credits or license for more information.
  from PyQt4 import QtCore
 Traceback (most recent call last):
   File stdin, line 1, in module
 ImportError: DLL load failed: The specified procedure could not be found.
 

 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] signal/slot with parameter (QSignalTransition)

2010-04-14 Thread Philippe Crave
Hi,

in a class, I have a QStateMachine, with some QState.
I would like to make a targetless transition for one state.
I followed the documentation here
http://qt.nokia.com/doc/4.6/statemachine-api.html#targetless-transitions

it works well if the initial event that launch the targetless transition
does not include any variables.
but now, I emit an event with an increment from a wheelEvent.
self.emit(SIGNAL(wheelEvent(int)), inc)
I do not know how to propagate that value from that event to the target slot
function self.change_drive.

actually, I get this error message:
TypeError: change_drive() takes exactly 2 arguments (1 given)

here is a part of my class
...
t = QSignalTransition(self, SIGNAL(wheelEvent(int)))
self.state_in.addTransition(t)
self.connect(t, SIGNAL(triggered()), self.change_drive)

@pyqtSignature(int)
def change_drive(self, v):
print 'change_drive', v

def wheelEvent(self, e):
inc = cmp(e.delta(), 0) * -1
self.emit(SIGNAL(wheelEvent(int)), inc)

thank you
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] problem with QGraphicsItem

2010-04-12 Thread Philippe Crave
really perfect!
simple, works very well.
thank you.

2010/4/12 David Boddie da...@boddie.org.uk

 On Tue, 6 Apr 2010 22:10:40 +0200, Philippe Crave wrote:

  I posted that question few days ago, but no answers. Maybe nobody use
  QGraphicItem. I do not know. I am new at pyqt (still reading the pyqt
  book !).
 
  Please, let me know if there is a better place to talk about
  QGraphicsItem, View, Scene,  I will use it a lot during the next
  month. it's a great tool compare to what I was using before.

 For some questions about the details of Qt features, the qt-interest
 mailing
 list might be a good place to ask:

  http://lists.trolltech.com/mailman/listinfo/qt-interest

  here was my question,
  I use setClipRegion() in the paint() method of a QGraphicsItem.
  That Item has got many children. I would like to avoid repeating the
  setClipRegion() in all of them.
  Thus, I would like to know if it's possible to propagate that
  Clipping to the children, automatically.

 A quick look in the documentation reveals the ItemClipsChildrenToShape
 flag:


 http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qgraphicsitem.html#GraphicsItemFlag-enum

 This might be useful in your case because you seem to clip the children to
 the rectangle occupied by your parent item.

 It may be that you can't use the painting system directly to clip child
 items
 and that setting this flag is the only way to clip them. You would have to
 experiment a bit more, or take a look at the QGraphicsItem source code, to
 verify this.

 David
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGraphicsObject / assignProperty

2010-04-10 Thread Philippe Crave
you mean:
alpha=pyqtProperty(get_alpha, set_alpha)

produce:
TypeError: type 'function' is not supported as a property type

should I import something specific ?
here are my actual import
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSvg import *

2010/4/9 Phil Thompson p...@riverbankcomputing.com

 On Fri, 9 Apr 2010 22:44:05 +0200, Philippe Crave
 philippe.cr...@gmail.com
 wrote:
  Hi,
 
  in a QGraphicsObject, I use a StateMachine.
  I have problem using assignProperty.
  I am sure to enter that State, but, it does not change my Class property.
 
  this how I assign the property
  self.state_in.assignProperty(self, alpha, 0)
 
  and here is how I define the property in the Class
  def get_alpha(self):
  print 'get'
  return self._alpha
  def set_alpha(self, v):
  print 'set'
  self.setOpacity(v)
  self._alpha = v
  alpha=property(get_alpha, set_alpha)
 
  What am I doing wrong ?

 Python properties and Qt properties are different things.

 Try using pyqtProperty() instead of property().

 Phil

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QGraphicsObject / Ubuntu 9.10

2010-04-10 Thread Philippe Crave
Hi,

On Ubuntu 9.10, we get pyqt 4.6.
in the official documentation, there is QGraphicsObject in 4.6
http://qt.nokia.com/doc/4.6/qgraphicsobject.html

but when I want to use it, i get an error message that tells QGraphicsObject
does not exist. (the other objects, like QGraphicsItem work).

in windows, I use the latest pyqt, and it works fine.

am I missing something ?
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGraphicsObject / Ubuntu 9.10

2010-04-10 Thread Philippe Crave
thanks, I misunderstood the version numbers.
I will wait ubuntu 10.4, it's soon.


2010/4/10 Phil Thompson p...@riverbankcomputing.com

 On Sat, 10 Apr 2010 16:39:52 +0200, Philippe Crave
 philippe.cr...@gmail.com wrote:
  Hi,
 
  On Ubuntu 9.10, we get pyqt 4.6.
  in the official documentation, there is QGraphicsObject in 4.6
  http://qt.nokia.com/doc/4.6/qgraphicsobject.html
 
  but when I want to use it, i get an error message that tells
  QGraphicsObject
  does not exist. (the other objects, like QGraphicsItem work).
 
  in windows, I use the latest pyqt, and it works fine.
 
  am I missing something ?

 PyQt v4.7 was the first release to support Qt v4.6.

 Phil

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QGraphicsObject / assignProperty

2010-04-09 Thread Philippe Crave
Hi,

in a QGraphicsObject, I use a StateMachine.
I have problem using assignProperty.
I am sure to enter that State, but, it does not change my Class property.

this how I assign the property
self.state_in.assignProperty(self, alpha, 0)

and here is how I define the property in the Class
def get_alpha(self):
print 'get'
return self._alpha
def set_alpha(self, v):
print 'set'
self.setOpacity(v)
self._alpha = v
alpha=property(get_alpha, set_alpha)

What am I doing wrong ?
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] [pyqt] drawPixmap() in a QGraphicsItem.paint() / SmoothTransformation issue

2010-04-07 Thread Philippe Crave
Had to set it in the View !

self.view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)


2010/4/2 Philippe Crave philippe.cr...@gmail.com:
 Hi,

 In a QGraphicsItem, I use painter.drawPixmap() in the paint() method.
 but when I resize the QGraphicsView, the Pixmap is not that pretty.

 If I put that pixmap in a QGraphicsPixmapItem, then, I can set the
 setTransformationMode(Qt.SmoothTransformation). the result is perfect
 in any situation.

 but is it possible to get a Qt.SmoothTransformation of a QPixmap in
 the following code sample ?

 /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
  /  /  /  /  /
 class Page(QGraphicsItem):

     Rect = QRectF(0, 0, 800, 480)

     def __init__(self, parent):
     super(Page, self).__init__(parent)
     self.setPos(self.mapFromParent(QPointF(0, 0)))
     
 self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsMovable)
        self.bg_pix = QPixmap('pic.png')

     def boundingRect(self):
     return Page.Rect

     def paint(self, painter, option, widget=None):
     painter.drawPixmap(QPointF(0, 0), self.bg_pix)
 /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
  /  /  /  /  /

 thank you,
 Philippe

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] problem with QGraphicsItem

2010-04-06 Thread Philippe Crave
hi,

I posted that question few days ago, but no answers. Maybe nobody use
QGraphicItem. I do not know. I am new at pyqt (still reading the pyqt
book !).

Please, let me know if there is a better place to talk about
QGraphicsItem, View, Scene,  I will use it a lot during the next
month. it's a great tool compare to what I was using before.

here was my question,
I use setClipRegion() in the paint() method of a QGraphicsItem.
That Item has got many children. I would like to avoid repeating the
setClipRegion() in all of them.
Thus, I would like to know if it's possible to propagate that
Clipping to the children, automatically.

In attachment, a simple .py that show the clipping not propagating
from parent to children.
Thanks for your help!
#!/usr/bin/env python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class BoxItem(QGraphicsItem):

def __init__(self, position, color, rect):
super(BoxItem, self).__init__()
self.setFlags(QGraphicsItem.ItemIsSelectable|
  QGraphicsItem.ItemIsMovable|
  QGraphicsItem.ItemIsFocusable)
self.rect = rect
self.color = color
self.setPos(position)
self.setMatrix(QMatrix())

def boundingRect(self):
return self.rect

def paint(self, painter, option, widget):
painter.setClipRegion(QRegion(QRect(0, 0, 20, 20)))
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(self.color))
painter.drawRect(self.rect)

class IntBoxItem(QGraphicsItem):

def __init__(self, position, color, rect, parent):
super(IntBoxItem, self).__init__(parent)
self.setFlags(QGraphicsItem.ItemIsSelectable|
  QGraphicsItem.ItemIsMovable|
  QGraphicsItem.ItemIsFocusable)
self.rect = rect
self.color = color
self.setPos(position)
self.setMatrix(QMatrix())
self.setOpacity(0.7)

def boundingRect(self):
return self.rect

def paint(self, painter, option, widget):
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(self.color))
painter.drawRect(self.rect)


class MainForm(QDialog):

def __init__(self, parent=None):
super(MainForm, self).__init__(parent)
self.scene = QGraphicsScene(self)
self.scene.setSceneRect(0, 0, 200, 200)
self.view = QGraphicsView()
self.view.setScene(self.scene)

layout = QVBoxLayout()
layout.addWidget(self.view)
self.setLayout(layout)

self.r1 = BoxItem(QPointF(0, 0), QColor(255, 0, 0), QRectF(0, 0, 100, 100))
self.r2 = IntBoxItem(QPointF(0, 0), QColor(255, 255, 0), QRectF(0, 0, 50, 50), self.r1)
self.scene.addItem(self.r1)


app = QApplication(sys.argv)
form = MainForm()
form.show()
app.exec_()

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] [pyqt] drawPixmap() in a QGraphicsItem.paint() / SmoothTransformation issue

2010-04-02 Thread Philippe Crave
Hi,

In a QGraphicsItem, I use painter.drawPixmap() in the paint() method.
but when I resize the QGraphicsView, the Pixmap is not that pretty.

If I put that pixmap in a QGraphicsPixmapItem, then, I can set the
setTransformationMode(Qt.SmoothTransformation). the result is perfect
in any situation.

but is it possible to get a Qt.SmoothTransformation of a QPixmap in
the following code sample ?

/  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
 /  /  /  /  /
class Page(QGraphicsItem):

    Rect = QRectF(0, 0, 800, 480)

    def __init__(self, parent):
    super(Page, self).__init__(parent)
    self.setPos(self.mapFromParent(QPointF(0, 0)))
    
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsMovable)
self.bg_pix = QPixmap('pic.png')

    def boundingRect(self):
    return Page.Rect

    def paint(self, painter, option, widget=None):
    painter.drawPixmap(QPointF(0, 0), self.bg_pix)
/  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
 /  /  /  /  /

thank you,
Philippe
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] [pyqt] how to propagate a painter.setClipRegion() to children of a QGraphicsItem

2010-04-02 Thread Philippe Crave
Hello,

For few days, I try to propagate a painter.setClipRegion() to the
children of a QGraphicsItem.
I hope someone can help me little bit.

I create 2 items. r1 and r2. r2's parent is r1.
I add r1 to the scene.
r1 has got a setClipRegion in is paint() method.
the clipping works perfect on r1, but not on r2 :/

here is my code..
-   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
#!/usr/bin/env python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class BoxItem(QGraphicsItem):

def __init__(self, position, color, rect):
super(BoxItem, self).__init__()
self.setFlags(QGraphicsItem.ItemIsSelectable|
  QGraphicsItem.ItemIsMovable|
  QGraphicsItem.ItemIsFocusable)
self.rect = rect
self.color = color
self.setPos(position)
self.setMatrix(QMatrix())

def boundingRect(self):
return self.rect

def paint(self, painter, option, widget):
painter.setClipRegion(QRegion(QRect(0, 0, 20, 20)))
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(self.color))
painter.drawRect(self.rect)

class IntBoxItem(QGraphicsItem):

def __init__(self, position, color, rect, parent):
super(IntBoxItem, self).__init__(parent)
self.setFlags(QGraphicsItem.ItemIsSelectable|
  QGraphicsItem.ItemIsMovable|
  QGraphicsItem.ItemIsFocusable)
self.rect = rect
self.color = color
self.setPos(position)
self.setMatrix(QMatrix())
self.setOpacity(0.7)

def boundingRect(self):
return self.rect

def paint(self, painter, option, widget):
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(self.color))
painter.drawRect(self.rect)


class MainForm(QDialog):

def __init__(self, parent=None):
super(MainForm, self).__init__(parent)
self.scene = QGraphicsScene(self)
self.scene.setSceneRect(0, 0, 200, 200)
self.view = QGraphicsView()
self.view.setScene(self.scene)

layout = QVBoxLayout()
layout.addWidget(self.view)
self.setLayout(layout)

self.r1 = BoxItem(QPointF(0, 0), QColor(255, 0, 0), QRectF(0,
0, 100, 100))
self.r2 = IntBoxItem(QPointF(0, 0), QColor(255, 255, 0),
QRectF(0, 0, 50, 50), self.r1)
self.scene.addItem(self.r1)


app = QApplication(sys.argv)
form = MainForm()
form.show()
app.exec_()
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt