[PyKDE] How to add a Table Validator
Steve Taetzsch
staetzsc at yahoo.com
Wed Feb 2 02:44:44 GMT 2005
I'm trying to port a Tkinter application to pyqt. It
has a table that the user can enter dates in one
column and I'd like to add a validator to the entry.
I'd also would like to validate dollar amount entries
in another column. After reading the docs, I'm still
missing something. Below is some code I am trying. If
I uncomment the lines creating an editor, the app
slows way down. There can be a few hundred rows. I'm
also trying to change the background color of
alternate rows which seems to be working.
Something tells me I'm doing this all wrong. I'm new
to qt, and am trying to decide between qt,gtk and wx
for my new widget library. Any tips would be
appreciated.
Steve
dateValidRegExp is a global variable for now.
class myTableItem(QTableItem):
def __init__(self, table, edittype,
text,row,debit_flag=0):
QTableItem.__init__(self, table, edittype,
text)
self.row = row
self.debit_flag = debit_flag
## self.editor = self.createEditor()
## dateValidator =
QRegExpValidator(self.editor)
## dateValidator.setRegExp(dateValidRegExp)
## self.editor.setValidator(dateValidator)
def paint(self, painter, colorgroup, rect,
selected):
cg = QColorGroup(colorgroup)
if self.row % 2:
cg.setColor(QColorGroup.Base,
TABLE_GREEN_BG)
QTableItem.paint(self,painter, cg,rect,selected)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the PyQt
mailing list