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.

有帮助吗?

解决方案

A fast trick:

  1. In the place your widget should be, insert an wx.Panel with wxGlade and give it the name mymediactrl instead of, for example, mypanel.
  2. Then, after you have your script generated, import (or insert the code of) 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).
  3. Finally, modify manually the mymediactrl=wx.Panel(...) line in the script with your mymediactrl = MediaControl(...) line. Note: This line must be maintained manually when you 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.

enter image description here

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top