豌豆Ai站群搜索引擎系统:www.wd.chat

Wd提问: ai编写小程序

Ai批改: Here's a simple example of a To-Do List mini program written in Python using the Tkinter library for the GUI:

python
import tkinter as tk
from tkinter import messagebox

class ToDoList:
def __init__(self, root):
self.root = root
self.root.title(To-Do List)
self.tasks = []

Create task list
self.task_list = tk.Listbox(self.root, width=40, height=10)
self.task_list.pack(padx=10, pady=10)

Create new task entry
self.new_task_label = tk.Label(self.root, text=New Task:)
self.new_task_label.pack()
self.new_task_entry = tk.Entry(self.root, width=40)
self.new_task_entry.pack()

Create buttons
self.add_task_button = tk.Button(self.root, text=Add Task, command=self.add_task)
self.add_task_button.pack()
self.delete_task_button = tk.Button(self.root, text=Delete Task, command=self.delete_task)
self.delete_task_button.pack()
self.save_tasks_button = tk.Button(self.root, text=Save Tasks, command=self.save_tasks)
self.save_tasks_button.pack()
self.load_tasks_button = tk.Button(self.root, text=Load Tasks, command=self.load_tasks)
self.load_tasks_button.pack()

def add_task(self):
task = self.new_task_entry.get()
if task != :
self.tasks.append(task)
self.task_list.insert(tk.END, task)
self.new_task_entry.delete(0, tk.END)

def delete_task(self):
try:
task_index = self.task_list.curselection()[0]
self.task_list.delete(task_index)
self.tasks.pop(task_index)
except:
messagebox.showwarning(Error, Select a task to delete)

def save_tasks(self):
with open(tasks.txt, w) as file:
for task in self.tasks:
file.write(task + \n)
messagebox.showinfo(Tasks Saved, Tasks have been saved to tasks.txt)

def load_tasks(self):
try:
with open(tasks.txt, r) as file:
self.tasks = file.readlines()
self.tasks = [task.strip() for task in self.tasks]
self.task_list.delete(0, tk.END)
for task in self.tasks:
self.task_list.insert(tk.END, task)
except FileNotFoundError:
messagebox.showwarning(Error, No saved tasks found)

if __name__ == __main__:
root = tk.Tk()
todo_list = ToDoList(root)
root.mainloop()

This program creates a simple to-do list with the following features:

* Add tasks to the list
* Delete tasks from the list
* Save tasks to a file
* Load tasks from a file

Here's how it works:

1、 The program creates a GUI window with a list box to display tasks, an entry field to input new tasks, and buttons to add, delete, save, and load tasks.
2、 When you enter a new task and click Add Task, it gets added to the list.
3、 You can delete a task by selecting it in the list and clicking Delete Task.
4、 Clicking Save Tasks saves all tasks in the list to a file named `tasks.txt`.
5、 Clicking Load Tasks loads tasks from `tasks.txt` and displays them in the list.

This is a basic example、You can enhance it by adding more features like editing tasks, due dates, priorities, etc.

商家广告

广告招商

月饼

广东过滤器

广告招商

贵阳用友软件

域名抢注

广告招商

高防vps

豌豆Ai站群搜索引擎系统

广告招商

广告招商

广告招商

广告招商

广告招商


0

IP地址: 222.81.250.243

搜索次数: 27

提问时间: 2025-04-19 22:35:26

热门提问
鹏华弘康灵活配置混合C
兴全社会价值三年持有混合
上海黄金珠宝批发市场
印度黄金项链
南通翡翠鉴定中心
ew45域名查询
怎么辩金子的真假
黄金 回收多少钱
实时汇率查询中国银行今日外汇牌价
查一下今日的黄金价格
豌豆Ai站群搜索引擎系统

热门作画

关于我们:
三乐Ai 作文批改 英语分析 在线翻译 拍照识图
Ai提问 英语培训 本站流量 联系我们

加入群聊
群

友情链接
ai作画  한국어 웹사이트  ai提问

站长工具
Ai工具  whois查询  搜索

温馨提示:本站所有问答由Ai自动创作,内容仅供参考,若有误差请用“联系”里面信息通知我们人工修改或删除。

技术支持:本站由豌豆Ai提供技术支持,使用的最新版:《豌豆Ai站群搜索引擎系统 V.25.05.20》搭建本站。

上一篇 50816 50817 50818 下一篇