Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button Help
#1
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
Reply
#2
exit()
Put that in the event handler for your button. What that looks like depends on what GUI you are using
Reply
#3
Are you using a GUI?

why not show code.
Reply
#4
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
Reply
#5
Quote:Yes i use gui
And which one might that be?
Reply
#6
(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
Reply
#7
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()
Reply
#8
(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 :(
Reply
#9
Please don't PM, use the forum so all can benefit

I showed how to do this in post 7
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020