[wxPython-users] ANN: FlatNotebook Control For wxPython ;-)
Andrea Gavana
andrea.gavana at gmail.com
Tue Oct 3 15:44:12 PDT 2006
Hello Matthias,
> Wow, this is just superb! You can drag around the individual pages like in
> VC, the demo rocks. I have two little comments about this:
Thanks, I am glad you liked it :-D
> 1. If I drag a tab to change the tab order in a peculiar notebook, I
> always have to drag it straight onto another tab. For example suppose
> there's Tab1 Tab2 and I want to make it Tab2 Tab1, I could either drag
> Tab2 on Tab1 or vice versa. It would be nice if you could extend this so
> that I could drag Tab1 somewhere right of Tab2 (not exactly onto Tab2) to
> move it to the last position. Or to drag Tab2 before Tab1 (to the left of
> Tab1, very close to the screen border).
Try the latest version I just uploaded, it should do what you ask :-D
> 2. Have you thought about combining this with wx.aui? I think VC does the
> same. Basically you can add new tabs to a notebook by dragging other
> tabs/windows onto it. Is it perhaps already possible by making a bunch of
> wx.aui panes, all containing FlatNotebooks? This would definately be one
> of the coolest things in wxpython and something I really appreciate. It
> would allow me to make my application work exactly like I wanted it to
> work.
Well, I can not integrate directly wxAUI with FlatNotebook, but try
the attached file and let me know if you like it :-D . It requires
wxPython 2.7 latest pre-release and latest FlatNotebook, which you can
get from:
http://xoomer.alice.it/infinity77/eng/freeware.html#flatnotebook
> Just for your information, I am using a lot of the controls you wrote by
> now. They're extremely useful for designing flexible, powerful and at the
> same time even good looking applications. I can't think of any more
> controls that you could write by now, honestly. Your work is basically the
> icing on the (great) cake that's called wxPython for me. Thanks a lot!
Thanks for your comments, you are too kind :-D. It's a joy for me
coding in wxPython after all that years at work using Matlab GUIs
(Matlab (!!!!)).
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
-------------- next part --------------
import wx
import wx.aui
import FlatNotebook as FNB
class AUI_FNB(wx.Frame):
=
def __init__(self, parent, id=3D-1, title=3D"", pos=3Dwx.DefaultPositio=
n,
size=3Dwx.DefaultSize, style=3Dwx.DEFAULT_FRAME_STYLE |
wx.SUNKEN_BORDER |
wx.CLIP_CHILDREN):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
=
# tell FrameManager to manage this frame =
self._mgr =3D wx.aui.FrameManager()
self._mgr.SetManagedWindow(self)
=
# min size for the frame itself isn't completely done.
# see the end up FrameManager::Update() for the test
# code. For now, just hard code a frame minimum size
self.SetMinSize(wx.Size(600, 500))
=
self._mgr.AddPane(self.CreateFlatNotebook(), wx.aui.PaneInfo().
Name("FNB1").Caption("First FlatNotebook").
Left().Layer(1).Position(1).MinSize(wx.Size(200, =
300)))
=
self._mgr.AddPane(self.CreateFlatNotebook(), wx.aui.PaneInfo().
Name("FNB2").Caption("Second FlatNotebook").
Bottom().Layer(1).Position(1).MinSize(wx.Size(300=
, 100)))
=
self._mgr.AddPane(self.CreateFlatNotebook(), wx.aui.PaneInfo().Name=
("FlatNotebook").
CenterPane())
self._perspectives =3D self._mgr.SavePerspective()
=
# "commit" all changes made to FrameManager =
self._mgr.Update()
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Centre() =
self.SendSizeEvent()
=
def CreateFlatNotebook(self):
bookStyle =3D FNB.FNB_TABS_BORDER_SIMPLE
book =3D FNB.StyledNotebook(self, wx.ID_ANY, style=3DbookStyle)
for ii in xrange(3):
caption =3D "Page # " + str(ii+1)
book.AddPage(self.CreatePage(book, caption), caption, False)
self.Style(book)
=
return book
def Style(self, book):
style =3D book.GetWindowStyleFlag()
style ^=3D FNB.FNB_NO_X_BUTTON
# remove old tabs style
mirror =3D ~(FNB.FNB_VC71 | FNB.FNB_VC8 | FNB.FNB_FANCY_TABS)
style &=3D mirror
# set new style
style |=3D FNB.FNB_VC8
style ^=3D FNB.FNB_TABS_BORDER_SIMPLE
book.SetGradientColorFrom(wx.WHITE)
book.SetGradientColorTo(wx.SystemSettings.GetColour(wx.SYS_COLOUR_A=
CTIVECAPTION))
book.SetNonActiveTabTextColour(wx.BLACK)
book.SetActiveTabColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3=
DFACE))
book.SetWindowStyleFlag(style)
book.Refresh()
=
def CreatePage(self, book, caption):
return wx.TextCtrl(book, -1, caption, style=3Dwx.TE_MULTILINE|wx.TE=
_READONLY)
=
def OnClose(self, event):
=
self._mgr.UnInit()
self.Destroy()
event.Skip() =
def OnSize(self, event):
event.Skip()
def main():
app =3D wx.PySimpleApp()
frame =3D AUI_FNB(None, -1, "wxAUI + FlatNotebook Example ;-)")
frame.Show()
app.MainLoop()
if __name__ =3D=3D "__main__":
main()
=20
More information about the wxpython-users
mailing list