Ed Leafe wrote:
> On Mar 1, 2009, at 2:01 PM, Ricardo Aráoz wrote:
>
>   
>> Hi, need some help. This is my first hand coded form, I need it to be
>> hand coded because the form's menu will be data driven.
>> So I just wanted a blue form with a menu, this is what I've come up so
>> far (obviously does not do what I want).
>> Any kind soul wishes to point out what I'm doing wrong? TIA
>>     
>
>
>   
>>> def doOpen():
>>>        dabo.ui.info('Función Open ejecutada', title='Atención!')
>>>
>>> def doClose():
>>>        dabo.ui.info('Función Close ejecutada', title='Atención!')
>>>
>>> def doEdit():
>>>        dabo.ui.info('Función Edit ejecutada', title='Atención!')
>>>       
>
>       All of these are event handlers, and thus will be called with an  
> event object passed to them. Change them all to add 'evt' as a  
> parameter; e.g.: def doOpen(evt):
>
>   
>>> def main():
>>>        app = dabo.dApp()
>>>        app.setup()
>>>        # instantiate the form
>>>        form = dabo.ui.dForm(app.MainForm, Caption="Hello, Dabo  
>>> users!")
>>>       
>
>       At this point the form's menu bar has already been created. Since you  
> aren't creating a form class, but rather an instance, you have to tell  
> it what menu bar class to create, or you'll get the default menu bar.  
> If you want a plain menu, then change this to:
>
> form = dabo.ui.dForm(app.MainForm, Caption="Hello, Dabo users!",  
> MenuBarClass=dabo.ui.dMenuBar)
>
>   
>>>        mb = dabo.ui.dMenuBar()
>>>       
>
>       Since the menu bar you want already exists, just reference that: mb =  
> form.MenuBar
>
>   
>>>        mfile = dabo.ui.dMenu()
>>>        mfile.Caption = '&File'
>>>        mfile.append('Open', HotKey='Ctrl+D', OnHit=doOpen,  
>>> help='Abrir un archivo')
>>>        mfile.append('Close', HotKey='Ctrl+L', OnHit=doClose,  
>>> help='Cerrar un archivo')
>>>        mfile.appendSeparator()
>>>        mfile.append('Edit', HotKey='Ctrl+E', OnHit=doEdit,  
>>> help='Editar algo')
>>>
>>>       
>
>       You never append the menu to the menu bar. You need to call  
> mb.append(mfile)
>
>   
>>>        panel = dabo.ui.dPanel(form)
>>>        panel.BackColor = 'blue'
>>>        panel.Sizer = dabo.ui.dSizer("v")
>>>       
>
>       You haven't added the panel to the form's sizer. You need to call:
>
> form.Sizer.append(panel, 1, "x")
>
> ...if you want it to fill the form. The '1' is the proportion, and 'x'  
> means 'expand'. Since this is a common call, I added a shortcut:
>
> form.Sizer.append1x(panel)
>
>   
>>>        #form.addObject(dabo.ui.dPanel, "tbox")
>>>        #form.tbox.Value = "Cool stuff!"
>>>        #form.tbox.FontBold = True
>>>        # show the form
>>>        app.SetMenuBar(mb)
>>>       
>
>       Application objects do not have menu bars; forms do. Just add:  
> form.MenuBar = mb
>
>   
>>>        form.Show()
>>>       
>
>       You're calling the wxPython version of the method, not the Dabo  
> wrapped version. Case matters, and the Dabo version is lower case:  
> form.show().
>
>   
>>>        app.start()
>>>       
>
>
>       Try it with the changes I suggested. If the explanations aren't  
> clear, let me know.
>
>
> -- Ed Leafe
>
>   
Thanks Ed, tried John's suggestion and they worked. Now I'm trying it
this way. You see, the way I think about it, I don't really want to
create a class but use dabo's dForm as it is, and manipulate it. Maybe
later I will end up subclassing dForm, but not right now.
The corrected program (as per your suggestions) is below. It works ok,
but besides the form, there is a "Dabo Application" window created with
the default menu. After I close my form the application window persists,
if I close the app window my forrm closes with it. Is there a way I can
get rid of this window and have only my form?

---------------------------------------------------------------------------------------------------------------------------------------------
# -*- coding: utf-8 -*-

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

def doOpen(evt):
        dabo.ui.info('Función Open ejecutada', title='Atención!')

def doClose(evt):
        dabo.ui.info('Función Close ejecutada', title='Atención!')

def doEdit(evt):
        dabo.ui.info('Función Edit ejecutada', title='Atención!')

def main():
        app = dabo.dApp()
        app.setup()
       
        form = dabo.ui.dForm(app.MainForm, Caption="Hello, Dabo users!",
MenuBarClass=dabo.ui.dMenuBar)

        mfile = dabo.ui.dMenu()
        mfile.Caption = '&File'
        mfile.append('Open', HotKey='Ctrl+D', OnHit=doOpen, help='Abrir
un archivo')
        mfile.append('Close', HotKey='Ctrl+L', OnHit=doClose,
help='Cerrar un archivo')
        mfile.appendSeparator()
        mfile.append('Edit', HotKey='Ctrl+E', OnHit=doEdit, help='Editar
algo')

        form.MenuBar.appendMenu(mfile)
        panel = dabo.ui.dPanel(form)
        panel.BackColor = 'blue'
        form.Sizer.append(panel, 1, 'x')

        form.show()
        app.start()

if __name__ == '__main__':
        main()
---------------------------------------------------------------------------------------------------------------------------------------------



--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
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/[email protected]

Reply via email to