boxsizer = wx.BoxSizer(integer origent)


box.Add(wx.Window window, integer proportion=0, integer flag = 0, integer border = 0)
  • proportion参数表示控件在既定方向所占空间的比例,相对于其他控件
  • flag参数定义了对齐方式及外边距border的作用对象
  • border定义了外边距的统一值


  • 对齐标签如下:


  • box中statictext的对齐规则:当box方向是wx.HORIZONTAL水平时且垂直方向有未被控件占用的panel空间时,wx.ALIGN_CENTER为垂直方向居中,因水平方向要么有其它控件,要么或是被自身占满;是wx.VERTICAL时且水平方向有未被占用的panel空间时,wx.ALIGN_CENTER为水平方向居中,同理
  • statictext自身的对齐规则:水平方向被扩展时,wx.ALIGN_CENTER为水平方向居中;垂直方向被扩展时,wx.ALIGN_CENTER为垂直方向居中。


  • 以上5个为边界标签,边界值设置要注意情形,通过设置wx.ALL可以达到水平和垂直方向同时居中,前提是四边的border设置都有效


  • box中是作用于居中控件,statictext中是作用于居中文字
  • 设置控件比例大小的指定边间距的前提条件是该边与其它控件比例大小边界间距为0,或是该边与panel边界间距为0。否则设置无效
  • 注意:分清控件实际大小,通过设置proportion值之后的比例大小,panle中未被控件占用的空间(即除去控件比例占用)。比如将一个大小(19, 7)的statictext添加到panel的唯一box中:若box为水平,proportion默认,那么所占比例大小就是实际大小,只有wx.UP、wx.LEFT的border设置有效;若proportion设为1,则比例大小为(panel长度, 7),这时wx.UP、wx.LEFT、wx.RIGHT的border设置有效;若flag添加wx.EXPAND标签,则四边都有效。

Window identifiers

wx.Button(parent, -1)
wx.Button(parent, wx.ID_ANY)

If we provide -1 or wx.ID_ANY for the id parameter, we let the wxPython automatically create an id for us. The automatically created id's are always negative, whereas user specified id's must always be positive. We usually use this option when we do not need to change the widget state. For example a static text that will never be changed during the life of the application. We can still get the id if we want. There is a method GetId(), which will determine the id for us.


This simple class provides a simple way to avoid flicker: when drawing on it, everything is in fact first drawn on an in-memory buffer (a wx.Bitmap) and then copied to the screen only once, when this object is destroyed. You can either provide a buffer bitmap yourself, and reuse it the next time something needs painted, or you can let the buffered DC create and provide a buffer bitmap itself.
Buffered DCs can be used in the same way as any other device context. wx.BufferedDC itself typically replaces wx.ClientDC, if you want to use it in your EVT_PAINT handler, you should look at wx.BufferedPaintDC. You can also use a wx.BufferedDC without providing a target DC. In this case the operations done on the dc will only be written to the buffer bitmap and not to any window, so you will want to have provided the buffer bitmap and then reuse it when it needs painted to the window.

__init__(self, dc, buffer=NullBitmap, style=BUFFER_CLIENT_AREA)
dc - The underlying DC: everything drawn to this object will be flushed to this DC when this object is destroyed. You may pass None in order to just initialize the buffer, and not flush it.

standard ID

Menus for standard IDs didn't dispaly on Mac,wx.ID_EXITwx.ID_ABOUT...using the ID defined by youself.

The menu was appearing in the "taskbar" or something because the OS had been configured for that, kind of like a Mac.





最后由 oucb 编辑于2016年05月04日 13:18