I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
TIA
Travis Griggs
"History has a habit of changing the people who think they are changing it." -- Sir Terry Pratchett
There are plenty of custom controls in the wx.lib package that you could learn from. Some simple ones to start with would be stattext.py and statbmp.py
···
On 8/31/12 4:59 PM, Travis Griggs wrote:
I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
if mention_platform_and_version() and include_sample_app():
send_message(email)
else:
install_malware()
erase_hard_drives()
# ------------------------------------------------------------- #
···
On 2 September 2012 01:11, Robin Dunn wrote:
On 8/31/12 4:59 PM, Travis Griggs wrote:
I made a little one window app with wxpython, a couple of buttons and
lists, etc. It was a month or so ago, the irc channel was really helpful. It
went great.
Now I want to make an app that doesn't use any standard widgets (well,
maybe a menu bar eventually), but just has a custom full window graphic that
draws some stuff and has some mouse interaction. Is there a good starting
place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file
that was a pattern I could just use as a boilerplate.
There are plenty of custom controls in the wx.lib package that you could
learn from. Some simple ones to start with would be stattext.py and
statbmp.py
So I used those and some of the others and made some progress. I'm particularly interested in being able to do GraphicsContext stuff, it's Cairo-like, and I'm very used to that. I got something to draw, but not what I expected. I think I'm missing something simple/fundamental.
What I expected was two top to bottom stripes, 100 pixels wide each.
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
TIA
Travis Griggs
"Coming back to where you started is not the same as never leaving." -- Sir Terry Pratchett
···
On Sep 1, 2012, at 3:11 PM, Robin Dunn wrote:
On 8/31/12 4:59 PM, Travis Griggs wrote:
I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
There are plenty of custom controls in the wx.lib package that you could learn from. Some simple ones to start with would be stattext.py and statbmp.py
I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
There are plenty of custom controls in the wx.lib package that you could learn from. Some simple ones to start with would be stattext.py and statbmp.py
Thanks Robin!
So I used those and some of the others and made some progress. I'm particularly interested in being able to do GraphicsContext stuff, it's Cairo-like, and I'm very used to that. I got something to draw, but not what I expected. I think I'm missing something simple/fundamental.
What I expected was two top to bottom stripes, 100 pixels wide each.
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
Almost every time you build a custom control, it's a goof idea to
override the DoGetBestSize method. If you want your control to be
correctly sized and (possibly) managed by sizers, thats the way to go.
And to finish up the custom control should probably call SetInitialSize in its __init__ so it can set itself to the best size or the passed in size if one was given.
Or you can just manually set the size of the control after you've created it. Or put it in a sizer with parameters that will cause it to be expanded to fill the parent if that's what you want it to do. Or any combination of the above.
···
On 9/6/12 10:37 PM, Andrea Gavana wrote:
Hi,
On 7 September 2012 02:17, Travis Griggs wrote:
On Sep 1, 2012, at 3:11 PM, Robin Dunn wrote:
On 8/31/12 4:59 PM, Travis Griggs wrote:
I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
There are plenty of custom controls in the wx.lib package that you could learn from. Some simple ones to start with would be stattext.py and statbmp.py
Thanks Robin!
So I used those and some of the others and made some progress. I'm particularly interested in being able to do GraphicsContext stuff, it's Cairo-like, and I'm very used to that. I got something to draw, but not what I expected. I think I'm missing something simple/fundamental.
What I expected was two top to bottom stripes, 100 pixels wide each.
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
Almost every time you build a custom control, it's a goof idea to
override the DoGetBestSize method. If you want your control to be
correctly sized and (possibly) managed by sizers, thats the way to go.
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
But it still draws just one box that is about 20x20
It also begs the question… what do you do when there is no real "best size" for a control? If there's no static assets (such as characters) or bitmaps, it's just a bunch of vector drawing and you want it to be as big as the parent is willing to let it be (in this case the whole frame), then there is no real best minimum or maximum size.
Travis Griggs
"Coming back to where you started is not the same as never leaving." -- Sir Terry Pratchett
···
On Sep 6, 2012, at 10:37 PM, Andrea Gavana wrote:
Hi,
On 7 September 2012 02:17, Travis Griggs wrote:
On Sep 1, 2012, at 3:11 PM, Robin Dunn wrote:
On 8/31/12 4:59 PM, Travis Griggs wrote:
I made a little one window app with wxpython, a couple of buttons and lists, etc. It was a month or so ago, the irc channel was really helpful. It went great.
Now I want to make an app that doesn't use any standard widgets (well, maybe a menu bar eventually), but just has a custom full window graphic that draws some stuff and has some mouse interaction. Is there a good starting place example, or easy 10,000 foot explanation about how to start?
What I would love is if someone could point me at a simple/single .py file that was a pattern I could just use as a boilerplate.
There are plenty of custom controls in the wx.lib package that you could learn from. Some simple ones to start with would be stattext.py and statbmp.py
Thanks Robin!
So I used those and some of the others and made some progress. I'm particularly interested in being able to do GraphicsContext stuff, it's Cairo-like, and I'm very used to that. I got something to draw, but not what I expected. I think I'm missing something simple/fundamental.
What I expected was two top to bottom stripes, 100 pixels wide each.
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
Almost every time you build a custom control, it's a goof idea to
override the DoGetBestSize method. If you want your control to be
correctly sized and (possibly) managed by sizers, thats the way to go.
That's very nice! I was able to use that, learned about dir() to figure out what PyControl could do for me, used PyCrust to SetSize() and was able to see the result. Very nice. Now I think I just need to understand the whole layout stuff better. I used the sizers in my first app, but I don't think I really *got* them, especially at what I need to do at the implementor side (not just the consumer).
···
On Sep 7, 2012, at 12:15 AM, Robin Dunn wrote:
On 9/6/12 4:17 PM, Travis Griggs wrote:
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
My hunch though, is that the "size" of my PlayDraw control is being set to some default size. I wasn't sure how to test this though, because when browsing the online docs for PyControl, all I see is a bunch of methods that say use something else. I'm not sure how a control finds out what his current dimensions are. And past that, is there no way to tell the control to just be the same size as it's root parent? Or is the reason it draws only a small amount something completely different?
That's very nice! I was able to use that, learned about dir() to figure out what PyControl could do for me, used PyCrust to SetSize() and was able to see the result. Very nice. Now I think I just need to understand the whole layout stuff better. I used the sizers in my first app, but I don't think I really *got* them, especially at what I need to do at the implementor side (not just the consumer).
This is a little out of date, but is still useful for learning about the various kinds of size and the methods that set them.
Basically what was happening in your example is that the widget was not being explicitly set to any particular size, and it wasn't being put into a sizer or other situation that would automatically manage the size, so it was left at the default.
It also begs the question� what do you do when there is no real "best size" for a control? If there's no static assets (such as characters) or bitmaps, it's just a bunch of vector drawing and you want it to be as big as the parent is willing to let it be (in this case the whole frame), then there is no real best minimum or maximum size.
In that case then I would say that it is the parent's responsibility to manage the size of the widget, since the widget itself is not able to participate in that sizing, (since it has no defined best size.) So the calling code should either explicitly pass a size to the widget's __init__, call SetSize later, or put it in a sizer that is either set to expand that item, or give the item a minsize that the sizer will use to prevent it from getting too small.