Sorry about that last post, I've having trouble getting a text encoding in
these @#$@# mail programs.
### Import modules
from wxPython.wx import *
### Event id's
ID_EXIT = 100
ID_LOAD = 101
class MyTreeCtrl(wxTreeCtrl):
def __init__(self, parent, id, pos, size, style):
wxTreeCtrl.__init__(self,parent, id, pos, size, style)
def OnCompareItems(self, item1, item2):
t1 = self.GetItemText(item1)
t2 = self.GetItemText(item2)
if t1 < t2 : return -1
if t1 == t2: return 0
return 1
### end of MyTreeCtrl ###
class MyTreePanel(wxPanel):
def __init__(self, parent, id):
wxPanel.__init__(self, parent, id)
tID = NewId()
self.tree = MyTreeCtrl(self,
tID,
wxDefaultPosition,
wxSize(200, 200),
wxTR_HAS_BUTTONS|wxTR_EDIT_LABELS)
self.root = self.tree.AddRoot( "Missouri" )
self.tree.SetPyData(self.root, None )
self.tree.AppendItem(self.root, "Dummy")
# Link up Events to Methods
EVT_SIZE(self, self.OnSize);
EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
def OnItemExpanded(self, event):
item = event.GetItem()
child=self.tree.AppendItem(item, "The Show-")
self.tree.SetPyData(child, None)
child=self.tree.AppendItem(item, "Me State")
self.tree.SetPyData(child, None)
def OnSize(self, event):
w,h = self.GetClientSizeTuple()
self.tree.SetDimensions(0,0,w,h)
### end of MyTreePanel ###
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(550, 400))
self.CreateStatusBar()
self.SetStatusText("")
menuBar = wxMenuBar()
menu = wxMenu()
menu.Append(ID_LOAD, "&Load", "Load the data")
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar);
#split main window, (tree, data)
splitter = wxSplitterWindow(self, -1)
self.panel1 = wxWindow(splitter, -1)
self.panel2 = wxWindow(splitter, -1)
splitter.SetMinimumPaneSize(20)
splitter.SplitVertically(self.panel1, self.panel2)
splitter.SetSashPosition(200)
# Link up Events to Methods
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
EVT_MENU(self, ID_LOAD, self.Load)
def TimeToQuit(self, event):
self.Close(true)
def Load(self, event):
# HERE'S WHERE IT GETS LOADED!!!!
self.tree = MyTreePanel(self.panel1, -1)
### end of MyFrame ###
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
### end of MyApp ###
### Main Loop ###
app = MyApp(0)
app.MainLoop()