> what error? 
>
> Error is "AttributeError: widget is undefined" with this code:

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HorizontalPanel import HorizontalPanel
from pyjamas.ui.Button import Button
from pyjamas import Window

BUTTONS = {"add":True, "clear":True, "delete":True,}

class ButtonBar(HorizontalPanel):
    
    def __init__(self,activated_buttons=BUTTONS,*args,**kwargs):
        HorizontalPanel.__init__(self,*args,**kwargs)
        self.setStyleName("centerview_buttonbar")
        self.buttons = []
        for button_tag,activated in activated_buttons.items():
            if activated:
                self.activateButton(button_tag)

    def activateButton(self,button_tag):
        bname = "buttonbar_"+button_tag
        button = Button(bname,self.onClick,StyleName=bname)
        self.buttons.append(button)
        #self.add(button)
        self.add(self.buttons[-1])

    def onClick(self,event):
        Window.alert("been clicked.")

def show_main():
    bbar = ButtonBar()
    RootPanel().add(bbar)

if __name__ == '__main__':
    show_main()


but with this code it works (mind the "#"):

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HorizontalPanel import HorizontalPanel
from pyjamas.ui.Button import Button
from pyjamas import Window

BUTTONS = {"add":True, "clear":True, "delete":True,}

class ButtonBar(HorizontalPanel):
    
    def __init__(self,activated_buttons=BUTTONS,*args,**kwargs):
        HorizontalPanel.__init__(self,*args,**kwargs)
        self.setStyleName("centerview_buttonbar")
        self.buttons = []
        for button_tag,activated in activated_buttons.items():
            if activated:
                self.activateButton(button_tag)

    def activateButton(self,button_tag):
        bname = "buttonbar_"+button_tag
        button = Button(bname,self.onClick,StyleName=bname)
        self.buttons.append(button)
        self.add(button)
        #self.add(self.buttons[-1])

    def onClick(self,event):
        Window.alert("been clicked.")

def show_main():
    bbar = ButtonBar()
    RootPanel().add(bbar)

if __name__ == '__main__':
    show_main()



 

> what are you build options? 
>
> my build options are:

pyjsbuild --enable-signatures --disable-compile-inplace --enable-strict 
--enable-debug
 
thank you,
Frank

-- 



Reply via email to