调整 wxPython 小部件的大小 [英] Resizing wxPython Widgets

查看:53
本文介绍了调整 wxPython 小部件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在创建 wxPython 小部件后更改其大小?我正在尝试根据弹出窗口中的元素动态更改 ComboBoxCtrl 小部件的宽度.为简单起见,假设我们创建一个按钮并尝试调整其大小:

How do I change the size of wxPython widget after its creation? I am trying to dynamically change the width of a ComboBoxCtrl widget based on the elements in the popup. 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()

在上述情况下,新的 25x25 尺寸不带.我只能让 SetSize 为面板工作.我假设我应该使用另一个电话.创建后如何更改小部件的大小?

In the above case, the new 25x25 size does not take. I can only get SetSize to work for a panel. I am assuming there is another call I should be using. How can I change the size of widget after creation?

推荐答案

SetMinSize 命令可以解决问题.

The SetMinSize command does the trick.

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

self.Layout()

这篇关于调整 wxPython 小部件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆