1

Im working on a project based off of the following example that I was shown. The buttons in the example call

 lambda: controller.show_frame(PageTwo)

to change the window or "frame", but I need to call this from within another function, not from a button, and I keep getting an error. The following is a cheesy "activation checker"

def KeyCheck(key_input,controller):
    import tkinter.messagebox
    if key_input in ["18806-47599-37423", "188064759937423"]:
        controller.show_frame(PageTwo)
        print ("good")
    else:
        tkinter.messagebox.showinfo("Invalid Key", "They key entered is not valid for activation.")

But trying to call back to this "controller" no longer works. Any suggestions are appreciated.

Community
  • 1
  • 1
qwerty22
  • 101
  • 2
  • 6
  • Can you post your code. its difficult to see how your `KeyCheck` relates to linked answer. – Marcin Jan 22 '15 at 07:10
  • Do you get a full traceback? If so, what is the error? Can you post the _full_ thing here in your question? That can often be super helpful in debugging these things. – mgilson Jan 22 '15 at 07:19
  • The whole thing is a little over 200 lines, and Im not exactly sure what all is relevant and or required. perhaps a better question that separates my specific function is such: " how would I call the first snippet from within any function? If I added a function to the example, and all I wanted that fuction to do is run something along the lines of the first snippet above, how would I write the line that does so? If youd still like my code I can try to figure out how to reduce it down – qwerty22 Jan 22 '15 at 07:22
  • the specific error is NameError: global name 'controller' is not defined, but even if I try to bring in controller as one of the parameters, it still doesnt work – qwerty22 Jan 22 '15 at 07:32
  • How do you call `KeyCheck`? – Marcin Jan 22 '15 at 08:36
  • from a button in tkinter, where command=Keycheck() – qwerty22 Jan 22 '15 at 09:03
  • 1
    In the code you posted, there is no variable named `PageTwo`. Is that a function? A global variable? – Bryan Oakley Jan 22 '15 at 11:54
  • Its in the example (your example) – qwerty22 Jan 23 '15 at 00:37

0 Answers0