Page 1 of 1

Python MessageBox display variable

Posted: 13 Sep 2022, 18:42
by Ben the Coder
Hi guys,
I'm using Python to have a messagebox display a variable.
Currently, my code looks like this:

Code: Select all

from tkinter import messagebox
myvar = "Name"
messagebox.showinfo("Title here", "You opened" % name)
I've checked out this, but it doesn't seem to be happening for me. Can someone with more expertise help me with this?
Ben

Re: Python MessageBox display variable

Posted: 15 Sep 2022, 15:18
by Drugwash
If the format in that example still stands you could try

Code: Select all

messagebox.showinfo("Title here", "You opened %s" % myvar)
But that's only a theory. ;)

Re: Python MessageBox display variable

Posted: 16 Sep 2022, 09:38
by Ben the Coder
Drugwash wrote:
15 Sep 2022, 15:18
If the format in that example still stands you could try

Code: Select all

messagebox.showinfo("Title here", "You opened %s" % myvar)
But that's only a theory. ;)
Thanks! I'll try it out.