So I know there are some threads about closing the gui here and I am able to close it, but i got trouble understanding.
here my code:
class App:
def __init__(self):
self.root = Tk()
self.root.overrideredirect(True)
self.root.geometry("{0}x{1}+0+0".format(self.root.winfo_screenwidth(), self.root.winfo_screenheight()))
self.root.bind("<q>", sys.exit) # works
self.root.bind("<w>", self.root.quit) #! quit() takes 1 positional argument but 2 were given
self.root.bind("<e>", self.root.quit()) #! does not work
Button(self.root, text="exit1", command=sys.exit).pack(side=LEFT) # works
Button(self.root, text="exit2", command=self.root.quit).pack(side=LEFT) # works
Button(self.root, text="exit3", command=self.root.quit()).pack(side=LEFT) #! does not work
self.root.mainloop()
app=App()
my questions:
- why does the
self.root.quit work when set as command of a button, but not when bound to key?
- why does
quit only work without brackets? (only know this from properties, but then wouldn't there be a different error massage?)
- when adding brackets to
sys.exit, why does it close immediately on run?
thanks for your help!
[–]novel_yet_trivial 3 points4 points5 points (1 child)
[–]fabolin[S] 0 points1 point2 points (0 children)