Answers for "tkinter simpledialog show information"

0

tkinter simpledialog show information

from tkinter import *
from tkinter import messagebox as msgb

def showi():
  info = entry.get()
  msgb.showinfo("info", info)

wn = Tk()

entry = Entry(wn)
entry.pack()

btn = Button(wn, text="show info", command=showi)
btn.pack()

wn.mainloop()
Posted by: Guest on October-21-2021
0

tkinter folderdialog

import tkinter as tk
from tkinter import ttk
from tkinter import filedialog as fd
from tkinter.messagebox import showinfo

# create the root window
root = tk.Tk()
root.title('Tkinter File Dialog')
root.resizable(False, False)
root.geometry('300x150')


def select_files():
    filetypes = (
        ('text files', '*.txt'),
        ('All files', '*.*')
    )

    filenames = fd.askopenfilenames(
        title='Open files',
        initialdir='/',
        filetypes=filetypes)

    showinfo(
        title='Selected Files',
        message=filenames
    )


# open button
open_button = ttk.Button(
    root,
    text='Open Files',
    command=select_files
)

open_button.pack(expand=True)

root.mainloop()Code language: Python (python)
Posted by: Guest on May-28-2021

Python Answers by Framework

Browse Popular Code Answers by Language