×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    23

    How to make a class destroy itself and call a function from parent? if possible

    Hello

    I have a script that lets the user select a services from a list. When selected, an instance of a "ServiceHandler" class is created, which does the service interaction.
    When the user is done interacting with the service, i should be able to press exit and return to the selection menu.

    The first part looks like this

    Code:
    def user_select_service(sevices):
      selection_list=create_list(services)
      appuifw.app.body=selection_list
      appuifw.app.title=u'Select a service'
      
    def returnToSelection():
      appuifw.app.body=selection_list
      appuifw.app.title=u'Select a service'
    
    servicelist=get_services()
    
    service=user_select_service(servicelist)
    sh=ServiceHandler(service)
    This is the handler

    Code:
    class ServiceHandler:
      def __init__(self,service):
        #blablabla
        appuifw.app.exit_key_handler=self.goBack
    
    
      def goBack(self):
        DESTROY SELF
        returnToSelection()
    
    
      #a list of methods for interaction with the service
      #....
      #...

    I'm in doubt how to make my goBack method. I'm unsure of how to refere to methods (and variable) outside the class i'm in. And also, how to destroy the class i'm operating within. What would you do?

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    23

    Re: How to make a class destroy itself and call a function from parent? if possible

    I think i'll just do the stuff in the returnToSelection function and then pass it as a parameter to ServiceHandler so it's accessible from within the class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×