Python体验(08)-Pannel和Sizer

Posted 许明会的计算机技术主页

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python体验(08)-Pannel和Sizer相关的知识,希望对你有一定的参考价值。

 

import wx
class Form(wx.Frame):
    def __init__(self,parent,ID,title):
        wx.Frame.__init__(self,parent,ID,title)
        panel = wx.Panel(self,-1)

        wx.Button(panel,-1,"Button1",(0,0))
        wx.Button(panel,-1,"Button2",(80,0))
        wx.Button(panel,-1,"Button3",(160,0))

class App(wx.App):
    def OnPreInit(self):
        form = Form(None,-1,"Panel Layout")
        form.Show()
        form.Centre()

app = App()
app.MainLoop()

 

import wx
class MyFrame( wx.Frame ):  
    def __init__( self, parent, id, title ):
        wx.Frame.__init__( self, parent, id, title )
        pnl1 = wx.Panel( self, -1, style=wx.SIMPLE_BORDER )
        pnl2 = wx.Panel( self, -1, style=wx.RAISED_BORDER )
        pnl3 = wx.Panel( self, -1, style=wx.SUNKEN_BORDER )
        pnl4 = wx.Panel( self, -1, style=wx.DOUBLE_BORDER )
        pnl5 = wx.Panel( self, -1, style=wx.STATIC_BORDER )
        pnl6 = wx.Panel( self, -1, style=wx.NO_BORDER )

        hbox1 = wx.BoxSizer( wx.HORIZONTAL )
        hbox1.Add( pnl1, 1, wx.EXPAND | wx.ALL, 3 )
        hbox1.Add( pnl2, 1, wx.EXPAND | wx.ALL, 3 )
        hbox1.Add( pnl3, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2 = wx.BoxSizer( wx.HORIZONTAL )
        hbox2.Add( pnl4, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2.Add( pnl5, 1, wx.EXPAND | wx.ALL, 3 )
        hbox2.Add( pnl6, 1, wx.EXPAND | wx.ALL, 3 )
        vbox=wx.BoxSizer(wx.VERTICAL)
        vbox.Add( hbox1, 1, wx.EXPAND )
        vbox.Add( hbox2, 1, wx.EXPAND )
        self.SetSizer( vbox )
        self.Centre()

class MyApp( wx.App ):  
    def OnInit( self ):
        frame = MyFrame( None, -1, borders.py )
        frame.Show( True )
        return True

app = MyApp()
app.MainLoop()  

 

以上是关于Python体验(08)-Pannel和Sizer的主要内容,如果未能解决你的问题,请参考以下文章

用C# winForm,一个pannel容器上有许多label,怎样才能使得鼠标点击label时触发的pannel事件呢?

C# 如何在pannel控件中加载子窗口(form)

Smart Text Re sizer ala jQuery(和cookies)

wxpython的布局方式

Rviz 实现 pannel 插件

Pannel中的窗体跳转(C#的Winform)