How to add custom widgets to wxglade

I have an application that I made with wxglade. I added mediacontrol to play mp3: s. Without mediacontrol, an application starts with a frame of 800x600px. But when I add mediacontrol, the frame is very small. I believe this is because I did not add it to the sizer. But do I need to do this? Media control should not show anything.

So my question is: how to add mediacontrol to my application without (a) violating the ability to update gui using wxglade and (b) , losing the ability to start from the right size?

If I can, I would not put anything between # Begin wxglade and # End wxglade . Because then it will be destroyed if I change my gui with wxglade (according to earlier tests).

Edit: The code snippet I provided does not add anything interesting. I also edited the question to be more clear so that other people with the same question could find this answer.

+4
source share
1 answer

Quick trick:

  • In the place where your widget should be, insert wx.Panel with wxGlade and give it the name mymediactrl instead of, for example, mypanel .
  • Then, after you have created your script, import (or paste the code) your MediaControl class in a place that is allowed (not writable) by wxglade (in the space outside of the sections separated by '# begin wxGlade' and '# end wxGlade').
  • Finally, manually change the line mymediactrl=wx.Panel(...) in the script using mymediactrl = MediaControl(...) . Note. This line must be maintained manually if you change your GUI because wxglade will rewrite it.

The right 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

Pro Method:

You can add your own widget to the wxglade widget set. You have an example and tutorial on how to do it here.

+4
source

Source: https://habr.com/ru/post/1392042/


All Articles