毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

wxpython中用ToolBook在标签页中添加内容不能调整大小

更新时间:2016-6-15:  来源:毕业论文

代码如下,用的python2.6,wx是3.0
出现的问题是,在标签页中添加内容时,发现不能调整大小,只有一个小框(图片在二楼)
不知如何解决?

import wx

class OverWatching(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'OverWatching',
                          size=(900, 600),
                          style=wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
        panel = wx.Panel(self)
        panel.SetBackgroundColour("White")
        self.Center()            # 令窗口在屏幕中居中显示
        self.tb = TestTB(self, -1)
        # -----创建状态栏------
        self.userStatus = self.CreateStatusBar()
        self.userStatus.SetFieldsCount(5)                   # 将状态栏分为5部分
        self.userStatus.SetStatusWidths([-1, -1, -1, -1, -1])  # 划分比例为5等分
        # 状态栏上待显示的文字
        statusLabel = [
            u' 主机名:',
            u' 用户个数:',
            u' 当前用户:',
            u' 系统启动时间:',
            u' 软件版本号:',
        ]
        # 将文字标签显示在状态栏上
        for i in range( len(statusLabel) ):
            self.userStatus.SetStatusText( statusLabel[i], i )

    #事件响应
    def OnPageChanged(self, event):
        old = event.GetOldSelection()
        new = event.GetSelection()
        sel = self.tb.GetSelection()
        print 'OnPageChanged,  old:%d, new:%d, sel:%d\n' % (old, new, sel)
        event.Skip()
        self.tb.Bind(wx.EVT_TOOLBOOK_PAGE_CHANGED, self.OnPageChanged)

class TestTB(wx.Toolbook):
    def __init__(self, parent, id):
        wx.Toolbook.__init__(self, parent, id, size = (900,550),  style = wx.BK_DEFAULT)   #注意:size一定要设置,我在次纠结了一个下午才发现问题
        il = wx.ImageList(48, 48)    #建议跟图像的大小一致
        bmp0 = wx.Image('icon\\0.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()   #图像的路径为相对路径,也可以设置成绝对路径
        bmp1 = wx.Image('icon\\1.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        bmp2 = wx.Image('icon\\2.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        bmp3 = wx.Image('icon\\3.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        bmp4 = wx.Image('icon\\4.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        index0 = il.Add(bmp0)
        index1 = il.Add(bmp1)
        index2 = il.Add(bmp2)
        index3 = il.Add(bmp3)
        index4 = il.Add(bmp4)
        print index4
        print il.GetImageCount()
        self.AssignImageList(il)
        #p = newPanel(None)
        pag1 = PageOne(self)
        pag1.SetBackgroundColour(wx.Colour(166, 255, 166))
        self.AddPage(pag1, "System Info".decode('utf-8'), imageId=index0)
        pag2 = PageTwo(self)

        self.AddPage(pag2, "Intranet Found ", imageId=index1)
        pag3 = PageThree(self)
        pag3.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.AddPage(pag3, "PC Resolution", imageId=index2)
        pag4 = PageFour(self)
        pag4.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.AddPage(pag4, "Network Resolution", imageId=index3)
        pag5 = PageFive(self)
        pag5.SetBackgroundColour(wx.Colour(0, 0, 0))
        self.AddPage(pag5, "Port Scan", imageId=index4)

class PageOne(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel,-1, "hello", pos=(1, 1))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()


    def OnClick(self,event):
        self.button.SetLabel("Clicked")

 


class PageTwo(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, size=(840,450))
        self.panel = wx.Panel(self)

 

class PageThree(wx.Panel):
    def __init__(self, parent):
         wx.Panel.__init__(self, parent)
         panel = wx.Panel(self)
         colour = [(160,255,204),(153,204,255),(151,253,225),]
         self.SetBackgroundColour(colour[0])
         self.center = wx.StaticText(self, -1, "使用说明", (355, 35),
                (100, -1), wx.ALIGN_CENTER)
         font = wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)
         self.center.SetFont(font)

class PageFour(wx.Panel):
    def __init__(self, parent):
         wx.Panel.__init__(self, parent)
         panel = wx.Panel(self)
         colour = [(160,255,204),(153,204,255),(151,253,225),]
         self.SetBackgroundColour(colour[0])
         self.center = wx.StaticText(self, -1, "使用说明", (355, 35),
                (100, -1), wx.ALIGN_CENTER)
         font = wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)
         self.center.SetFont(font)

class PageFive(wx.Panel):
    def __init__(self, parent):
         wx.Panel.__init__(self, parent)
         panel = wx.Panel(self)
         colour = [(160,255,204),(153,204,255),(151,253,225),]
         self.SetBackgroundColour(colour[0])
         self.center = wx.StaticText(self, -1, "使用说明", (355, 35),
                (100, -1), wx.ALIGN_CENTER)
         font = wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)
         self.center.SetFont(font)

if __name__ == "__main__":
    app = wx.App()
    frame = OverWatching()
    frame.Show()
    app.MainLoop()
----------------------------------------------------------------------------
class PageOne(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel,-1, "hello", pos=(1, 1))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()
 
        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.panel, 1, wx.EXPAND)
        self.SetSizer(self.sizer)

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。