Re: [PyKDE] Aligning Text in a Table

2003-06-29 Thread Bob Parnes
On Sun, Jun 29, 2003 at 09:39:20PM +0200, Simon Edwards wrote:
 Hi,
 
 On Sunday 29 June 2003 01:00, Bob Parnes wrote:
  I did not read your post carefully enough and thought that I had to make
  the call to paintCell. However, it is confusing, because now I do not
  understand the purpose of the arguments beyond the row and column.
 
 The other args specify if the cell is selected (and therefore should be drawn 
 in the selected state) and which colours should be used etc.
 
  Anyway, I did manage to successfully draw an example, so long as the
  code was in the paintCell implementation.
 
 That is correct.
 
  But I could not write 
  to the table at a later time.
 
 * BobTable stores the contents of the cells somewhere. (array of strings if 
 the cells hold strings etc).
 
 * paintCell() looks up the contents of the cell (i.e. grab it's string 
 contents) and draws the string on the QPainter object.
 
 * BobTable has a method for changing a cell's contents (i.e. 
 setStuff(row,col,newstring) )
 
 * setStuff() modifies the internal array of strings (cell contents) and then 
 calls QTable's updateCell(row,col). This tells Qt to repaint (redraw) that 
 cell.
 
 * When Qt is ready. Qt will call paintCell() for any cells that need 
 repainting.
 
 For a C++ example of how to do this kind of thing look at Guarddog's 
 checktablelistitem.cpp file:
 
 http://www.simonzone.com/software/guarddog/
 
 cheers,
 
 -- 
 Simon Edwards | Guarddog Firewall
 [EMAIL PROTECTED]   | http://www.simonzone.com/software/
 Nijmegen, The Netherlands | ZooTV? You made the right choice.
 
 ___
 PyKDE mailing list[EMAIL PROTECTED]
 http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Thanks. I just downloaded guarddog and will look it up.
-- 
Bob Parnes
[EMAIL PROTECTED]

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Aligning Text in a Table

2003-06-28 Thread Simon Edwards
Hi,

 Thanks for your response. I got lost trying to follow your idea. In the
 past I have subclassed my own classes and reimplemented methods in order 
 to make changes suiting the subclass. But here I cannot even make the
 simplest reimplementation of paintCell. For example, the method,
 
   def paintCell(self,p,row,col,r,selected):
   QTable.paintCell(self,p,row,col,r,selected)

Does this work?:

def paintCell(self,p,row,col,r,selected,cg):
QTable.paintCell(self,p,row,col,r,selected,cg)

Maybe PyQt doesn't have the 6 arg version (it's depreciated BTW),

 Furthermore, I don't know how to identify the QPainter object that Qt
 passes. I could not find any place in the documentation that describes
 how to do this. In my attempt above, I created one.

e... You don't need to identify anything. YOu just draw with the QPainter 
that you get.

cheers,

-- 
Simon Edwards | Guarddog Firewall
[EMAIL PROTECTED]   | http://www.simonzone.com/software/
Nijmegen, The Netherlands | ZooTV? You made the right choice.

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Aligning Text in a Table

2003-06-28 Thread Phil Thompson
On Saturday 28 June 2003 2:10 pm, Simon Edwards wrote:
 Hi,

  Thanks for your response. I got lost trying to follow your idea. In the
  past I have subclassed my own classes and reimplemented methods in order
  to make changes suiting the subclass. But here I cannot even make the
  simplest reimplementation of paintCell. For example, the method,
 
def paintCell(self,p,row,col,r,selected):
QTable.paintCell(self,p,row,col,r,selected)

 Does this work?:

 def paintCell(self,p,row,col,r,selected,cg):
 QTable.paintCell(self,p,row,col,r,selected,cg)

 Maybe PyQt doesn't have the 6 arg version (it's depreciated BTW),

This was discussed on the mailing list within the last 2 weeks. Both the 6 and 
7 argument variations are implemented but, because Python doesn't support 
function overloading, your re-implementation must handle both.

In other words...

def paintCell(self,p,row,col,r,selected,cg = None):
if cg:
QTable.paintCell(self,p,row,col,r,selected,cg)
else:
QTable.paintCell(self,p,row,col,r,selected)

Phil

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde