Window creation + File upload button | Data Analysis using Python Tkinter | Part 1

Опубликовано: 09 Июль 2026
на канале: SE CS Academy
25
4

Code : - ## Data Analysis using Python Tkinter
import tkinter as tk
from tkinter import filedialog, messagebox

root = tk.Tk()
root.title("Data Analysis using Python Tkinter")
root.geometry("500x500")

file upload dialog and button
def upload_file():
filepath = filedialog.askopenfilename(
title="Select a file",
filetypes = (
("All files " , "*.*") ## '*' represents all & '.' says '.' should be present in file name
,)
)

if filepath :
label.configure(text=f"Selected file successfully : \n{filepath}")
else:
label.configure(text="No file selected")

btn = tk.Button(root, text = "Upload file" , command=upload_file,padx=10,pady=10)
btn.pack(pady=20)

label = tk.Label(root,text="No file selected", wraplength=350,justify="center")
label.pack(pady =10)

root.mainloop()