wx python 位图/切换/菜单按钮
我需要一个带有位图、切换开关的按钮,并且可以在其中添加菜单(我意识到这要求很高)。我无法找到在 wx python 中执行此操作的方法。以下是我尝试过的方法以及它们不起作用的原因:
板按钮:不要切换
genbitmaptogglebuttons:由于某种原因,这些按钮杀死了我的工具提示(我之前发布了这个问题,但从未得到答案)
工具栏按钮:可以不要向按钮添加下拉菜单。我会为下拉菜单制作一个单独的按钮,但工具栏必须垂直定向,而且我不知道如何让下拉按钮显示在其相应按钮旁边,而不是在其下方带有垂直工具栏方向。
位图按钮:不会切换
我是否遗漏了一些明显的东西?如果没有,我只会通过更改边框/背景颜色来伪造切换,除非有人有更好的建议。
谢谢。
I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot). I can't figure out a way to do this in wx python. Here are the things I've tried and why they don't work:
plate buttons: don't toggle
genbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I posted this problem earlier and never got an answer)
toolbar buttons: can't add a drop down menu to a button. I would make a separate button for the drop down menu, but the toolbar has to be oriented vertically, and I don't know how to get the drop down button to show up beside its corresponding button, rather than beneath it with vertical a toolbar orientation.
bitmap buttons: won't toggle
Am I missing something obvious? If not I'm just going to resort to faking a toggle by changing the border/background color, unless someone has a better suggestion.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有看到具有所有这些功能的预构建按钮。我认为您可以使用通用切换按钮或 ShapedButton 来实现位图切换功能,并附加右键单击弹出菜单。我不太确定你所说的菜单是什么意思,所以这可能不起作用。如果您正在谈论类似于 PlateButton 的菜单实现,那么您可能必须滚动自己的按钮。 wxPython 邮件列表上的人可以告诉你如何做到这一点。
I don't see a pre-built button with all those features. I would think that you can use the generic toggle button or maybe the ShapedButton for your bitmap toggle functionality and attach a right-click popup menu. I'm not really sure what you mean by a menu, so that may not work. If you're talking about a menu implementation similar to the one that the PlateButton has, then you'll probably have to roll your own button. The guys on the wxPython mailing list can tell you how to do that.
根据 Mark 的建议,如果您有 wx 2.8.12,您可以使用面板按钮来获取切换/位图/菜单功能。由于此时更新到较新的 wx 对我来说并不容易,因此我将使用位图按钮并伪造切换开关。
Per Mark's suggestion, if you have wx 2.8.12 you can use a plate button to get the toggle/bitmap/menu functionality. Since it is not easy for me to update to the newer wx at this point, I'll use a bitmap button and fake the toggle.