I have created a script in Python which notifies me at a given event. I am using the following function to produce the warning window:
def window_warn():
'''
This function will throw up a window with some text
'''
#These two lines get rid of tk root window
root = Tkinter.Tk()
root.withdraw()
#tkMessageBox.deiconify()
TkMessageBox.showwarning("New Case", "You have a new case\n Please restart pycheck")
return
The window draws fine, but when I click ok, the window stays in place with the button depressed. Im using xfce. Is there anyway to get the window to close after ok is clicked?
A comment indicated this may be to do with surrounding code, so for completeness:
print "Just started newcase check"
while True:
if "Uncommitted" in webpage:
print "oh look, 'Uncommitted' is in the url returned from the last function"
#If this hits we call a notification window
window_warn()
print "sleeping"
time.sleep(10)
webpage = scrape_page()
else:
print "nothing"
time.sleep(20)
webpage = scrape_page()
Try calling root.update()
before returning from the function. That will process all pending Tk/X window events.
(ideally, you'd establish a main event loop before displaying the window, but that assumes that your entire program is event driven, which may not always work.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With