Answers for "python tkinter alert custom buttons"

3

how to make alert dialog in tkinter

import tkinter as tk
from tkinter import messagebox as mb

def answer():
    mb.showerror("Answer", "Sorry, no answer available")

def callback():
    if mb.askyesno('Verify', 'Really quit?'):
        mb.showwarning('Yes', 'Not yet implemented')
    else:
        mb.showinfo('No', 'Quit has been cancelled')

tk.Button(text='Quit', command=callback).pack(fill=tk.X)
tk.Button(text='Answer', command=answer).pack(fill=tk.X)
tk.mainloop()
Posted by: Guest on July-18-2020
1

how to make custom buttons tkinter

from tkinter import *

root = Tk()

button = Button(root, text="Click me!")
img = PhotoImage(file="C:/path to image/example.gif") # make sure to add "/" not ""
button.config(image=img)
button.pack() # Displaying the button

root.mainloop()
Posted by: Guest on July-18-2020

Python Answers by Framework

Browse Popular Code Answers by Language