473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[wxPython] How to tack data onto a node of a tree?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ok, this one has me scratching my head. Right now my application is
working fine. I have a tree control which contains a 2-level deep tree.
The first level is directories while the second level are files in those
directories. The user clicks on the file they want to manipulate and it
is loaded and parsed into other windows. However I'm doing it in a
kludgey fashion and would like to do the proper thing.

The kludge is that I could not figure out how to associate data with
a particular node within the tree. So for the moment I have set the
data to NULL and the node's name is either the directory name or the
file name. When the user clicks on the file I then grab the node's
name, grab the parent node ID, grab the name of the parent node name and
then splice them together. EG:

def BuildPath(self, id):
''' Build a path from the node and parent node name'''
# This really should be contained in the node data.
file = self.FileList.GetItemText(id)
parent = self.FileList.GetItemParent(id)
path = self.FileList.GetItemText(parent)
filepath = path + '/' + file
return(filepath)

As the comment says, the path to the file should really be contained
in the data associated with the node.

I've read the documentation for wxTreeItemData and am a little
confused. Would something like the following work for assignment?

dir = '/dir/to/file'
file = 'filename'
filepath = wxTreeItemData(dir + '/' + file)
self.FileList.Append(dir_node, -1, -1, filepath)

I believe that the following would be used to retrieve the data?
filepath = self.FileList.GetPyData(id)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/NTeIel/srYtumcURAqQ2AJ9HZbdZSSlee+zvRHFVAn4ltNnp+ACdEyf2
XNCzUogZkEAnRtqXQxYX/GU=
=phai
-----END PGP SIGNATURE-----

--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
PGP Key: 8B6E99C5 | main connection to the switchboard of souls.
| -- Lenny Nero - Strange Days
-------------------------------+---------------------------------------------
Jul 18 '05 #1
1 2300
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 09 Aug 2003 18:03:52 -0000, Steve Lamb <gr**@despair.rpglink.com> wrote:
I've read the documentation for wxTreeItemData and am a little
confused. Would something like the following work for assignment? dir = '/dir/to/file'
file = 'filename'
filepath = wxTreeItemData(dir + '/' + file)
self.FileList.Append(dir_node, -1, -1, filepath) I believe that the following would be used to retrieve the data?
filepath = self.FileList.GetPyData(id)


Well, I thought that wrestling with my program or building a test
case would take longer than it did. Turns out I was able to make the
modifications quickly and it looks like I read the documentation
accurately. Teach me to ask before trying, esp. when it comes to
Python.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/NT3cel/srYtumcURAjQ0AKC5J/P0JwSlM32koy9O9iPAKSTx9gCeIkfO
GCJRkpaASyTHAEg29xXT2Mk=
=me9C
-----END PGP SIGNATURE-----

--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
PGP Key: 8B6E99C5 | main connection to the switchboard of souls.
| -- Lenny Nero - Strange Days
-------------------------------+---------------------------------------------
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems...
4
by: Piet | last post by:
Hello. I am working on an XML editor that will not display the xml file as plain text, but will rather work with a combination of a tree view for the main element nodes and some kind of tabular...
0
by: t_pet422 | last post by:
Hi, I've been scouring the net and reading the PostgreSQL docs for a while now trying to learn how to create a recursive function in PL/pgSQL that will return a whole subtree given a starting...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
6
by: sathyashrayan | last post by:
#include<stdio.h> #include<stdlib.h> #include<string.h> struct tree { int data; struct tree *left,*right; }; void init(struct tree *node)
2
by: rodmc | last post by:
I am totally new to Python and WxPython and need to write an application which can open up an external windows from a plug-in within GAIM (using pyGAIM). I have managed to hack some code together...
12
by: vivainio | last post by:
I rarely do GUIs, and reminded myself today why that is the case (simply, it's not fun). I implemented a simple TreeCtrl, and had to implement my own 'children' method, of all things! Here it...
1
by: Eric von Horst | last post by:
Hi, I need some advice on Drag&Drop. What I want to achieve is the following: - I have a window that is divided in two : on the left hand I have a wx.TreeCtlr and on the other hand a...
3
by: azrael | last post by:
I need to implement a tree which will append a root. Any other node in the tree will be triggered when a button is pressed. I created the button, all the needed events, tree and a root. But when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.