On Wednesday 17 January 2007 10:17, Paul McNett wrote:
> Ed Leafe wrote:
> > On Jan 17, 2007, at 12:42 PM, johnf wrote:
> >> import dabo.ui.uiwx.dKeys
> >
> >     FWIW, even though wxPython is the only UI toolkit we support, this
> > coding style is strongly discouraged. If you get errors with
> > 'dabo.ui.<some module or function>', then you need to add:
> >
> > dabo.ui.loadUI("wx")
>
> It is not only strongly discouraged, it can wind up causing hair loss in
> edge cases. Always do 'import dabo' and then when you want to access
> something like dKeys do:
>
> keys = dabo.ui.dKeys
>
> and if the ui hasn't been loaded yet, you'll need to add the
> dabo.ui.loadUI("wx") manually first. So, for a simple script it would be:
>
> import dabo
> dabo.ui.loadUI("wx")
> print dabo.ui.dKeys
>
> >     I'd explain why, but as it's a namespace issue, I don't want to
> > confuse you further.
>
> I'll only add that Dabo has complicated the import of the ui namespace
> in this fashion because of the original design goal of supporting more
> than one UI toolkit. Originally we weren't going to only support
> wxPython, but also PyQt, TkInter, PyGTK, curses, etc. etc. It could
> still happen.


Both of you have placed your fingers on my problem with namespace.  

How is it possible that dTextBox.onKeyChar() does not have access to
1.  the dabo namespace?
2.  Does not know what the UI is set too?
The UI property is set during the app.setup()
The dabo is imported everywhere.  All the d*s import dabo.  Of course I 
thought that was because each has a test "main".  But each in fact has the 
import statement.  So when I create an instance of dTextBox why would I lose 
the dabo namespace?  I can understand that the instance of dTextBox may not 
be aware of the UI property - after all it is a property of the app.  So why 
would I need:
dabo.ui.loadUI("wx")

Of course all of this moot at the moment if I keep adding import statements to 
my code and dabo.ui.loadUI("wx") to my code.

BTW if this is to much to explain - don't take the time.  One day a light will 
flash on - I hope.

-- 
John Fabiani

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to