如何使wx工具栏按钮变大?

发布于 2024-07-11 16:23:55 字数 115 浏览 4 评论 0原文

我有一个 wx.Toolbar,我想让按钮更大。 我进行了搜索,似乎找不到任何有关如何执行此操作的具体文档。

我还想知道这在跨平台上的翻译效果如何; OSX 上的按钮和图标会发生什么变化?

I've got a wx.Toolbar and I'd like to make the buttons larger. I've searched and can't seem to find any concrete documentation on how to do this.

I'm also wondering how well this will translate across platforms; what will happen to the buttons and icons on OSX?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱娆 2024-07-18 16:23:55

这取决于您想要更改的内容:是按钮的大小还是图标的大小?

要更改按钮的大小,请使用 SetToolBitmapSize (例如 24x24)

toolbar.SetToolBitmapSize((24, 24))

:不过,只会改变按钮的大小。 如果您想更改图标的大小,只需使用更大的图标即可。 最简单的方法是使用 wx.ArtProvider

wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (24, 24))

所以,总结一下:

# Define the size of the icons and buttons
iconSize = (24, 24)

# Set the size of the buttons
toolbar.SetToolBitmapSize(iconSize)

# Add some button
saveIcon = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, iconSize)
toolBar.AddSimpleTool(1, saveIcon, "Save", "Save current file")

备注:由于SetToolBitmapSize更改的是按钮的大小,而不是图标的大小,因此您可以将按钮设置为大于图标。 这应该在图标周围留下空白区域。

It depends on what you want to change: is it the size of the buttons or the size of the icons ?

To change the size of the buttons, use SetToolBitmapSize (24x24 for instance):

toolbar.SetToolBitmapSize((24, 24))

This will only change the size of the buttons, though. If you want to change the size of the icons, simply use bigger ones. The easiest way is to use wx.ArtProvider:

wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (24, 24))

So, summing it up:

# Define the size of the icons and buttons
iconSize = (24, 24)

# Set the size of the buttons
toolbar.SetToolBitmapSize(iconSize)

# Add some button
saveIcon = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, iconSize)
toolBar.AddSimpleTool(1, saveIcon, "Save", "Save current file")

Remark: As SetToolBitmapSize changes the size of the buttons, not the size of the icons, you can set the buttons to be larger than the icons. This should leave blank space around the icons.

╄→承喏 2024-07-18 16:23:55

工具栏的大小不会自动适应位图图标的大小吗? 我认为如果你想要一个更大的工具栏,你需要更大的位图。

Doesn't the size of the toolbar adapts itself automatically to the size of the bitmap icons? I think if you want a bigger toolbar, you need bigger bitmaps.

动次打次papapa 2024-07-18 16:23:55

在 Mac OS X Big Sur 上运行 python 3.9 和 wxpython 4.1.1。 这个电话

toolbar.SetToolBitmapSize((24, 24))

不起作用。 该算法似乎是与工具栏关联的图标的算法,wxPython 选择最大的一个并为所有其他图标设置该大小。

On Mac OS X Big Sur running python 3.9 and wxpython 4.1.1. this call

toolbar.SetToolBitmapSize((24, 24))

does not work. The algorithm seems to be that of the icons associated with the toolbar wxPython picks the largest one and sets that size for all the other icons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文