Opening another display on one side of a splitter window…
I’m having a small problem with adding a new window to a splitter window…I have a wxPython program that has a splitter window. On the left panel, there is a wxTreeCtrl, and when someone double clicks on one of the children nodes, I want to call a display for that child node on the right hand side. I’ve already created the displays before in Tkinter (before I started learning wxPython, when I learned Tkinter doesn’t have TreeCtrls built in), and have them saved as separate .pyw files, so really I want to do something like this:
class MyApp(wxApp):
"""driver class, creates a frame to store everything, puts 2 splitter windows inside, the first holding the tree display"""
def OnInit(self):
#create the frame
frame = MyFrame(NULL, -1, "Display")
frame.Show(true)
self.SetTopWindow(frame)
#create the splitter windows
splitter = MySplitter(frame, -1)
sty = wxBORDER_SUNKEN
self.p1 = wxWindow(splitter, style=sty)
self.p2 = wxWindow(splitter, style=sty)
self.p2.SetBackgroundColour("sky blue")
splitter.SetMinimumPaneSize(100)
splitter.SplitVertically(self.p1, self.p2, 320)
#Create the tree and add the outermost parents
self.p1.myTree = MyTreeCtrl(self.p1, -1, wxDefaultPosition, (400,400), wxTR_HAS_BUTTONS)
self.p1.root = self.p1.myTree.AddRoot("Media")
self.p1.myTree.SetPyData(self.p1.root, None)
self.p1.child1 = self.p1.myTree.AppendItem(self.p1.root, "Music")
self.p1.child2 = self.p1.myTree.AppendItem(self.p1.root, "Video")
#Bind Drag and Drop methods to the tree to support drag and drop
self.p1.myTree.Bind(EVT_TREE_BEGIN_DRAG, self.OnBeginDrag)
self.p1.myTree.Bind(EVT_TREE_END_DRAG, self.OnEndDrag)
self.p1.myTree.Bind(EVT_LEFT_DCLICK, self.OnLeftDClick)
#Fill with children
headerLabels = ["Title", "Year", "Genre", "Description", "Rating"]
for label in headerLabels:
grandchild = self.p1.myTree.AppendItem(self.p1.child1, label)
self.p1.myTree.SetPyData(grandchild, None)
grandchild = self.p1.myTree.AppendItem(self.p1.child2, label)
self.p1.myTree.SetPyData(grandchild, None)
#Expand base root to get to meat of data
self.p1.myTree.Expand(self.p1.root)
return true
def OnLeftDClick(self, event):
iterator = self.p1.myTree.GetLastChild(self.p1.root)
pt = event.GetPosition();
item, flags = self.p1.myTree.HitTest(pt)
clicked = self.p1.myTree.GetItemText(item)
if(clicked == "Year"):
self.p2 = YearInfo()
elif(clicked == "Genre" ):
self.p2 = GenreInfo()
elif(clicked == "Description"):
self.p2 = DescripInfo()
elif(clicked == "Rating"):
self.p2 = RatingInfo()
This works, in a sense, in that when I import the appopiate classes and double click on an item, and then close the open window, the appropiate display appears in the background. However, this isn’t what I want, as I really want the display to be packed into the p2. Is this possible?
“MMS <apsc.com>” made the following annotations.
···
— NOTICE —
This message is for the designated recipient only and may contain confidential, privileged or proprietary information. If you have received it in error, please notify the sender immediately and delete the original and any copy or printout. Unintended recipients are prohibited from making any other use of this e-mail. Although we have taken reasonable precautions to ensure no viruses are present in this e-mail, we accept no liability for any loss or damage arising from the use of this e-mail or attachments, or for any delay or errors or omissions in the contents which result from e-mail transmission.
==============================================================================