Hello all, last night i was working with an application in pythoncard
and decided I really wanted to have a resizeable window - that is -
with the components growing and shrinking Resizer like. That isn't
supported natively in pycard; and I am a stubborn person. I realize
there is a wxPython way of doing this (i have the usage examples right
here) but i like staying in pycard world. It has something to do with
destroying cryptic C-inherited syntax, and a little DIY syndrome. So,
I wrote one, and I'd like to share it.
If you just want to see it, go to http://telecend.hopto.org/sizer/
It's a small class, "sizer" in sizer.py, and aside from importing the
module, you can have yummy resizer widget action in just two easy
steps! okay, this is not a commerical for a veg-o-matic, but here is
the clipped example code:
####################
import sizer
...
...
def on_initialize(self, event):
self.resizer = sizer.sizer(self)
#setup resizer information:
self.resizer.bulkAdd( {self.components.widget1: {"grow": "xy"},
self.components.widget2:
{"grow": "y", "pos": "x"},
self.components.widget3: {"grow": "x"}
}
)
...
...
def on_size(self,event):
self.resizer.onSizeEvent(self, event)
#######################
And that's it!
You can use the bulkAdd() (or addWidget() one by one) to register the
widgets. Then, the only thing you specifiy is a string "xy" or "x" or
"y" (don't include it if you don't want it) for the "grow" and "pos"
entries. Here is a sentence or two to make how to use it clear,
If you want a widget to GROW along with the window when the window is
resized (like a text area),then tell it which way it can grow when the
window is resized, "x" and/or "y".
If you want a widget, like a button, to MOVE (keep a certain relation
to the border), then tell it which way it can move when the window is
resized, "x" and/or "y".
These can be used simultaneously too. I think it's really easy, if you
look at it and give it a whirl.
So -- if you go to http://telecend.hopto.org/sizer/ you'll be able to
get and play with it. Drop me a line if you have a comment, i am
trying to get started on contributing when and where I can.
James Robey,
Maryland
|