LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2014, 02:33 AM   #1
simhumcon
Member
 
Registered: Dec 2013
Posts: 35

Rep: Reputation: Disabled
tkinter.Message how to quit mainloop


hi there!

im fairly new to python. im wondering how to quit from the mainloop when i use tkinter.Message. here is my code

Code:
from Tkinter import *
import time

def _close(self):
  self.quit()

root = Tk()
var = StringVar()
label = Message(root, textvariable=var, anchor=CENTER)

var.set("Please Wait ...")
label.pack()

root.mainloop()

time.sleep(5)

root.quit()
the problem here is, when the messagebox pops out, it just stays in root.mainloop. it doesnt go to time.sleep(5). how to fix this please????

Last edited by simhumcon; 12-16-2014 at 02:38 AM.
 
Old 12-16-2014, 12:41 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,748

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Try this:

Code:
def all_done:
    root.quit()

after(5000, all_done)
root.mainloop()
 
Old 12-16-2014, 07:30 PM   #3
simhumcon
Member
 
Registered: Dec 2013
Posts: 35

Original Poster
Rep: Reputation: Disabled
hi smallpond! thank you very much for your reply. i tried that already but that will quit the mainloop after 5 secs. i want to have like a command to quit the mainloop whenever i want. i just need to execute the command anytime i want to quit the mainloop. is there a way to that?
 
Old 12-17-2014, 10:52 AM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,748

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Yes. Just put root.quit() in the code where you want to quit.

When you use tkinter, you have to write event-driven code, not linear code like you may be used to.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
No module named mainloop.glib SKDeo Linux - Software 4 07-15-2009 11:31 AM
Domino Telnet quit Message brnkstyle Linux - Server 1 06-04-2009 05:45 PM
SuSe 10.1 error mainloop 68 hope1 SUSE / openSUSE 5 11-28-2006 07:22 PM
SuSe 10.1 error mainloop 68 hope1 Linux - Desktop 0 11-23-2006 12:06 PM
Ok, my lm_sensors just quit working (error message inside) Kramer Linux - General 9 12-03-2004 11:19 AM


All times are GMT -5. The time now is 06:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration