Wx. Boxsizer

Source: Internet
Author: User

Transferred from: http://wwty.iteye.com/blog/385519

Wx. Boxsizer:

Python code
    1. box = WX. Boxsizer (integer orient)

The orientation can be wx. VERTICAL or WX. Horizontal

Python code
    1. Box. ADD (WX. Window window, integer proportion=0, Integer flag = 0, Integer border = 0)

Parameter interpretation:

1, proportion:

The proportion parameter defines the proportion of the component's space in the given direction, relative to the other components
For example: We have three buttons, the values of proportion are 0,1,2 respectively. The three buttons are placed in the horizontal Sizer, button with proportion 0 is not the change in all. However, the Button with proportion 2 will be twice times larger than the one with proportion 1 in horizontal position.

Python code
  1. Import WX
  2. Class Border (WX. Frame):
  3. def __init__ (self, parent, ID, title):
  4. Wx. Frame.__init__ (self, parent, ID, title, size= (+ ))
  5. panel = WX. Panel (self,-1,size= (+))
  6. Panel. Setbackgroundcolour (' white ')
  7. Boxsizer1 = wx. Boxsizer (WX. VERTICAL)
  8. BTN1 = wx. Button (Panel,-1, ' Botton1 ')
  9. BTN2 = wx. Button (Panel,-1, ' Botton2 ')
  10. Btn3 = wx. Button (Panel,-1, ' Botton3 ')
  11. Boxsizer1. ADD (btn1, proportion=0, Flag=wx. EXPAND, border=0)
  12. Boxsizer1. ADD (BTN2, proportion=1, flag=wx. All, border=0)
  13. Boxsizer1. ADD (Btn3, proportion=2, flag=wx. All, border=0)
  14. Self . Setsizer (Boxsizer1)
  15. Self . Centre ()
  16. Self . Show (True)
  17. App = WX. APP ()
  18. Border (None,-1, ')
  19. App. Mainloop ()

This example can be used to observe the effect of the proportion parameter.

2. Flag:

The flag parameter can use ' | ' To produce a combination of multiple flags.

The flag parameter defines two main behaviors:

The first parameter is the border of the window: This parameter determines the width of the border, which determines the event where a border is added to one side of the window.

Another parameter determines the behavior of the Sizer event, and when Sizer changes, the space is allocated. And how much of the allocation depends on a particular kind of sizer is used.

3, border:
Determines the border width, if the flag parameter is set to include any border flag

Finally, special note:

Flag and border parameters are used together.
VBox. ADD (Midpan, 1, WX. EXPAND | Wx. All, 20)
Flag=wx. EXPAND | Wx. All,border=20---------This represents the Midpan this component will make full use of space, but will be reserved from around 20px as border. So if we say that WX is used. EXPAND flag, instead of setting border, our component will take full advantage of the allocated space.

Finally, we can also define the adjustment of our components. However, this adjustment refers to an adjustment within the space allocated by the Sizer to the current component.

We do it with the following flags:
Wx. Align_left
Wx. Align_right
Wx. Align_top
Wx. Align_bottom
Wx. Align_center_vertical
Wx. Align_center_horizontal
Wx. Align_center

Take a look at the following example:

Python code
    1. hbox5 = wx. Boxsizer (WX. Horizontal)   
    2. btn1 = wx. button (Panel, -1, 70 ,  30))   
    3. hbox5. ADD (Btn1, 0)   
    4. btn2 = wx. button (Panel, -1,  ' Close ',  size= ( 70, 30)   
    5. hbox5. ADD (Btn2, 0, wx. Left | wx. Bottom , 5)   
    6. vbox. ADD (Hbox5, 0, wx. Align_right | wx. Right, 10)   

This example places the existing hbox5 into VBox when total, while wx. Align_right's role is to place the hbox5 in the Sizer.

The following are the common flag parameters:

1. These flags is used to specify which side (s) of the Sizer item, the border width would apply to.

    • Wx. TOP
    • Wx. BOTTOM
    • Wx. Left
    • Wx. Right
    • Wx. All

2. The item is expanded to fill the space allotted to the item.

Wx. EXPAND

There are two other not listed, if used, you can check the Help document

Finally, there are some cases where we need to add some blank areas to our application, and we can use the following code:

Python code
    1. VBox = wx. Boxsizer (WX. VERTICAL)
    2. VBox. ADD ((-1, + ))

VBox. Add (( -1))---added 25 pixels of empty space

Wx. Boxsizer

Related Keywords:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.