Robin Dunn <robin <at> alldunn.com> writes:
>> I thought this would work, but when I hide the loader I use the same
>> sizer code
>> that sizes up the loader on the tree, but nothing happens- the tree
>> shows with
>> .Show() but is still a little square. Could this be because the
>> program is
>> already in the Mainloop by this point? (I have to run the tree builder
>> in a
>> thread so I could get to Frame.Show() and the mainloop to show the
>> loader in the
>> first place)
> I think what you want is:
>
> - create a panel
> - add the loader message to this panel
> - add the listctrl to the same panel
> - listctrl.Hide()
> - add both to a sizer and do panel.SetSizer(sizer)
> - when you have the data load it into the listctrl
> - loader.Hide()
> - listctrl.Show()
> - panel.Layout()
>
> If listctrl is still small at this point then check your sizer options
> (expand/propertion) for the listctrl.
And one more step, use that panel (the parent of the message and the
tree windows) as the window that is put in the splitter. In other
words, you are adding an extra layer in between the splitter and the
message/tree widgets, and that new layer will be managed by the splitter
and it will in turn manage the message or tree widgets.
I can't get this working at all.. I've followed the steps above plus a bunch of
different variations but to no avail. I've simplified my code just down to the
bits needed to show what I'm trying to do and included it below. I hope this
helps show what I'm doing wrong 
import wx,time,thread
import wx.lib.agw.customtreectrl as CT
class CustomTreeCtrl(CT.CustomTreeCtrl):
def __init__(self, parent, id, pos, size, style, spanel, loader):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, wx.SIMPLE_BORDER,
style)
self.spanel= spanel
self.loader= loader
isz = (16,16)
il = wx.ImageList(isz[0], isz[1])
self.fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER,
wx.ART_OTHER, isz))
self.fldropenidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN,
wx.ART_OTHER, isz))
self.fileidx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE,
wx.ART_OTHER, isz))
self.SetImageList(il)
self.il = il
thread.start_new_thread(self.loadTree,(None,))
def loadTree(self,junk):
time.sleep(3)
self.root_name= "Root"
self.root = self.AddRoot(self.root_name,ct_type=1)
self.root.Set3State(True)
self.SetItemImage(self.root, self.fldridx, wx.TreeItemIcon_Selected)
self.SetItemImage(self.root, self.fldropenidx, wx.TreeItemIcon_Expanded)
child= self.addChildNode(self.root,"child 1")
self.addChildNode(child,"child 2")
self.Expand(self.root)
self.loader.Hide()
## s1= wx.BoxSizer(wx.VERTICAL)
## s1.Add(self,1,wx.EXPAND)
## self.spanel.SetSizer(s1)
self.Show()
def addChildNode(self,parent,name):
child= self.AppendItem(parent,name,ct_type=1)
child.Set3State(True)
self.SetItemImage(child, self.fldridx, wx.TreeItemIcon_Normal)
self.SetItemImage(child, self.fldropenidx, wx.TreeItemIcon_Expanded)
return child
class Loader(wx.Panel):
def __init__(self, parent):
""""""
wx.Panel.__init__(self, parent=parent, style=wx.SIMPLE_BORDER)
self.SetBackgroundColour("White")
font1=wx.Font(14,wx.NORMAL,wx.NORMAL,wx.NORMAL)
text1="Please wait..."
sizer= wx.BoxSizer(wx.VERTICAL)
sizer.AddStretchSpacer()
#gif= "loader.gif"
#spinner= wx.animate.GIFAnimationCtrl(self, -1, gif)
#spinner.GetPlayer().UseBackgroundColour(True)
#spinner.Play()
#sizer.Add(spinner,0,wx.ALIGN_CENTER)
t1= wx.StaticText(self,-1,text1,style=wx.ALIGN_CENTER)
t1.SetFont(font1)
sizer.Add(t1,0,wx.ALL|wx.ALIGN_CENTER,10)
sizer.AddStretchSpacer()
self.SetSizer(sizer)
class FileSelectorFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(800,
600))
p= wx.Panel(self)
self.splitter1 = wx.SplitterWindow(p, -1, style=wx.SP_3D)
spanel= wx.Panel(self.splitter1)
self.loader= Loader(spanel)
self.tree = CustomTreeCtrl(spanel, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TR_DEFAULT_STYLE
#wx.TR_HAS_BUTTONS
#| wx.TR_EDIT_LABELS
#| wx.TR_MULTIPLE
#| wx.TR_HIDE_ROOT
,spanel,self.loader)
self.tree.Hide()
s1= wx.BoxSizer(wx.VERTICAL)
s1.Add(self.loader,1,wx.EXPAND)
s1.Add(self.tree,1,wx.EXPAND)
spanel.SetSizer(s1)
#This is normally something different, I've just put in a panel for
simplicity
self.p2= wx.Panel(self.splitter1,-1,style=wx.BORDER_SIMPLE)
self.p2.SetBackgroundColour("white")
self.splitter1.SplitVertically(spanel, self.p2)
self.splitter1.SetSashPosition(300)
self.splitter1.SetMinimumPaneSize(50)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.splitter1, 1, wx.ALL|wx.EXPAND, 5)
p.SetSizer(sizer)
self.Centre()
class RApp(wx.App):
def OnInit(self):
self.frame = FileSelectorFrame(None, -1, "framey")
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True
if __name__ == '__main__':
app = RApp(False)
app.MainLoop()
···
On 10/4/11 10:34 AM, werner wrote:
> On 10/04/2011 07:26 PM, Paul wrote: