-1

I created browserView class named as "bdrMenuView" . It should be like "class bdrMenuView(BrowserView):" . and the class contains the method named as "createPictMenu" . The whole class should be

    class bdrMenuView(BrowserView):
              def createPictMenu(self):

Now i have written one more class named as LogoViewlet . It should be like "class LogoViewlet(ViewletBase):" . and the class contains the method named as "update" . The whole class should be

    class LogoViewlet(ViewletBase):
              def update(self):

Now i want to call the method of browserView class from another class. I created an instance of one class like

    class LogoViewlet(ViewletBase):
              def update(self):
                   a = bdrMenuView(self,BrowserView)      ---------> instance of BrowserView class
                   logoName = a.createPictMenu() 

I want to know whether it is correct or not which i created.

  • 1
    This question is off-topic. Consider asking it on Stack Overflow. – edwin Jul 30 '13 at 6:22
  • 1
    @edwin It's kind of a toss-up whether or not this question is on-topic. General computer programming questions are off-topic, but once a question becomes Ubuntu-specific in one way, it tends to be considered on-topic. Even though this is applicable outside of Ubuntu, questions about how to create graphical interfaces with Python are usually considered on-topic here because that is a common and important way to make GUI programs for Ubuntu (and one of the most strongly encouraged ways). – Eliah Kagan Aug 1 '13 at 19:20
  • @EliahKagan: I accept what you say. Nonetheless, when I see a question which does not point out Ubuntu in anyway I feel it's natural to at least warn/suggest the OP about sites which are more "on-topic". – edwin Aug 1 '13 at 20:37
0

create an instance class from an another class

class LogoViewlet(ViewletBase):
          def update(self):
               a = bdrMenuView(self,BrowserView)   --->>>> this is wrong. no need to pass BrowserView as a parameter   
               logoName = a.createPictMenu() 



class LogoViewlet(ViewletBase):
          def update(self):
               a = bdrMenuView(self.context,self.request) --->>>> this is the correct way to create an instance of one class     
               logoName = a.createPictMenu() 
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.