All, I am more than a little confused and would appreciate a nudge in the right direction.
I am reading records from a database and one of the fields (PID)
contains a string representation of a treeview path.
+-----------------+------------------+------+-----+----------------------+----------------+
| Field | Type | Null | Key | Default
| Extra |
+-----------------+------------------+------+-----+----------------------+----------------+
| AssemblyID | int(11) | NO | PRI | NULL
| auto_increment |
| ConfigID | int(11) | NO | | 1
| |
| PID | char(7) | NO | | 0
| |
I'm trying to display the following in a treeview in an indentured
manner. It will display as a flat list, but representing the
parent-child relationship has me befuddled.
+--------+-------+--------------+
| IndLvl | PID | Name |
+--------+-------+--------------+
| 0 | 0 | Workstation |
| 1 | 0:0 | Computer |
| 1 | 0:1 | Monitor |
| 1 | 0:2 | Keyboard |
| 1 | 0:3 | Mouse |
| 2 | 0:0:0 | Motherboard |
| 2 | 0:0:1 | Power Supply |
| 2 | 0:0:2 | Hard Drive |
+--------+-------+--------------+
I'm attempting to use the gtk.TreeModel get_iter_from_string() passing
the field with the path. I'm getting ValueError: invalid tree path.
Assuming that there was something wrong with the data in my database, I
attempted to pass just a static string to see if it returned
anything. Same results.
piter = self.model.get_iter_from_string('0')
piter = self.model.get_iter_from_string('(0,)')
piter = self.model.get_iter_from_string('0:')
I've looked at the tutorial and studied several uses of
get_iter_from_string() at koders.com. To me it looks like I am using it
correctly and I am passing a correct path, but obviously I am not.
Clearly I do not understand what I am doing and would appreciate a hint.
TIA
Andrew "Weibullguy" Rowland
The following is the code that it not working:
def populate_system_tree(self, results, n):
for i in range(n):
if (results[i][2] == '0'):
piter = self.model.append( None, [results[i][3],
results[i][4], results[i][5],
results[i][3], results[i][4], results[i][5],
results[i][6], results[i][7], results[i][8],
results[i][9], results[i][10], results[i][11],
results[i][12], results[i][13], results[i][14],
results[i][15]])
for j in range(n):
if (results[j][2] != '0'):
iter = self.model.append( piter, [results[j][3],
results[j][4], results[j][5],
results[j][3], results[j][4], results[j][5],
results[j][6], results[j][7], results[j][8],
results[j][9], results[j][10], results[j][11],
results[j][12], results[j][13], results[j][14],
results[j][15]])
piter =
self.model.get_iter_from_string(results[j][2])
--
Visit the ReliaFree Project at http://reliafree.sourceforge.net/
Please do not send me *.doc, *.xls, *.ppt, or *.mdb files. They are a
proprietary format and do not conform to any recognized standards available
in the public domain. I have no need for the proprietary programs used to
view and edit these file types and prefer standards-compliant formats.
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
