Menu driven program using python | 😀 Python code | GUI programming Python | एक सिंपल GUI application
Автор: e-GURUG
Загружено: 2025-10-21
Просмотров: 82
Описание:
Menu driven program using python | 😀 Python code | GUI programming Python | एक सिंपल GUI application
your Query solve-
#python
#pythonprogramming
#pythoncode
#coding
#programming
#developer
#programmer
#codinglife
#softwaredevelopment
#datascience
#machinelearning
#artificialintelligence
#deeplearning
#pytorch
#tensorflow
#webdevelopment
#django
#flask
#learnpython
#pythonforbeginners
#pythonprojects
#programminglife
#codingbootcamp
code:
import tkinter as tk
from tkinter import messagebox, filedialog
import os
---- Functions ----
def open_notepad():
os.system("notepad" if os.name == "nt" else "gedit")
def open_calculator():
os.system("calc" if os.name == "nt" else "gnome-calculator")
def about_info():
messagebox.showinfo("About", "GUI Menu Program\nCreated using Python & Tkinter")
def exit_app():
confirm = messagebox.askyesno("Exit", "Are you sure you want to exit?")
if confirm:
root.destroy()
def open_file():
file_path = filedialog.askopenfilename(title="Open File", filetypes=[("Text Files", "*.txt")])
if file_path:
messagebox.showinfo("File Selected", f"You selected:\n{file_path}")
---- Main Window ----
root = tk.Tk()
root.title("Menu Driven Program")
root.geometry("500x300")
---- Menu Bar ----
menu_bar = tk.Menu(root)
File Menu
file_menu = tk.Menu(menu_bar, tearoff=0)
file_menu.add_command(label="Open File", command=open_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=exit_app)
menu_bar.add_cascade(label="File", menu=file_menu)
Tools Menu
tools_menu = tk.Menu(menu_bar, tearoff=0)
tools_menu.add_command(label="Calculator", command=open_calculator)
tools_menu.add_command(label="Notepad", command=open_notepad)
menu_bar.add_cascade(label="Tools", menu=tools_menu)
Help Menu
help_menu = tk.Menu(menu_bar, tearoff=0)
help_menu.add_command(label="About", command=about_info)
menu_bar.add_cascade(label="Help", menu=help_menu)
Add Menu to Window
root.config(menu=menu_bar)
---- Label ----
tk.Label(root, text="Welcome to GUI Menu Driven Program",
font=("Arial", 14), fg="blue").pack(pady=50)
Run the App
root.mainloop()
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: