Python Forum

Full Version: Button Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm student. I need help. I create "information management system". I want to press the button and program shut down. What is this code?

But this is error box. I press "ok" and program close
exit()
Put that in the event handler for your button. What that looks like depends on what GUI you are using
Are you using a GUI?

why not show code.
def girisYap():
    kAdi = isim.get()
    parola = sifre.get()
    if kAdi == bilgiler[0] and parola == bilgiler[1]:
        messagebox.showinfo("Bilgilendirme","Giriş Başarılı!")
        import sistemgiris
    else:
        messagebox.showerror("Bilgilendirme","Kullanıcı/Şifre Hatalı!")
I want if is ok, let that screen turn off and open import.
Yes i use gui
Quote:Yes i use gui
And which one might that be?
(Apr-20-2020, 09:12 PM)Larz60+ Wrote: [ -> ]
Quote:Yes i use gui
And which one might that be?

(Apr-20-2020, 08:48 PM)jefsummers Wrote: [ -> ]
exit()
Put that in the event handler for your button. What that looks like depends on what GUI you are using

Tkinter
Ok in tkinter do this:
import sys

    def quit():
        windowname.destroy()
        sys.exit(0)

# just after window defined (root, or toplevel name, or whatever you call it) add
        windowname.protocol('WM_DELETE_WINDOW', quit)
        ...
of course you must change 'windowname' to name of your window, like root.protcol(...)
and root.destroy()
(Apr-20-2020, 09:33 PM)Larz60+ Wrote: [ -> ]Ok in tkinter do this:
import sys

    def quit():
        windowname.destroy()
        sys.exit(0)

# just after window defined (root, or toplevel name, or whatever you call it) add
        windowname.protocol('WM_DELETE_WINDOW', quit)
        ...
of course you must change 'windowname' to name of your window, like root.protcol(...)
and root.destroy()
I cant :(
Please don't PM, use the forum so all can benefit

I showed how to do this in post 7