wxPython控制項學習之wx.BoxSizer

來源:互聯網
上載者:User
wx.BoxSizer:
1.建構函式 boxSizer = wx.BoxSizer(integer orient) orient可以是wx.VERTICAL or wx.HORIZONTAL

2.向sizer裡面增加一個控制項。box.Add(wx.Window window, integer proportion=0, integer flag = 0, integer border = 0)

主要參數: 

  1.proportion:proportion參數定義了構件在既定方向上所佔空間的比例,是相對的,相對於其他組件
  2、flag:

  常用的flag參數:

   調整對其方式的flag: 

    wx.ALIGN_LEFT 
  wx.ALIGN_RIGHT 
  wx.ALIGN_TOP 
  wx.ALIGN_BOTTOM 
  wx.ALIGN_CENTER_VERTICAL 
  wx.ALIGN_CENTER_HORIZONTAL 
  wx.ALIGN_CENTER

  • wx.TOP, wx.BOTTOM, wx.LEFT, wx.RIGHT, wx.ALL





#-------------------------------------------------------------------------------# Name: 1# Purpose:## Author: ankier## Created: 13/09/2012# Copyright: (c) ankier 2012# Licence: <your licence>#-------------------------------------------------------------------------------import wxclass Border(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size =(800,600)) pane = wx.Panel(self, -1, size =(800,600)) pane.SetBackgroundColour('yellow') boxsizer = wx.BoxSizer(wx.HORIZONTAL) btn1 = wx.Button(pane, -1, 'Botton1') btn2 = wx.Button(pane, -1, 'Botton2') btn3 = wx.Button(pane, -1, 'Botton3') boxsizer.Add(btn1, proportion=0, flag=wx.ALL, border=2) boxsizer.Add(btn2, proportion=1, flag=wx.ALL, border=2) boxsizer.Add(btn3, proportion=2, flag=wx.ALL, border=2) self.SetSizer(boxsizer) self.Centre() self.Show(True)def main(): app = wx.App() Border(None, -1, '') app.MainLoop()if __name__ == '__main__': main()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.