简体   繁体   中英

how to show a pop up message in python?

hello I just started python and i'm facing a probleme with this code the probleme is i want the printing part to be in a pop up window message instead of the ide how can i do that? and thank u.

from tkinter import *
from tkinter import ttk
root=Tk()
root.title('laccroche')
b1=ttk.Button(root,text="entrez le titre:")
b1.pack()
entry1=ttk.Entry(root,width=60)
entry1.pack()

style=ttk.Style()
style.configure('TButton', foreground='blue')
def be():
print("ce texte est un texte "+entry1.get())

b1.config(command=be)
root.mainloop()

I'm not sure if this is what you're looking for but you can try using the tkinter messagebox command. The code will go something like: (I'm not good with French but the first string basically gives the title of the popup window)

def be():
    messagebox.showinfo("Your text","ce texte est un texte "+entry1.get())

Alternatively, if you do not want to have any title for the popup, you can specify the text given as the message as:

def be():
        messagebox.showinfo(message="ce texte est un texte"+entry1.get())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM