Re: [PyQt] identify a QTreeWidgetItem

2007-10-23 Thread Michael Towers

alteo_gange wrote:

Le mardi 23 octobre 2007, alteo_gange a écrit :
  

Hi everybody!

I have created several QTreeWidgetItem and connected a signal
"itemClicked(QTreeWidgetItem *,int)" on the QTreeWidget.



treeWidget=QtGui.QTreeWidget(widget)
...
itemTree1=QtGui.QTreeWidgetItem(treeWidget)
...
itemTree2=QtGui.QTreeWidgetItem(treeWidget)
...
self.connect(treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem
*,int)"),self.function)
...
def function(self, item):
print item
  

'print item' return:
.


It's very abstract!

I must identify QTreeWidgetItem in order to connect it an action (view a
widget on the right), but how? With a method of the item reference? Which?
I don't know.



With the .text() method, i can recover the QTreeWidgetItem name:
 
  

print item.text(0), "\n"



But with no-ascii characters (ex: itemTree.setText(0,_(u"Filtres vidéos"))), 
there is an error:


  

Traceback (most recent call last):
 File "/home/login/docs/langages/python/pyqt4/QTreeWidget.py", line 126, in   


fonction
  

   print item.text(0), "\n"
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 
11: ordinal not in range(128)

I find this one of the most annoying things in PyQt, it confuses me 
terribly. I think in this case you can do (for example)


print unicode(item.text(0)), "\n"

(the original result from item.text() being a QString)

But it may be that you need to specify an encoding and use the
encode or decode methods of unicode or string ...

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


Re: [PyQt] identify a QTreeWidgetItem

2007-10-23 Thread Jim Bublitz
On Tuesday 23 October 2007 02:13, alteo_gange wrote:
> Hi everybody!
>
> I have created several QTreeWidgetItem and connected a signal
> "itemClicked(QTreeWidgetItem *,int)" on the QTreeWidget.
>
> > treeWidget=QtGui.QTreeWidget(widget)
> > ...
> > itemTree1=QtGui.QTreeWidgetItem(treeWidget)
> > ...
> > itemTree2=QtGui.QTreeWidgetItem(treeWidget)
> > ...
> > self.connect(treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem
> > *,int)"),self.function)
> > ...
> > def function(self, item):
> > print item
>
> 'print item' return:
> .
>
>
> It's very abstract!
>
> I must identify QTreeWidgetItem in order to connect it an action (view a
> widget on the right), but how? With a method of the item reference? Which?
> I don't know.

Store the items in a dict as you create them:

self.itemDict = {}
itemTree1=QtGui.QTreeWidgetItem(treeWidget)
self.itemDict [itemTree1] = ??  # could be the associated widget that you want  

   #  to connect to, or a   
 
   # string identifier
itemTree2=QtGui.QTreeWidgetItem(treeWidget)
self.itemDict [itemTree2] = ??

...

def function (self, item):
widget = self.itemDict [item]
...

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


Re: [PyQt] PyQt book "Rapid GUI Programming with Python and Qt" now available

2007-10-23 Thread pyprog
Excuse in advance for my bad english.

Thank you very much Mark for your book . I'm going to command it as
soon as possible (but it seems to me your book will be accessible in
France only at the end of november).

a+ ;)

-- 
Venez faire un tour ici :

http://ekd.tolosano.info
http://monsitt.irruption.net
http://irruption.net/progdudim

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


Re: [PyQt] identify a QTreeWidgetItem

2007-10-23 Thread alteo_gange
Le mardi 23 octobre 2007, alteo_gange a écrit :
> Hi everybody!
>
> I have created several QTreeWidgetItem and connected a signal
> "itemClicked(QTreeWidgetItem *,int)" on the QTreeWidget.
>
> > treeWidget=QtGui.QTreeWidget(widget)
> > ...
> > itemTree1=QtGui.QTreeWidgetItem(treeWidget)
> > ...
> > itemTree2=QtGui.QTreeWidgetItem(treeWidget)
> > ...
> > self.connect(treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem
> > *,int)"),self.function)
> > ...
> > def function(self, item):
> > print item
>
> 'print item' return:
> .
>
>
> It's very abstract!
>
> I must identify QTreeWidgetItem in order to connect it an action (view a
> widget on the right), but how? With a method of the item reference? Which?
> I don't know.

With the .text() method, i can recover the QTreeWidgetItem name:
 
> print item.text(0), "\n"

But with no-ascii characters (ex: itemTree.setText(0,_(u"Filtres vidéos"))), 
there is an error:

> Traceback (most recent call last):
>  File "/home/login/docs/langages/python/pyqt4/QTreeWidget.py", line 126, in   
fonction
>print item.text(0), "\n"
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 
> 11: ordinal not in range(128)

-- 
alteo_gange


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


[PyQt] NotImplementedError

2007-10-23 Thread Heinz A. Preisig
Title: business




Hi,

I have been expanding my code with new features after which I
experience an error

NotImplementedError: QGraphicsItem.boundingRect() is abstract and must
be overridden

when using the rubber band. The procedure has been working before, but
obviously I disturbed the devil.

Any suggestions on what to change or do to get rid of the problem

Cheers, Heinz
-- 





  

  Heinz A Preisig
Professor of Process Systems Engineering
  Private: 
Øvre Bakklandet 62 B, 7013 Trondheim, Norway
  


  Department
of Chemical Engineering
  Norwegian
University of Science and
Technology       
  
  N – 7491 Trondheim, Norway
  Tel direct:
   +47     735
92807
  Tel mob:  
   +47     9754
1334
  e-mail: 
  [EMAIL PROTECTED]
  web:
  www.chemeng.ntnu.no\~preisig

  

 





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

Re: [PyQt] identify a QTreeWidgetItem

2007-10-23 Thread alteo_gange
I'm sorry for the multiple messages.
Few subscription problems. Now, it's OK.

-- 
alteo_gange

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


[PyQt] identify a QTreeWidgetItem

2007-10-23 Thread alteo_gange
Hi everybody! 
 
I have created several QTreeWidgetItem and connected a 
signal "itemClicked(QTreeWidgetItem *,int)" on the QTreeWidget.:
 
 
> treeWidget=QtGui.QTreeWidget(widget) 
> ... 
> itemTree1=QtGui.QTreeWidgetItem(treeWidget) 
> ... 
> itemTree2=QtGui.QTreeWidgetItem(treeWidget) 
> ... 
> self.connect(treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem 
*,int)"),self.function) 
> ... 
> def function(self, item): 
> print item 
 
 
'print item' return: 
. 
 
 
It's very abstract! 
 
I must identify QTreeWidgetItem in order to connect it an action (view a 
widget on the right), but how? With a method of the item reference? Which? I 
don't know.

-- 
alteo_gange

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


[PyQt] identify a QTreeWidgetItem

2007-10-23 Thread alteo_gange

Hi everybody!

I have created several QTreeWidgetItem and connected a signal
"itemClicked(QTreeWidgetItem *,int)" on the QTreeWidget.


> treeWidget=QtGui.QTreeWidget(widget)
> ...
> itemTree1=QtGui.QTreeWidgetItem(treeWidget)
> ...
> itemTree2=QtGui.QTreeWidgetItem(treeWidget)
> ...
> self.connect(treeWidget,QtCore.SIGNAL("itemClicked(QTreeWidgetItem
> *,int)"),self.function)
> ...
> def function(self, item):
> print item


'print item' return:
.


It's very abstract!

I must identify QTreeWidgetItem in order to connect it an action (view a
widget on the right), but how? With a method of the item reference? Which? I
don't know.
-- 
View this message in context: 
http://www.nabble.com/identify-a-QTreeWidgetItem-tf4672656.html#a13349040
Sent from the PyQt mailing list archive at Nabble.com.

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


Re: [PyQt] PyQt book "Rapid GUI Programming with Python and Qt" now available

2007-10-23 Thread Linos
I recommend this book to anyone that wants to learn PyQt, it is a excellent 
book with many real world examples
 with working code and really new stuff (it even use import from future in 
python).

Regards,
Miguel Angel.

Mark Summerfield escribió:
> Hi,
> 
> I am delighted to announce that
> 
> "Rapid GUI Programming with Python and Qt:
>  The Definitive Guide to PyQt Programming"
> 
> has now been published in the US.
> 
> The book is a hardback, 648 pages, ISBN 0132354187.
> 
> The foreword was written by Phil Thompson (creator of PyQt), who was
> also one of the book's five technical reviewers.
> 
> For a brief overview of the book and the table of contents, etc., see
> 
> http://www.qtrac.eu/pyqtbook.html
> 
> This web page also has links to places that sell the book, and has the
> full source code for the examples (and model answers to almost every
> exercise) available for downloading.
> 
> The book covers PyQt4 (it has no coverage of PyQt3), and is best used
> with Python 2.5 and PyQt 4.2 or better, on Windows, Mac OS X, or an
> X11-based Unix or Linux. No prior knowledge of GUI programming is
> assumed, so don't worry if you've only ever done web programming:-)
> 
> Since this is the only book that covers PyQt4 it is automatically the
> "best"---but I have not been complacent, and have worked extremely hard
> to make the book as accessible, useful, enjoyable, and interesting as
> possible.
> 
> (Note for Safari readers: The printed version of the book uses the PDF I
> supplied as is, with fonts and typesetting exactly as I wanted them,
> whereas the Safari online edition was retypeset by the publisher.)
> 

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


Re: [PyQt] PyQt book "Rapid GUI Programming with Python and Qt" now available

2007-10-23 Thread Horst Herb
On Tuesday 23 October 2007 17:46, Mark Summerfield wrote:
> Since this is the only book that covers PyQt4 it is automatically the
> "best"---but I have not been complacent, and have worked extremely hard
> to make the book as accessible, useful, enjoyable, and interesting as
> possible.
>
> (Note for Safari readers: The printed version of the book uses the PDF I
> supplied as is, with fonts and typesetting exactly as I wanted them,
> whereas the Safari online edition was retypeset by the publisher.)

I bought the "rough cut" version via Safari - it is a true delight to read. 
Covers a very comprehensive cross section of PyQt4 - I can really recommend 
it highly to anybody beginning to program in PyQt4

>From my perspective however I'd wish the introductory chapter on general 
Python (which is excellent for real beginners btw, I get my kids to read 
them!) was scrapped in favour of more detailed widget discussion, or 
alternatively, just more pages. More please!

Horst
-- 
Government is the mechanism by which you mind my business and I mind yours.

Cat Farmer

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


[PyQt] PyQt book "Rapid GUI Programming with Python and Qt" now available

2007-10-23 Thread Mark Summerfield
Hi,

I am delighted to announce that

"Rapid GUI Programming with Python and Qt:
 The Definitive Guide to PyQt Programming"

has now been published in the US.

The book is a hardback, 648 pages, ISBN 0132354187.

The foreword was written by Phil Thompson (creator of PyQt), who was
also one of the book's five technical reviewers.

For a brief overview of the book and the table of contents, etc., see

http://www.qtrac.eu/pyqtbook.html

This web page also has links to places that sell the book, and has the
full source code for the examples (and model answers to almost every
exercise) available for downloading.

The book covers PyQt4 (it has no coverage of PyQt3), and is best used
with Python 2.5 and PyQt 4.2 or better, on Windows, Mac OS X, or an
X11-based Unix or Linux. No prior knowledge of GUI programming is
assumed, so don't worry if you've only ever done web programming:-)

Since this is the only book that covers PyQt4 it is automatically the
"best"---but I have not been complacent, and have worked extremely hard
to make the book as accessible, useful, enjoyable, and interesting as
possible.

(Note for Safari readers: The printed version of the book uses the PDF I
supplied as is, with fonts and typesetting exactly as I wanted them,
whereas the Safari online edition was retypeset by the publisher.)

-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu

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