首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

3_significant software.zip

行业研究 5.32MB 7 需要积分: 1
立即下载

资源介绍:

3_significant software.zip
import pygame import sys from pygame.locals import * import tkinter as tk import json from tkinter import ttk a=0 a1="" a2="" b1="" def main(): root = tk.Tk() root.title("Tkinter 表格示例") with open("test.json", "r",encoding="utf-8") as f: list1 = json.load(f) length=len(list1) # 创建Treeview控件 tree = ttk.Treeview(root, columns=("ID", "Name", "Age"), show="headings") tree.heading("ID", text="ID") tree.heading("Name", text="VALUE") tree.heading("Age", text="KEY") # 插入数据 for i in range(1,length+1): a1=list1[i-1] keys=a1.keys() values=a1.values() keys=str(keys) keys=keys[11:-2] values=str(values) values=values[13:-2] tree.insert("", "end", values=(i,keys,values)) tree.pack(expand=True, fill="both") root.mainloop() def tkin1(): def close(): root.destroy() def confirm(): global a1, b1 a1 = entry_1.get() b1 = entry_2.get() print(a1) print(b1) close() root = tk.Tk() root.title("输入框") root.geometry("600x400+530+80") label_1 = tk.Label(root, text='KEY:', font=('Arial', 12)) label_2 = tk.Label(root, text='VALUE:', font=('Arial', 12)) label_1.place(x=50, y=100) label_2.place(x=50, y=155) entry_1 = tk.Entry(root) entry_1.place(x=250, y=100, width=100) entry_2 = tk.Entry(root) entry_2.place(x=250, y=155, width=100) button1 = tk.Button(root, text='确认', width=20, command=confirm) # 修正了宽度和command button1.place(x=320, y=340, height=30) # 移除了不必要的width参数 button2 = tk.Button(root, text='取消', width=20, command=close) # 修正了width和command button2.place(x=420, y=340, height=30) # 调整了位置以避免重叠 root.mainloop() def tkin2(): def close(): root.destroy() def confirm(): global a2 a2 = entry_1.get() print(a2) close() root = tk.Tk() root.title("输入框") root.geometry("600x400+530+80") label_1 = tk.Label(root, text='KEY:', font=('Arial', 12)) label_1.place(x=50, y=100) entry_1 = tk.Entry(root) entry_1.place(x=250, y=100, width=100) button1 = tk.Button(root, text='确认', width=20, command=confirm) # 修正了宽度和command button1.place(x=320, y=340, height=30) # 移除了不必要的width参数 button2 = tk.Button(root, text='取消', width=20, command=close) # 修正了width和command button2.place(x=420, y=340, height=30) # 调整了位置以避免重叠 root.mainloop() class Button: def __init__(self, x, y, width, height, text, color_inactive=(100, 100, 100), color_active=(50, 150, 50)): self.rect = pygame.Rect(x, y, width, height) self.color_inactive = color_inactive self.color_active = color_active self.color = self.color_inactive self.text = text self.font = pygame.font.Font('MiSans-Heavy.ttf', 36) # 使用默认字体,大小36 self.text_image = self.font.render(self.text, True, (255, 255, 255)) # 白色文本 self.text_rect = self.text_image.get_rect(center=self.rect.center) # 文本居中 def is_clicked(self, event): # 检查鼠标点击是否在按钮上 if event.type == MOUSEBUTTONDOWN: if self.rect.collidepoint(event.pos): self.color = self.color_active # 改变按钮颜色以表示它被点击 return True elif event.type == MOUSEBUTTONUP: self.color = self.color_inactive # 鼠标释放时恢复按钮颜色 return False def draw(self, surface): # 绘制按钮和文本 pygame.draw.rect(surface, self.color, self.rect) surface.blit(self.text_image, self.text_rect) text1="不存在" pygame.init() screen = pygame.display.set_mode((1280, 720)) background = pygame.image.load("0.jpg") button1 = Button(100, 100, 200, 50, "创建") button2 = Button(100, 200, 200, 50, "删除") button3 = Button(100, 300, 200, 50, "查询") button4 = Button(100, 400, 200, 50, "退出") button5 = Button(400, 400, 200, 50, "表格") running=0 screen.blit(background,(0,0)) while True: while running==0: for event in pygame.event.get(): if event.type == pygame.QUIT: running = 1 elif button1.is_clicked(event) : a=1 elif button2.is_clicked(event) : a=2 elif button3.is_clicked(event) : a=3 elif button4.is_clicked(event) : a=0 elif button5.is_clicked(event) : a=7 screen.blit(background,(0,0)) button4.draw(screen) button5.draw(screen) if a==0: button1.draw(screen) button2.draw(screen) button3.draw(screen) elif a==1: tkin1() try: with open("test.json", "r",encoding="utf-8") as f: list1 = json.load(f) except FileNotFoundError: list1 = [] found = False for item in list1: if a1 in item: print(f"VALUE是{item[a1]}") found = True break if not found: dictionary1 = {a1: b1} list1.append(dictionary1) print(f"已添加 {dictionary1} 到列表中") # 将更新后的列表写回JSON文件 with open("test.json", "w", encoding='utf-8') as a: json.dump(list1, a, ensure_ascii=False, indent=4) # 使用indent使JSON文件更易读 print("程序已退出。") a=0 elif a==2: with open("test.json", "w") as a: json.dump([],a,ensure_ascii=False) text1="数据已被全部删除" elif a==3: tkin2() try: with open("test.json", "r",encoding="utf-8") as f: data = json.load(f) # 检查data是否是列表 if isinstance(data, list): found = False for item in data: if isinstance(item, dict) and a2 in item: print(f"VALUE是{item[a2]}") text1=item[a2] a=4 found = True if not found: print("该KEY在JSON文件中的任何字典中都不存在") a=5 else: # 假设data是一个字典 if a2 in data: print(f"VALUE是{data[key1]}") else: print("该KEY在JSON文件中不存在") a=5 except json.JSONDecodeError: print("无法解析JSON文件,请检查文件内容") except Exception as e: print(f"发生了一个错误:{e}") elif a==4: text=str(text1) font = pygame.font.Font('MiSans-Heavy.ttf', 53) text_surface = font.render(text, True, (255, 255, 255)) text_rect = text_surface.get_rect(center=(640, 120)) screen.blit(text_surface, text_rect) elif a==5: font = pygame.font.Font('MiSans-Heavy.ttf', 53) text_surface1 = font.render(text1, True, (255, 255, 255)) text_rect1 = text_surface1.get_rect(center=(640, 120)) screen.blit(text_surface1, text_

资源文件列表:

3_significant software.zip 大约有4个文件
  1. 0.jpg 222.09KB
  2. main.py 8KB
  3. MiSans-Heavy.ttf 7.42MB
  4. test.json 2B
0评论
提交 加载更多评论
其他资源 Android虚拟机&Android类加载机制
Android虚拟机&Android类加载机制 Android虚拟机&Android类加载机制 Android虚拟机&Android类加载机制
线程与进程的理论知识入门1线程与进程的理论知识入门1
线程与进程的理论知识入门1线程与进程的理论知识入门1线程与进程的理论知识入门1线程与进程的理论知识入门1
vba excel单元格内相同名称标红色
vba excel单元格内相同名称标红色
ecryptfsecryptfsecryptfsecryptfsecryptfsecryptfs
ecryptfsecryptfsecryptfsecryptfsecryptfs
实战设计模式大全:业务场景应用与代码实现
本资源是一套精心编写的实战教程,专门面向开发者,展示如何将设计模式应用到各种真实业务场景中,涵盖从初级到高级的多种设计模式及其组合应用。通过这些详尽的实例,您将学习如何在实际开发中灵活运用设计模式,解决复杂的业务问题。本资源中的每个案例都经过深思熟虑,涵盖了从需求分析、架构设计到代码实现的完整过程。无论您是处理报表生成系统、在线购物平台、交通管理系统还是社交网络平台,本资源都提供了相应的解决方案。 每个设计模式实战案例都附有详细的讲解和示例代码,使学习过程更加直观、易于理解。您不仅能够深入理解各个设计模式的核心思想,还可以看到它们如何在不同的项目中有效应用。通过这些案例,您将掌握如何在开发中提高代码的可维护性、扩展性和重用性,从而提升项目的整体质量。 本资源特别适合希望提升设计能力的开发者,以及在项目开发过程中遇到复杂问题时寻找解决方案的技术人员。无论您是经验丰富的开发者,还是刚刚接触设计模式的新手,这套资源都能为您提供有价值的参考和指导。下载本资源,您将获得理论与实践的双重提升,能够更好地应对未来开发中的挑战,助力您的职业发展。
Sung Mo Kang 康松默《CMOS数字集成电路 分析与设计》第4版 课后 答案(ch1~16).zip
Sung Mo Kang 康松默《CMOS数字集成电路 分析与设计》第4版 课后 答案(ch1~16).zip
Sung Mo Kang 康松默《CMOS数字集成电路 分析与设计》第4版 课后  答案(ch1~16).zip Sung Mo Kang 康松默《CMOS数字集成电路 分析与设计》第4版 课后  答案(ch1~16).zip Sung Mo Kang 康松默《CMOS数字集成电路 分析与设计》第4版 课后  答案(ch1~16).zip
图书管理系统素材.zip
图书管理系统素材.zip
Dev-C++ 6.3.zip
Dev-C++ 6.3.zip