Apr-25-2018, 10:13 AM
(Apr-24-2018, 06:01 PM)nilamo Wrote: import filename
?
Pretty much. It's exactly like importing a module function:#!/usr/bin/python #YesNoPopup.py from tkinter import * import tkinter.messagebox import QuickTest as test def ask_question(): answer = tkinter.messagebox.askquestion("Program from unknown source.", "Do you want to allow this " + "program to access your computer?") if answer == 'yes': tkinter.messagebox.showinfo('Program activated.', 'You have been hacked!') #code to activate BackdoorLogin.py test.QuickTestMain() root.destroy() else: tkinter.messagebox.showinfo('You denied the program access.', 'Wise choice!') root.destroy() root = Tk() btn = Button(root, text="Alert!", command=ask_question) btn.pack(side=TOP) root.mainloop()The QuickTest.py code is:
#!/usr/bin/env python3 #QuickTest.py def printSomething(): print("HA-HA-HA! I'm an evil python program.") def QuickTestMain(): printSomething() QuickTestMain()The only problem is that it prints the message twice, once with the initial "Alert!" message box, and a second time after the user clicks yes:
Error:========= RESTART: I:\Python\Python36-32\SamsPrograms\YesNoPopup.py =========
HA-HA-HA! I'm an evil python program.
HA-HA-HA! I'm an evil python program.
>>>
How do I prevent it from printing the message before it goes into the ask_question fucntion?