ken | 25 Jun 2012 04:00
Picon

Tkinter message box


If this belongs on another list, please let me know. I am using PYTHON 3
and tkinter. I have been playing around with messagebox. Is there any
way I can display the value of a variable inside a message box?

Thank you,
Ken
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Steven D'Aprano | 25 Jun 2012 06:07

Re: Tkinter message box

On Sun, Jun 24, 2012 at 10:00:57PM -0400, ken wrote:
> 
> If this belongs on another list, please let me know. I am using PYTHON 3
> and tkinter. I have been playing around with messagebox. Is there any
> way I can display the value of a variable inside a message box?

Of course. tkinter doesn't care where the values come from, you can use 
a variable just as easily as a static string literal.

Using Python 3.2:

>>> import tkinter.messagebox
>>> import time
>>> title = "a trivial example".title()
>>> message = "It is now %s, do you know where your computer is?" % time.asctime()
>>> tkinter.messagebox.showinfo(title, message)
'ok'

If that's not the sort of thing you mean, please show us what code you 
are using.

--

-- 
Steven
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Alan Gauld | 25 Jun 2012 09:21

Re: Tkinter message box

On 25/06/12 03:00, ken wrote:
>
> If this belongs on another list, please let me know. I am using PYTHON 3
> and tkinter. I have been playing around with messagebox. Is there any
> way I can display the value of a variable inside a message box?

Yes, just insert it intro the message string prior to displaying the 
messagebox:

import tkMessageBox
num = 6
tkMessageBox.showinfo("Village News", "Message for number %d" % num)

HTH,
--

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Gmane