First a little house cleaning - it has been pointed out that I forgot to add
two lines of code (at the top) that are very import to the Linux and Mac
users. When our code is run from a Linux shell the added two lines of code
tells the shell what program to start to get our code to run and what
character code that is used. Sort of a boot strap way to get our code to
run.
Another issue raised it's ugly head. There are differences between python,
wxPython setups and versions. It caused the last code using a panel not to
run correctly for at least one person. So I am changing the control we will
use to demonstrate how sizers work. We will use a Dabo button
(dabo.ui.dButton).
I was hoping someone would have posted a description of how sizers worked
within the context of Dabo. But no one has posted to the list. So lets
just more on and add a little more information by demonstrating the effects
of parameters to sizers.
Recall I said that when I think of sizer rules that horizontal sizers “expand”
in the vertical. But I also said that my thinking was a over simplification.
That's because sizers have parameters that define the amount of space a
control takes relative to the other controls within a sizer's space and how
the control will react to resizing. So let's create an example that will
demonstrate sizers even more.
Let's review. We have created a simple form. We added a vertical sizer to
the form. And then used the append method of the sizer to add a panel
(which we are now changing to a button). I have also added several sizer
spacers to better mark the buttons. For the purpose of this demo we are
interested in three parameters that the append method will accept – a Dabo
control, the proportional factor, and the resize flag (there are more).
vs.append(dabo control, an integer, a flag)
A Dabo control such as a button as in dabo.ui.dButton(self,Caption=”Button 1”)
An integer as 0 or 1, 2, 3, 4 .
A flag as in 'x' or 'expand'.
In the code below I have changed the sizer to a horizontal and added three
buttons to better demonstrate how the proportional integer effects the
display of the buttons. First play with the proportional factor by changing
the integers for each of the buttons and don't forget to test zero (0). Then
add more buttons. Last add the expand flag “x”. Oops what happened?
Remember I said a horizontal sizer expands in the vertical and the a vertical
sizer expands in the horizontal.
With this installment I'll get off sizers and move on to creating a more
complex form.
import dabo
dabo.ui.loadUI('wx')
class MainForm(dabo.ui.dForm):
def afterInit(self):
self.Caption = File Tutorial
self.Sizer =vs= dabo.ui.dSizer(horizontal)
vs.append(dabo.ui.dButton(self, Caption='Button 1'),0)
vs.appendSpacer(5)
vs.append(dabo.ui.dButton(self, Caption='Button 0'),2)
vs.appendSpacer(5)
vs.append(dabo.ui.dButton(self, Caption='Button 3'),3)
self.layout()
if __name__ == __main__:
app = dabo.dApp()
app.BasePrefKey = fileTutor
app.setAppInfo(appName, File Tutorial )
app.MainFormClass = MainForm
app.start()
Please if anyone sees an error please post to the list.
--
John Fabiani
___
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]