Exiting a plugin code - Not just closing down a single screen/session

  • Hi there,


    I know that i can close a screen using self.close() and the current session will close but what code do i use to close down a plugin all together?


    Example is i have a plugin that has many screens, i'd like the user to be able to exit the plugin from a screen other than the first one in the plugin to save them having to press exit many times.


    If anybody knows the code then that is apprechiated


    Many thanks,


    Mark

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV

  • Ok i tried your suggestion and it doesn't work. For some reason the program doesn't recognise other screens open, even when i define a class to remove programs in the global scope. Here is the code i have:


    The above code brings the following error in the crash log when i view it:


    Code
    File "/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
      File "/usr/lib/enigma2/python/Plugins/Extensions/TheWebsiteParser/plugin.py", line 2768, in closeplugin
    	ClosePlugin()
      File "/usr/lib/enigma2/python/Plugins/Extensions/TheWebsiteParser/plugin.py", line 8448, in ClosePlugin
    	screens.close()
    TypeError: unbound method close() must be called with TransponderChannels instance as first argument (got nothing instead)
    (PyObject_CallObject(<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0x1e75120>>,('ColorActions', 'blue')) failed)


    I have also tried to say self.session.close(MainMenu), that code goes through but the screen does not close unless you are on it.


    Do you know the right way i need to write this code to close all screens? The way you suggested is not working for me.


    Thanks,


    Mark

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV

  • Ah, well when i open the screen i open it with a callback, so how do i get around it when wanting to close a screen, is it just Screens.close(ScreenName,True) ?

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV

  • I do not understand, i don't appear to have a callback function. When i launch TransponderChannels screen i do this code:

    Code
    self.session.open(TransponderChannels,transponderfoundlist,channelfoundlist)


    Shown above is the screen being opened with two parameters passed. When i close TransponderChannels from within the screen i do the code below which works fine:


    Code
    self.close()


    So i do not get why it is now asking for a callback as i shouldn't need to give it one if it closes ok from the screen itself.


    I have changed the close function in the global class so that it equals screens.close(False), the green screen here states that the first parameter should not be boolean, i then changed screens.close(TransponderChannels) and it says that it shouldn't take a type as a first parameter. I just don't see why it is not closing as i don't open the screen with a callback in the first place. Maybe you could explain another way which may work.


    Thanks,


    Mark

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV

    • Offizieller Beitrag

    Hi,


    you're not appending the instances of the screens but the object (which is just wrong)


    Code
    def closeplugin(self):
      	#this is used to close the plugin all together
      	screen.append(TransponderChannels)
      	screen.append(MainMenu)
      	#we call ClosePlugin here
      	ClosePlugin()


    You need to make the screen instances "append themselves" to your list of screens. Some rather simple Example for that could be


    Please don't forget to remove any screen from the list which is being closed manually or otherwise "preamaturely" (which is any call of close() before calling closeAll() ).
    There basically plenty of ways to reach the target ;).
    If you don't you wil:
    1. get a crash when trying to close it again
    2. possibly leak memory because of keeping a reference to an object that's not needed/used anymore (which makes it impossible for the Garbage-Collector to free the memory this object uses).


    When using existing Classes you could inerhit them and overwrite their init and close methods to achieve the "self-(de)registration".
    Oh... this is just an Example... some may even call it a little bit "hackish".


    PS: Untested Code!

  • maybe it could help if we know what you are trying to do there. Usually you dont need to close all open screens ... you close each screen with EXIT or only use one screen ... never saw a plugin or whatever that needs to work like yours.

    Theorie ist, wenn man alles weiß, aber nichts funktioniert.
    Praxis ist, wenn alles funktioniert aber niemand weiß warum.

  • Ok i will try the new code,


    The reason i need to close all screens at once is because a user e-mailed me saying they'd like to close down the plugin from an "exit plugin" button after they have zapped to a channel using my WebsiteParser plugin...i did tell him it only takes an extra 2 seconds to press exit 5 or so times but you have to keep users happy.


    I will try your code and let you know the outcome reichi.


    Many thankk and danke

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV

  • Reichi your code worked a charm. I implemented it and screens now close automatically one after another when i press exit plugin button.


    Many thanks my friend and Danke.


    :smiling_face:

    Dreambox 8000 with 1TB Western Digital Internal Hard Drive, 80cm Dish, Quad LNB, 1.2 Compatible Motor, Yamaha RX-765 Amplifier, Two Tannoy Custom F1 Speakers, Tannoy FC Custom Centre Speaker, Two Tannoy Custom FR Speakers, EPOS ELS Sub Woofer, Porty TV