Python script - complete execution of one line before the ne

This is the place for queries that don't fit in any of the other categories.

Python script - complete execution of one line before the ne

Postby pcd » Thu May 22, 2014 7:22 pm


Perhaps someone can help with this problem. For info - Choicebox is an enigma2 gui class - this is not important for my question.

Code: Select all
def main(session, **kwargs):
        res = openTest(session)
        print "res =", res

def openTest(session):
        session.openWithCallback(test1, ChoiceBox, title="Select playlist item?", list=[(_("Video1"), "Video1"), (_("Video2"), "Video2"), (_("Video3"), "Video3"), (_("Video4"), "Video4"), (_("Video5!"), "Video5")])   
        return SELECTION
def test1(answer):
      print "answer A:", answer
      global SELECTION
      SELECTION = answer[1]

Question :- This code prints res = None. Obviously the print line is executed before openTest is completed. Without changing def main - how can the correct reply 'res' be returned and printed ?

Regards, pcd.
Last edited by Yoriz on Thu May 22, 2014 9:32 pm, edited 1 time in total.
Reason: First post lock.
Posts: 1
Joined: Thu May 22, 2014 7:12 pm

Re: Python script - complete execution of one line before th

Postby Kebap » Fri May 23, 2014 9:37 am

Hi pcd, your function openTest returns the value of SELECTION, but that is never defined there. I assume this is why None is returned.

Other than that, can you show some code with the same error, but without openWithCallback or ChoiceBox etc, so we can actually run and test it ourselves?
Due to the reasons discussed here we are moving to on October 1, 2016.

This forum will be closed. Please create an account at the new site to continue discussion.

Posts: 689
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests