"Book" Controls → Aui_Notebook
时间:2007-04-18 来源:wxPhoenix
Overview = """\
Hello!
Welcome to this little demo of draggable tabs using the wx.aui module.
To try it out, drag a tab from the top of the window all the way to the bottom.
After releasing the mouse, the tab will dock at the hinted position. Then try
it again with the remaining tabs in various other positions. Finally, try
dragging a tab to an existing tab ctrl. You'll soon see that very complex tab
layouts may be achieved. """
import wx
import wx.aui
import os.path
import random
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='Aui_Notebook', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
panel = wx.Panel(self, wx.ID_ANY)
notebook = wx.aui.AuiNotebook(panel, wx.ID_ANY)
pageTitles = ['C', 'C++', 'Python', 'Java', 'Perl', 'JavaScript', 'C#', 'AWK']
# Add pages
for title in pageTitles:
TextCtrl = wx.TextCtrl(notebook, wx.ID_ANY, 'this is page of %s' % title, style=wx.TE_MULTILINE)
num = random.randint(1, len(pageTitles))
bitmap = wx.Bitmap(os.path.join(os.getcwd(), 'bmp', str(num)+'.bmp'), wx.BITMAP_TYPE_BMP)
notebook.AddPage(TextCtrl, title, bitmap=bitmap)
sizer = wx.BoxSizer()
sizer.Add(notebook, 1, wx.EXPAND)
panel.SetSizer(sizer)
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
After releasing the mouse, the tab will dock at the hinted position. Then try
it again with the remaining tabs in various other positions. Finally, try
dragging a tab to an existing tab ctrl. You'll soon see that very complex tab
layouts may be achieved. """
import wx
import wx.aui
import os.path
import random
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='Aui_Notebook', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
panel = wx.Panel(self, wx.ID_ANY)
notebook = wx.aui.AuiNotebook(panel, wx.ID_ANY)
pageTitles = ['C', 'C++', 'Python', 'Java', 'Perl', 'JavaScript', 'C#', 'AWK']
# Add pages
for title in pageTitles:
TextCtrl = wx.TextCtrl(notebook, wx.ID_ANY, 'this is page of %s' % title, style=wx.TE_MULTILINE)
num = random.randint(1, len(pageTitles))
bitmap = wx.Bitmap(os.path.join(os.getcwd(), 'bmp', str(num)+'.bmp'), wx.BITMAP_TYPE_BMP)
notebook.AddPage(TextCtrl, title, bitmap=bitmap)
sizer = wx.BoxSizer()
sizer.Add(notebook, 1, wx.EXPAND)
panel.SetSizer(sizer)
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
相关阅读 更多 +