views:

205

answers:

2

I'm starting to use Pyjamas and I'm running into some annoyances. I have to import a lot of stuff to make a script work well. For example, to make a button I need to first

from pyjamas.ui.Button import Button

and then I can use Button. Note that

import pyjamas.ui.Button

and then using Button.Button doesn't work (results in errors when you build to JavaScript, at least in 0.7pre1). Does anyone have a better example of a good way to do the import statements in Pyjamas than what the Pyjamas folks have on their site? Doing things their way is possible, but ugly and overly complicated from my perspective, especially when you want to use a dozen or more ui components.

+2  A: 

If you want to be able to say Button.Button, then instead of

import pyjamas.ui.Button

you should write

from pyjamas.ui import Button

Otherwise you need to use pyjamas.ui.Button.Button. What ends up in your namespace is what you have after the import keyword.

akaihola
+1  A: 

thanks for answering this, akaihola. gordon you should ideally have reported this as a bug on the issue tracker, or asked on the mailing list pyjamas-dev, where you would have got an answer immediately. fortunately, as this turned out to be a python-related issue not specifically a pyjamas-related one, akaihola's answer was correct, useful and helpful. but if the developers have to go hunting on the internet to find you, that's not really fair to you or to them! :) think about dropping by the mailing list next time :)