pythongui界面分页,分为四页,且页面各自分开按钮,可来回点击切换,每个页面也有文字显示和数据输入框的代码
时间: 2024-05-02 12:20:24 浏览: 115
python gui界面
3星 · 编辑精心推荐
以下是一个简单的Python GUI分页界面,分为四页,每页都有不同的文本和数据输入框。您可以通过点击按钮来切换页面。
```
import tkinter as tk
class Page1(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="Page 1", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
text = tk.Label(self, text="This is page 1. Enter some data below:")
text.pack(pady=10)
self.entry = tk.Entry(self)
self.entry.pack()
button = tk.Button(self, text="Go to Page 2", command=lambda: controller.show_frame(Page2))
button.pack()
def on_show(self):
self.entry.focus()
class Page2(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="Page 2", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
text = tk.Label(self, text="This is page 2. Enter some data below:")
text.pack(pady=10)
self.entry = tk.Entry(self)
self.entry.pack()
button = tk.Button(self, text="Go to Page 3", command=lambda: controller.show_frame(Page3))
button.pack()
def on_show(self):
self.entry.focus()
class Page3(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="Page 3", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
text = tk.Label(self, text="This is page 3. Enter some data below:")
text.pack(p
阅读全文