On Friday 30 November 2007 08:23:28 pm bsnipes wrote:
> Absolutely.  The first thing that comes to my mind is an example of the
> relationship between the Form, dPanel and Sizers when starting a project
> and then adding extra sizers and controls to a form.  Just a simple program
> to browse directories and list the files in a list box might cover the
> basics of what a newbie needs.
> I have no problem with using the Wiki for the examples as opposed to
> distributing the examples.  Thanks for the offer of apps.
>
> Thanks,
> Brian

Sounds fine.  But I have a little twist.  Instead of me just building the form 
let's keep a running dialog via this email list of the steps to get it done.  
That way others can help and put their .02 in too .  And at the end I'll 
gather the messages and put them on the wiki.   You are expected to ask 
questions and make suggestions.  Let's get started.

A Dabo form.  The word "form" brings up a little history.  Dabo's two primary 
authors (Ed and Paul) come from the windows world and are long time Visual 
Fox Pro programmers.  In the VFP world a form is a window, a frame, a 
window-object, a  widget in other languages.  But the concept is simple:

It is any rectangular area displayed on a video monitor with a common set of 
properties.  Such as borders, resizing,  menu bar,  Titles, etc...  The most 
important property is it has a painting and coordinate system for placing 
other objects within the "client area".    Bottom line it is a window that 
you have seen on every computer that you use to close, expand and interact 
with daily.  It is a python object.   In fact everything in python (and 
therefore Dabo) is an object.

A dPanel is a container (a Dabo/python object).  It is used to define an area 
within the client area of a form (window).  Within the context of Dabo it 
actually does more.  It mains the tab order of the controls within the panel.  
It contains it's own coordinate system (normally you would use sizers) for 
controls such as buttons, text boxes.  Simple but very important.

Sizers!  Sizers! Sizers!  What can I say.  

Sizers are a layout mechanism, a layout manager, a set of rules to describe 
the layout, a means to allow resizing of objects.  They are sort of a 
container - in that they contain the controls you need layed out.  Not much 
really.  But for some reason it becomes a stumbling block for many 
programmers coming from the windows world were placement of controls is 
fixed.  I know it was hard for me (I'm a VFP guy too).  But there is plenty 
of help on the web.  In fact check the Dabo wiki for more information on how 
to use sizers.  

We have several types of sizers.  A vertical box, a horizontal box, and grid 
sizer.  Recall I said that sizers are a set of rules.  Well this is how I 
think of the rules.  A vertical sizer expands or resizes in the horizontal.  
A horizontal sizer expands or resizes in the vertical.  A grid sizer is a 
speadsheet where I set the column size and the number of columns a control 
can span.  This of course is way to simple of an explanation but it works for 
me.  

So what is the relationship of form, dPanel and sizers?  Well, a form can 
contain a panel and a sizer determines how controls (including panels) are 
layouted within a form.

So let do a little coding by starting out with a form.

import dabo
dabo.ui.loadUI('wx')

class MainForm(dabo.ui.dForm):

        def afterInit(self):
                self.Caption = "File Tutorial"
# I have added a sizer to show you how to create and call the layout
# but at this point it is not strictly needed.
                self.Sizer = vs=dabo.ui.dSizer("vertical")
                self.layout()
                

if __name__ == "__main__":
        app = dabo.dApp()
        
        app.BasePrefKey = "fileTutor"
        app.setAppInfo("appName", "File Tutorial ")
        
# The app starts by running "MainForm"
        app.MainFormClass = MainForm

#you have to start the event loop       
        app.start()


Run the above code and you will get a simple form with a title and the 
built-in Dabo menu.  

Ok lets add a little more to display a panel

immediately after
self.Sizer =vs= dabo.ui.dSizer("vertical")

add
vs.append(dabo.ui.dPanel(self,BackColor = "green))

Run again.

This should give you a little green box in the upper left hand corner.  

Ok now let's expand the panel to fill the form in several steps by adding 
paramenters to the vs.append method.  Just add a ',1'.
.
vs.append(dabo.ui.dPanel(self,BackColor = "green),1)

Run it again - what happened?.

Now add one more parameter so it reads
vs.append(dabo.ui.dPanel(self,BackColor = "green),1,'x')

At this point I will stop and ask you to tell me  (and others on the list) 
what is happening.  Your clue is we are adding a container/control/object to 
a sizer using the the append method (function).


-- 
John Fabiani


_______________________________________________
Post Messages to: [email protected]
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]

Reply via email to