Hello!
I have some trouble with my GUI. I have left panel with foldpanelbar,
but i need one item but not collapsed - simple button. I split my left
panel into two foldpanelbars with one button between.
But a have trouble...
Sorry for english :/
Simple code:
#------------------------------------------------------------------------------------------------------
import sys
import wx
import wx.html as html
import wx.lib.foldpane lbar as fpb
import os
import sys
ID_New = wx.NewId()
ID_Exit = wx.NewId()
#------------------------------------------------------------------------------
class MyMDIChildFrame (wx.MDIChildFra me):
#------------------------------------------------------------------------------
def __init__(self,p arent,id,name=" "):
wx.MDIChildFram e.__init__(self ,parent, id, name)
self.InitGUI()
#--------------------------------------------------------------------------
def InitGUI(self):
#--------------------------------------------------------------------------
self.mainSplitt er = wx.SplitterWind ow(self, -1,
style=wx.SP_NOB ORDER)
self.infoViewer = html.HtmlWindow (self.mainSplit ter, -1,
style=wx.NO_FUL L_REPAINT_ON_RE SIZE)
#self.infoViewe r.LoadPage("htt p://wxwidgets.org/manuals/2.5.4/
wx_wxbutton.htm l")
self.infoViewer .SetPage("Here is some <b>formatted</b>
<i><u>text</u></iloaded from a <font color=\"red\">s tring</font>.")
self.leftPanel = wx.Panel(self.m ainSplitter)
self.CreateFold Panel()
self.mainSplitt er.Initialize(s elf.infoViewer)
self.mainSplitt er.SplitVertica lly(self.leftPa nel,
self.infoViewer , 180)
#--------------------------------------------------------------------------
def CreateFoldPanel (self):
#--------------------------------------------------------------------------
# foldpanel #1
self.foldPanel1 = fpb.FoldPanelBa r(self.leftPane l, -1,
wx.DefaultPosit ion, wx.Size(-1,-1), fpb.FPB_DEFAULT _STYLE,
fpb.FPB_SINGLE_ FOLD)
self.bs = wx.BoxSizer(wx. VERTICAL)
self.leftPanel. SetSizer(self.b s)
self.leftPanel. SetBackgroundCo lour(wx.BLACK)
item = self.foldPanel1 .AddFoldPanel(" Documents",
collapsed=False )
item.SetBackgro undColour(wx.RE D)
button1 = wx.Button(item, wx.ID_ANY, "In")
button2 = wx.Button(item, wx.ID_ANY, "Out")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
item = self.foldPanel1 .AddFoldPanel(" Projects", collapsed=False )
item.SetBackgro undColour(wx.BL UE)
button1 = wx.Button(item, wx.ID_ANY, "Name")
button2 = wx.Button(item, wx.ID_ANY, "Type")
button3 = wx.Button(item, wx.ID_ANY, "Data")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
self.foldPanel1 .AddFoldPanelWi ndow(item, button3)
item = self.foldPanel1 .AddFoldPanel(" Contacts", collapsed=False )
item.SetBackgro undColour(wx.CY AN)
button1 = wx.Button(item, wx.ID_ANY, "Name")
button2 = wx.Button(item, wx.ID_ANY, "Mail")
button3 = wx.Button(item, wx.ID_ANY, "City")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
self.foldPanel1 .AddFoldPanelWi ndow(item, button3)
self.bs.Add(sel f.foldPanel1, 0, wx.EXPAND)
# button
button1 = wx.Button(self. leftPanel, wx.ID_ANY, "Calendar")
self.bs.Add(but ton1, 0, wx.ALL|wx.EXPAN D, 4)
# foldpanel #2
self.foldPanel2 = fpb.FoldPanelBa r(self.leftPane l, -1,
wx.DefaultPosit ion, wx.Size(-1,-1), fpb.FPB_DEFAULT _STYLE,
fpb.FPB_SINGLE_ FOLD)
item = self.foldPanel2 .AddFoldPanel(" Treenote", collapsed=True)
item.SetBackgro undColour(wx.GR EEN)
self.tree = wx.TreeCtrl(ite m, wx.ID_ANY, wx.DefaultPosit ion,
wx.DefaultSize, wx.TR_HAS_BUTTO NS| wx.TR_EDIT_LABE LS|
wx.TR_HIDE_ROOT )#| wx.TR_MULTIPLE# | wx.TR_HIDE_ROOT )
self.foldPanel2 .AddFoldPanelWi ndow(item, self.tree)
self.LoadTree()
self.bs.Add(sel f.foldPanel2, 0, wx.EXPAND)
self.foldPanel1 .Bind(fpb.EVT_C APTIONBAR, self.OnPressCap tion)
self.foldPanel2 .Bind(fpb.EVT_C APTIONBAR, self.OnPressCap tion)
self.bs.Fit(sel f)
self.bs.Layout( )
self.foldPanel1 .Layout()
self.foldPanel2 .Layout()
#--------------------------------------------------------------------------
def OnPressCaption( self, event):
#--------------------------------------------------------------------------
self.bs.Layout( )
event.Skip()
#--------------------------------------------------------------------------
def LoadTree(self):
#--------------------------------------------------------------------------
self.root = self.tree.AddRo ot("The Root Item")
for x in range(15):
child = self.tree.Appen dItem(self.root , "Test item %d" % x)
for y in range(5):
last = self.tree.Appen dItem(child, "test item %d-%s" % (x,
chr(ord("a")+y) ))
for z in range(5):
item = self.tree.Appen dItem(last, "test item %d-%s-%d" %
(x, chr(ord("a")+y) , z))
#------------------------------------------------------------------------------
class MyParentFrame(w x.MDIParentFram e):
#------------------------------------------------------------------------------
#--------------------------------------------------------------------------
def __init__(self):
#--------------------------------------------------------------------------
wx.MDIParentFra me.__init__(sel f, None, -1, "MDI Parent",
size=(800,600))
self.winCount = 0
menu = wx.Menu()
menu.Append(ID_ New, "&New Window")
menu.AppendSepa rator()
menu.Append(ID_ Exit, "E&xit")
menubar = wx.MenuBar()
menubar.Append( menu, "&File")
self.SetMenuBar (menubar)
self.CreateStat usBar()
self.my_canvas = None
self.Bind(wx.EV T_MENU, self.OnNewWindo w, id=ID_New)
self.CreateNewW indow()
#--------------------------------------------------------------------------
def OnNewWindow(sel f, evt):
#--------------------------------------------------------------------------
self.CreateNewW indow()
#--------------------------------------------------------------------------
def CreateNewWindow (self):
#--------------------------------------------------------------------------
self.winCount = self.winCount + 1
win = MyMDIChildFrame (self, -1, "Child Window: %d" %
self.winCount)
win.Maximize()
if __name__ == '__main__':
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImage Handlers()
frame = MyParentFrame()
frame.Show(True )
self.SetTopWind ow(frame)
return True
app = MyApp(False)
app.MainLoop()
I have some trouble with my GUI. I have left panel with foldpanelbar,
but i need one item but not collapsed - simple button. I split my left
panel into two foldpanelbars with one button between.
But a have trouble...
Sorry for english :/
Simple code:
#------------------------------------------------------------------------------------------------------
import sys
import wx
import wx.html as html
import wx.lib.foldpane lbar as fpb
import os
import sys
ID_New = wx.NewId()
ID_Exit = wx.NewId()
#------------------------------------------------------------------------------
class MyMDIChildFrame (wx.MDIChildFra me):
#------------------------------------------------------------------------------
def __init__(self,p arent,id,name=" "):
wx.MDIChildFram e.__init__(self ,parent, id, name)
self.InitGUI()
#--------------------------------------------------------------------------
def InitGUI(self):
#--------------------------------------------------------------------------
self.mainSplitt er = wx.SplitterWind ow(self, -1,
style=wx.SP_NOB ORDER)
self.infoViewer = html.HtmlWindow (self.mainSplit ter, -1,
style=wx.NO_FUL L_REPAINT_ON_RE SIZE)
#self.infoViewe r.LoadPage("htt p://wxwidgets.org/manuals/2.5.4/
wx_wxbutton.htm l")
self.infoViewer .SetPage("Here is some <b>formatted</b>
<i><u>text</u></iloaded from a <font color=\"red\">s tring</font>.")
self.leftPanel = wx.Panel(self.m ainSplitter)
self.CreateFold Panel()
self.mainSplitt er.Initialize(s elf.infoViewer)
self.mainSplitt er.SplitVertica lly(self.leftPa nel,
self.infoViewer , 180)
#--------------------------------------------------------------------------
def CreateFoldPanel (self):
#--------------------------------------------------------------------------
# foldpanel #1
self.foldPanel1 = fpb.FoldPanelBa r(self.leftPane l, -1,
wx.DefaultPosit ion, wx.Size(-1,-1), fpb.FPB_DEFAULT _STYLE,
fpb.FPB_SINGLE_ FOLD)
self.bs = wx.BoxSizer(wx. VERTICAL)
self.leftPanel. SetSizer(self.b s)
self.leftPanel. SetBackgroundCo lour(wx.BLACK)
item = self.foldPanel1 .AddFoldPanel(" Documents",
collapsed=False )
item.SetBackgro undColour(wx.RE D)
button1 = wx.Button(item, wx.ID_ANY, "In")
button2 = wx.Button(item, wx.ID_ANY, "Out")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
item = self.foldPanel1 .AddFoldPanel(" Projects", collapsed=False )
item.SetBackgro undColour(wx.BL UE)
button1 = wx.Button(item, wx.ID_ANY, "Name")
button2 = wx.Button(item, wx.ID_ANY, "Type")
button3 = wx.Button(item, wx.ID_ANY, "Data")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
self.foldPanel1 .AddFoldPanelWi ndow(item, button3)
item = self.foldPanel1 .AddFoldPanel(" Contacts", collapsed=False )
item.SetBackgro undColour(wx.CY AN)
button1 = wx.Button(item, wx.ID_ANY, "Name")
button2 = wx.Button(item, wx.ID_ANY, "Mail")
button3 = wx.Button(item, wx.ID_ANY, "City")
self.foldPanel1 .AddFoldPanelWi ndow(item, button1)
self.foldPanel1 .AddFoldPanelWi ndow(item, button2)
self.foldPanel1 .AddFoldPanelWi ndow(item, button3)
self.bs.Add(sel f.foldPanel1, 0, wx.EXPAND)
# button
button1 = wx.Button(self. leftPanel, wx.ID_ANY, "Calendar")
self.bs.Add(but ton1, 0, wx.ALL|wx.EXPAN D, 4)
# foldpanel #2
self.foldPanel2 = fpb.FoldPanelBa r(self.leftPane l, -1,
wx.DefaultPosit ion, wx.Size(-1,-1), fpb.FPB_DEFAULT _STYLE,
fpb.FPB_SINGLE_ FOLD)
item = self.foldPanel2 .AddFoldPanel(" Treenote", collapsed=True)
item.SetBackgro undColour(wx.GR EEN)
self.tree = wx.TreeCtrl(ite m, wx.ID_ANY, wx.DefaultPosit ion,
wx.DefaultSize, wx.TR_HAS_BUTTO NS| wx.TR_EDIT_LABE LS|
wx.TR_HIDE_ROOT )#| wx.TR_MULTIPLE# | wx.TR_HIDE_ROOT )
self.foldPanel2 .AddFoldPanelWi ndow(item, self.tree)
self.LoadTree()
self.bs.Add(sel f.foldPanel2, 0, wx.EXPAND)
self.foldPanel1 .Bind(fpb.EVT_C APTIONBAR, self.OnPressCap tion)
self.foldPanel2 .Bind(fpb.EVT_C APTIONBAR, self.OnPressCap tion)
self.bs.Fit(sel f)
self.bs.Layout( )
self.foldPanel1 .Layout()
self.foldPanel2 .Layout()
#--------------------------------------------------------------------------
def OnPressCaption( self, event):
#--------------------------------------------------------------------------
self.bs.Layout( )
event.Skip()
#--------------------------------------------------------------------------
def LoadTree(self):
#--------------------------------------------------------------------------
self.root = self.tree.AddRo ot("The Root Item")
for x in range(15):
child = self.tree.Appen dItem(self.root , "Test item %d" % x)
for y in range(5):
last = self.tree.Appen dItem(child, "test item %d-%s" % (x,
chr(ord("a")+y) ))
for z in range(5):
item = self.tree.Appen dItem(last, "test item %d-%s-%d" %
(x, chr(ord("a")+y) , z))
#------------------------------------------------------------------------------
class MyParentFrame(w x.MDIParentFram e):
#------------------------------------------------------------------------------
#--------------------------------------------------------------------------
def __init__(self):
#--------------------------------------------------------------------------
wx.MDIParentFra me.__init__(sel f, None, -1, "MDI Parent",
size=(800,600))
self.winCount = 0
menu = wx.Menu()
menu.Append(ID_ New, "&New Window")
menu.AppendSepa rator()
menu.Append(ID_ Exit, "E&xit")
menubar = wx.MenuBar()
menubar.Append( menu, "&File")
self.SetMenuBar (menubar)
self.CreateStat usBar()
self.my_canvas = None
self.Bind(wx.EV T_MENU, self.OnNewWindo w, id=ID_New)
self.CreateNewW indow()
#--------------------------------------------------------------------------
def OnNewWindow(sel f, evt):
#--------------------------------------------------------------------------
self.CreateNewW indow()
#--------------------------------------------------------------------------
def CreateNewWindow (self):
#--------------------------------------------------------------------------
self.winCount = self.winCount + 1
win = MyMDIChildFrame (self, -1, "Child Window: %d" %
self.winCount)
win.Maximize()
if __name__ == '__main__':
class MyApp(wx.App):
def OnInit(self):
wx.InitAllImage Handlers()
frame = MyParentFrame()
frame.Show(True )
self.SetTopWind ow(frame)
return True
app = MyApp(False)
app.MainLoop()
Comment