简体   繁体   English

调整wxPython小部件的大小

[英]Resizing wxPython Widgets

How do I change the size of wxPython widget after its creation? 如何在创建后更改wxPython小部件的大小? I am trying to dynamically change the width of a ComboBoxCtrl widget based on the elements in the popup. 我试图根据弹出窗口中的元素动态更改ComboBoxCtrl小部件的宽度。 For the sake of simplicity lets say we create a button and try to resize it: 为简单起见,我们假设我们创建一个按钮并尝试调整它的大小:

btn = wx.Button(self, wx.ID_ANY, 'Start', size=(25,-1))
btn.SetSize(wx.Size(25,25))

self.Layout()

In the above case, the new 25x25 size does not take. 在上述情况下,新的25x25尺寸不需要。 I can only get SetSize to work for a panel. 我只能让SetSize适用于面板。 I am assuming there is another call I should be using. 我假设还有另一个我应该使用的电话。 How can I change the size of widget after creation? 如何在创建后更改窗口小部件的大小?

The SetMinSize command does the trick. SetMinSize命令可以解决这个问题。

btn = wx.Button(self, wx.ID_ANY, 'Start', size=(25,-1))
btn.SetMinSize(wx.Size(25,25))

self.Layout()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM