如何在wxglade中添加自定义小部件
我有一个用 wxglade 制作的应用程序。我添加了一个媒体控件以便能够播放 mp3:s。如果没有媒体控制,应用程序将以 800x600px 的框架启动。但是当我添加媒体控件时,框架非常小。我相信这是因为我没有将其添加到 sizer 中。但我必须这样做吗?无论如何,媒体控件不应该显示任何内容。
所以,我的问题是,如何向我的应用程序添加媒体控件,而不(a)破坏使用wxglade更新GUI的可能性,并且(b)失去更新GUI的能力从合适的尺寸开始?
如果可以的话,我不会在 # Begin wxglade
和 # End wxglade
之间放置任何内容。因为如果我用 wxglade 更改我的 gui(无论如何根据早期的测试),它就会被破坏。
编辑:我提供的代码片段没有添加任何有趣的内容。我还编辑了问题以使其更加清晰,以便其他有相同问题的人可以找到答案。
I have an app that I made with wxglade. I've added a mediacontrol to be able to play mp3:s. Without the mediacontrol the app starts with a frame that is 800x600px. But when I add the mediacontrol, the frame is very small. I believe this is because I've not added it to a sizer. But do I have to do that? The mediacontrol isn't supposed to show anything anyways.
So, my question is, how do I add a mediacontrol to my app without (a) breaking the possibility of updating the gui with wxglade and (b) losing the ability to start with the right size?
If I can I would not put anything between the # Begin wxglade
and # End wxglade
. Because then it will be destroyed if I change my gui with wxglade (according to earlier tests anyway).
Edit: The code snippet I supplied doesn't add anything of interest. I also edited the question to be more clear so other people with the same question can find this answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个快速技巧:
wx.Panel
并将其命名为
mymediactrl
,而不是mypanel
。您的 MediaControl 类位于 wxglade 允许(不可写)的位置
(在由“# begin wxGlade”分隔的部分之外的空间中,并且
'# end wxGlade' 标签)。
mymediactrl=wx.Panel(...)
行mymediactrl = MediaControl(...)
行。注意:此线必须手动维护你修改你的GUI,因为wxglade会重写它。
正确的方法:
你可以使用wxglade小部件集的CustomWidget小部件。
如果您有 wxglade 经验,这是推荐的方法。
专业方法:
您可以将自己的自定义小部件添加到 wxglade 小部件中放。
您有如何操作的一些示例和教程
A fast trick:
wx.Panel
with wxGladeand give it the name
mymediactrl
instead of, for example,mypanel
.your MediaControl class in a place allowed (non-writable) by wxglade
(in the space outside the sections delimited by '# begin wxGlade' and
'# end wxGlade' tags).
mymediactrl=wx.Panel(...)
line in the script with yourmymediactrl = MediaControl(...)
line. Note: This line must be maintained manually whenyou modify your GUI because wxglade will rewrite it.
The correct way:
You can use the CustomWidget widget of the wxglade widget set.
This is the recommended method if you have experience with wxglade.
The Pro method:
You can add your own custom widget to the wxglade widget set.
You have some example and a tutorial of how to do it here