本文共 2172 字,大约阅读时间需要 7 分钟。
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
主要部分的源代码如下:
# -*- coding: utf-8 -*-
import wx
import images
from time import *
import panelOne,panelTwo,panelThree
class NotebookDemo(wx.Notebook):
def __init__(self,parent):
wx.Notebook.__init__(self,parent,id=wx.ID_ANY,style=
wx.BK_DEFAULT
#wx.BK_TOP
#wx.BK_BOTTOM
#wx.BK_LEFT
#wx.BK_RIGHT
)
# Create the first tab and add it to the notebook
tabOne = panelOne.TabPanel(self)
tabOne.SetBackgroundColour("Gray")
self.AddPage(tabOne,"TabOne")
# Show how to put an image on one of the notebooktabs,
# first make the image list:
il = wx.ImageList(16,16)
#idx1 = il.Add(wx.Bitmap("bitmaps/config.jpg", wx.BITMAP_TYPE_JPEG))
idx1 = il.Add(images.getSmilesBitmap())
self.AssignImageList(il)
# now put an image on the first tab we just created:
self.SetPageImage(0,idx1)
# Create and add the second tab
tabTwo = panelTwo.TabPanel(self)
self.AddPage(tabTwo,"TabTwo")
# Create and add the t third tab
tabThree = panelThree.TabPanel(self)
self.AddPage(tabThree,"TabThree")
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,self.OnPageChanged)
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING,self.OnPageChanging)
def OnPageChanged(self,event):
old = event.GetOldSelection()
new = event.GetSelection()
sel = self.GetSelection()
print 'OnPageChanging,old:%d,new:%d,sel:%d\n' %(old,new,sel)
event.Skip()
def OnPageChanging(self,event):
old = event.GetOldSelection()
new = event.GetSelection()
sel = self.GetSelection()
print 'OnPageChanging,old:%d,new:%d,sel:%d\n' %(old,new,sel)
event.Skip()
class DemoFrame(wx.Frame):
'''
Frame that holds all other widgets
'''
def __init__(self,parent,ID,title):
wx.Frame.__init__(self,parent,ID,title="Demo Frame Example",size=(500,700))
panel = wx.Panel(self,-1)
notebook = NotebookDemo(panel)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(notebook,1,wx.ALL|wx.EXPAND,5)
panel.SetSizer(sizer)
self.Layout()
class App(wx.App):
def __init__(self):
wx.App.__init__(self)
def OnInit(self):
self.title = "Demo Frame Example"
self.frame = DemoFrame(None,-1,self.title)
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True
if __name__ == "__main__":
myApp = App()
myApp.MainLoop()
需要源代码的同学们,去下面的连接下载:
链接:http://pan.baidu.com/s/1kUHL9fp 密码:0uf6
转载地址:https://blog.csdn.net/weixin_34081553/article/details/112962225 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!