以下是一个简单的 Python 可视化窗体示例,使用 Tkinter 库创建,包含一个标签和一个退出按钮:

import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.hello_label = tk.Label(self, text='Hello, world!')
        self.hello_label.pack(side='top')

        self.quit_button = tk.Button(self, text='Quit', command=self.master.destroy)
        self.quit_button.pack(side='bottom')

root = tk.Tk()
app = Application(master=root)
app.mainloop()

这个窗体有一个标签显示 'Hello, world!',以及一个按钮,点击按钮可以退出窗口。你可以根据自己的需求添加更多的组件和功能,例如文本框、下拉菜单、图像等。

Python 可视化窗体示例:简单标签和按钮

原文地址: https://www.cveoy.top/t/topic/ofJr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录