[PyQt] how aim same function to other tables

Tony Peña emperor.cu at gmail.com
Wed Aug 24 18:18:55 BST 2011


hi I want to use same function to other tables like this

tablename = Searchtable .... but could be table1 table2 table3 ... table n

addAction.triggered.connect(self.addFriend) <- This works ok def addFriend(
self, event): tablename = 'SearchtableWidget' table_obj = getattr(self.ui,
tablename)  current_row = table_obj.currentRow() current_vid = table_obj.
item(current_row, 0) current_realname = table_obj.item(current_row, 2)
total_vid = len(vid) insert = True if total_vid >= 0: for i in range(0,
total_vid): if int(str(current_vid.text())) == vid[i][0]: ..... rest code
run fine ....
------------------------------------------------------------------- if i
pass this to prepare the connect when right-click button is active...
addAction.triggered.connect(self.addFriend(self, 'SearchtableWidget')) <--
need fix this because is running function before connected :| def addFriend(
self, event, tablename): table_obj = getattr(self.ui, tablename) <-this
receive Searchtable same like before BUT... current_row = table_obj.
currentRow() current_vid = table_obj.item(current_row, 0) current_realname =
table_obj.item(current_row, 2) total_vid = len(vid) insert = True if
total_vid >= 0: for i in range(0, total_vid): if int(str(current_vid.text
())) == vid[i][0]: current_vid.text() <- current.text() method NOT WORK...
because when came tablename as argument is NoneType
                                            ...stop here...

I guess to need some help with how can connect to a function with ARG as
options...

any idea?


-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at http://pgp.mit.edu
 Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110824/eaf2f9af/attachment-0001.html>


More information about the PyQt mailing list