"Book" Controls → Listbook
时间:2007-04-18 来源:wxPhoenix
Overview = """\
wx.Listbook
This class is a control similar to a notebook control, but with a
wx.ListCtrl instead of a set of tabs.
"""
import wx
import os.path
import random
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='Listbook', 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)
pageTitles = ['C', 'C++', 'Python', 'Java', 'Perl', 'JavaScript', 'C#', 'AWK']
imageList = wx.ImageList(40, 40)
for number in range(len(pageTitles)):
imageList.Add(wx.Bitmap(os.path.join(os.getcwd(), 'bmp', str(number)+'.bmp'), wx.BITMAP_TYPE_BMP))
# imageList.Add(wx.Image('32x32.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap())
# imageList.Add(images.getSmilesBitmap())
listBook = wx.Listbook(parent=panel, id=wx.ID_ANY, style=
wx.BK_DEFAULT
# wx.BK_TOP
# wx.BK_BOTTOM
#wx.LEFT wx.RIGHT
)
listBook.AssignImageList(imageList)
for title in pageTitles:
textCtrl = wx.TextCtrl(listBook, wx.ID_ANY, 'This is page of %s' % title, style=wx.TE_MULTILINE)
id = random.randint(1, len(pageTitles)-1)
listBook.AddPage(textCtrl, title, imageId=id)
sizer = wx.BoxSizer()
sizer.Add(listBook, 1, wx.EXPAND)
panel.SetSizer(sizer)
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
wx.ListCtrl instead of a set of tabs.
"""
import wx
import os.path
import random
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='Listbook', 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)
pageTitles = ['C', 'C++', 'Python', 'Java', 'Perl', 'JavaScript', 'C#', 'AWK']
imageList = wx.ImageList(40, 40)
for number in range(len(pageTitles)):
imageList.Add(wx.Bitmap(os.path.join(os.getcwd(), 'bmp', str(number)+'.bmp'), wx.BITMAP_TYPE_BMP))
# imageList.Add(wx.Image('32x32.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap())
# imageList.Add(images.getSmilesBitmap())
listBook = wx.Listbook(parent=panel, id=wx.ID_ANY, style=
wx.BK_DEFAULT
# wx.BK_TOP
# wx.BK_BOTTOM
#wx.LEFT wx.RIGHT
)
listBook.AssignImageList(imageList)
for title in pageTitles:
textCtrl = wx.TextCtrl(listBook, wx.ID_ANY, 'This is page of %s' % title, style=wx.TE_MULTILINE)
id = random.randint(1, len(pageTitles)-1)
listBook.AddPage(textCtrl, title, imageId=id)
sizer = wx.BoxSizer()
sizer.Add(listBook, 1, wx.EXPAND)
panel.SetSizer(sizer)
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
相关阅读 更多 +