Hi wxPython users,
I have been wondering if there is interest in the wxpython community to have custom widgets and a stylesheet language for styling them.
WxPython is great for native GUIs and is honestly the best GUI toolkit I’ve used, however it seems that wxPython isn’t so good for custom GUIs (and obviously, it’s because it’s made for native).
It seems like questions about custom GUIs get asked and wxpython should have a better solution than AUI (not that AUI isn’t customizable as-is) or (for example) “you’ll have to create that from scratch in order to change the border thickness on that widget”.
My idea is to make a custom-widget set and stylesheet language, inspired by CSS, to where the widget styles can be controlled by an external/inline stylesheet.
I know this isn’t exactly the first attempt to do something like this, but I do believe it’s worth another try.
Now, I know that there are those who aren’t in favor of customized widgets, etc, but please hear me out. Native works for a lot of UIs, but for some applications and use-cases it really is needed and it would be great to make creating customized GUIs with wxpython easier. I can see this opening up a lot of use cases and a lot more people using wxpython because of it. And I do want to see wxpython grow: Why should QT users have all the fun with customized GUIs?
Also, I realize that there is getting to be many more “pure-python widgets” now incuded in wxpython -and this is great. I think this makes for a good opportunity to take those widgets and make the styles controllable via a stylesheet.
This is something I’ve been thinking about since I started using wxpython and have even done some experiments with this (though, not fully realized) in my experimental UI Style Lang project.
Here is an experimental demo example, with UI Style Lang (the custom button demo in the repository):
/* button */
@style button {
background-color: #F4F4F4;
top: 20px;
left: 40px;
width: 115px;
height: 35px;
border-color: #D1D1D1;
border-size: 2px;
}
@style button:hover {
background-color: #FDFDFD;
top: 20px;
left: 40px;
width: 115px;
height: 35px;
border-color: #D1D1D1;
border-size: 2px;
}
@style button:press {
background-color: #D1D1D1;
top: 20px;
left: 40px;
width: 115px;
height: 35px;
border-color: #D1D1D1;
border-size: 2px;
}
Result (button changes color when hovered and clicked, etc):
Now, obviously, the current demo is drawn to a wx.PsuedoDC, but the idea is that the button would be a widget itself and style-able.
Questions you may wonder:
What about actually implementing this? That’s part of the reason I am writing this: in order for this to be implemented we need more than just me doing it.
- If you’re a wxpython user you already have the skills to help out as you know python and wxpython (I don’t see any need for additional skills to help develop this project at the present moment).
- If you’re not a wxpython user, but want this functionality, then you can probably still help as you probably know python and at least want to know wxpython.
Now, what about maintenance? Indeed this would take a bit of work to update for new releases, but I think it’s worth it if enough people are interested in using it. So, if you’d be interested in potentially using this project (saying it was implemented), it would be great to know that as well.
So, constructive feedback is welcome! I realize I may have not thought of everything, so please let me know.
Please let me know if you’d be interested in developing and/or using this for your wxpython project(s) as well or if there is an alternative that would be better. @robin, I’d especially like to know your thoughts, if possible. Thanks!