Interface definition to session in Enigma2

  • Could any of you please define the interface to the session object.


    As I understood, session is used to show the screen box on the screen, my plugin requires that when the user select and press OK, then the current screen disappear and a new one appears.


    I check the simplerss plugin which perform a similar thing, I can see that following line is execited:


    Code
    session.openWithCallback(closed, RSSSetup, rssPoller)


    My guess is that we are trying to open the new screen but I do not understand what the following parameters are, like close, RSSSetup and rssPoller.


    I guess that it is telling the I have to open a new screen and and before that I have to call the self.close function, and the new screen should be according to the RSSSetup class. But I'm not sure, I actually think thatI'm trying to let things fit.


    Could any one of you tell me how to interpret this session.openWithCallBack command and how many parameters I can include in the call and what will the return value be.


    cheers.

  • closed -> callback function
    RSSSetup -> Screen to open
    rssPoller -> argument


    There is no limit to the number of arguments but the screen you're opening needs to support it. If you look at the remaining source of SimpleRSS you see that it expects the rssPoller instance as an additional argument (aside from the implicit self and the session).


    Both openWithCallback and open return the opened dialog.


    The Session class is defined in mytest.py so you might want to take a look if you want to have a closer look at the interface.


    Also my source code (I'm the current maintainer of e.g. SimpleRSS :D) normally has plenty of comments so reading a little more of it might help too.

    Homescreen eurer Apple-Geräte noch nicht voll genug?


    dreaMote: Fernbedienung für Dreamboxen
    Mobile WOL: Wake-on-LAN Client für iOS mit optionalem Widget
    My Home Remote: Fernkontrolle für Homematic CCU/CCU2 optimiert für mobile Benutzung

  • ritzMo,


    Thanks for the tentative answer. I will do some study as you suggested. Actually the information about mytest.py was quite vital for me so I will check that now :grinning_squinting_face:

  • So,


    # Session.open:
    # * push current active dialog ('current_dialog') onto stack
    # * call execEnd for this dialog
    # * clear in_exec flag
    # * hide screen
    # * instantiate new dialog into 'current_dialog'
    # * create screens, components
    # * read, apply skin
    # * create GUI for screen
    # * call execBegin for new dialog
    # * set in_exec
    # * show gui screen
    # * call components' / screen's onExecBegin
    # ... screen is active, until it calls 'close'...


    which means that I can call self.session.openWithCallback(...) from within a screen and it will call execEnd for the old and call execBegin for the new.


    I'm calling self.session.openWithCallback(...) in line 64 but it seems that is does not like doing this from within the screen or something


    And I'm getting the following in trace back. If you have any idea, then please write it, else I will write back when I figure that out.

    Code
    modal open are allowed only from a screen which is modal!
  • There are a lot of mistakes in the code...


    First of (not a mistake, but imo better style): Screen.__init__ saves session as self.session - so don't do it twice unless you have a good reason for it (you don't!).
    Second: you're calling keySearch when you actually want to bind it in the keymap definition
    Third: you really don't need a bound function to call main - does not break anything but it's useless overhead.
    Fourth: SelectCountry does not know about the parameter you're opening it with.



    If you really don't want to keep track of xmlparse as a variable bound to the instance you can use a boundFunction there but i'd rather implement it like I suggested since it is imo more readable.


    Zitat

    Originally posted by laith.said
    And I'm getting the following in trace back. If you have any idea, then please write it, else I will write back when I figure that out.

    Code
    modal open are allowed only from a screen which is modal!


    Your screen was not finished when you tried to open a new one (not exactly "correct" but should be understandable ;)).

    Homescreen eurer Apple-Geräte noch nicht voll genug?


    dreaMote: Fernbedienung für Dreamboxen
    Mobile WOL: Wake-on-LAN Client für iOS mit optionalem Widget
    My Home Remote: Fernkontrolle für Homematic CCU/CCU2 optimiert für mobile Benutzung

    Einmal editiert, zuletzt von ritzMo ()

  • ritzMo,


    Thanks for the review and input. That was very much of help. Please note that I'm very new in Python, so this was learning by doing :winking_face:


    I was wondering whether it really need to be in 2 different classes or whether it was enough to do on the same class, e.g. (starting from line 62 below):


    now that did not work anyhow.

  • That won't work.
    At least the way you copied it - you might want to try:


    Since I do not really know what you're up to I can barely say if putting it in one screen would be a good idea or if my proposal is actually any good :winking_face:

    Homescreen eurer Apple-Geräte noch nicht voll genug?


    dreaMote: Fernbedienung für Dreamboxen
    Mobile WOL: Wake-on-LAN Client für iOS mit optionalem Widget
    My Home Remote: Fernkontrolle für Homematic CCU/CCU2 optimiert für mobile Benutzung

    Einmal editiert, zuletzt von ritzMo ()

  • Sure, that was a paste issue wrt to the idents :winking_face:


    The idea is that have an xml file with contenants, countries. The user select the contenant then select the country and based on the selection the plugin extract the correct URL and use it for the ntp update script.


    So, in line 16 below, I should implement fethcing the test from the text from XML and send it as a parameter to the script that executes ntpupdate.


    My question was, if I do as below
    self("menu") = MenuList(list)


    then I clear list and start to append new things to it, will that update the menu list in the screen with the new content? If that is possible, then I can instead of opening a new screen, just clear the current screen from the contenants and add the list of the counteries.