[Tutor] Dialog box under windows

Edward Comber comber at cix.co.uk
Thu Jan 8 10:46:03 EST 2004


Thanks very much for that, I'll get stuck into it. At the moment it opens a
Tk main app screen that can't be closed but I'll persist.

Thanks for your help.

Eddie.

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
Behalf Of Rick Pasotto
Sent: 08 January 2004 15:35
To: tutor at python.org
Subject: Re: [Tutor] Dialog box under windows


On Thu, Jan 08, 2004 at 01:59:13PM -0000, Eddie Comber wrote:
> Would anyone have a working piece of code that can open a simple
> dialog bow in Windows?
>
> I have a background Python app running and I just want to inform the
> user when particular events occur.
>
> It would be ideal if the box showed a few lines of information and an
> #'OK' button.

import tkMessageBox
tkMessageBox.showinfo(title='window title',
	message='put your message text here')

> I have the Mark Hammond's win32all stuff but while the function calls
> are there, the stuff like the windows API constants that are needed
> for e.g. the style of the box etc.

tkMessageBox contains:

def showinfo(title=None, message=None, **options):
    "Show an info message"
    return _show(title, message, INFO, OK, **options)

def showwarning(title=None, message=None, **options):
    "Show a warning message"
    return _show(title, message, WARNING, OK, **options)

def showerror(title=None, message=None, **options):
    "Show an error message"
    return _show(title, message, ERROR, OK, **options)

def askquestion(title=None, message=None, **options):
    "Ask a question"
    return _show(title, message, QUESTION, YESNO, **options)

def askokcancel(title=None, message=None, **options):
    "Ask if operation should proceed; return true if the answer is ok"
    s = _show(title, message, QUESTION, OKCANCEL, **options)
    return s == OK

def askyesno(title=None, message=None, **options):
    "Ask a question; return true if the answer is yes"
    s = _show(title, message, QUESTION, YESNO, **options)
    return s == YES

def askretrycancel(title=None, message=None, **options):
    "Ask if operation should be retried; return true if the answer is yes"
    s = _show(title, message, WARNING, RETRYCANCEL, **options)
    return s == RETRY

--
"Politics has always been the institutionalized and established way
 in which some men have exercised the power to live off the output
 of other men." -- Karl Hess
    Rick Pasotto    rick at niof.net    http://www.niof.net

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list