import tkinter as tk import tkinter.messagebox import pickle class Desk(): def __init__(self,master): self.window = master self.window.config() self.window.title("线路规划系统") self.window.geometry("500x300") self.window.resizable(width=False,height=False) main_menu(self.window) class main_menu(): def __init__(self,window): self.window = window self.window.config() self.main_menu = tk.Frame(self.window, ) self.main_menu.pack() b = tk.Label(self.main_menu, text="主菜单", font=('heiti', 25), width=20, height=1) b.pack() v = tk.Button(self.main_menu, text=" 用户模式 ", width=20, height=1, command=self.change) v.pack() s = tk.Button(self.main_menu, text="管理员模式", width=20, height=1 ) s.pack() v.place(x=10, y=30) s.place(x=10, y=40) b.place(x=10, y=20) def change(self, ): self.main_menu.destroy() user_face(self.window) class user_face(): def __init__(self,window): self.window = window self.window.config() self.user_face = tk.Frame(self.window, ) self.user_face.pack() a = 0.1 with open("zhenjiang_jiaotong.txt", 'r') as jt: for line in jt: lines = line.rstrip() s = tk.Button(window, text=lines, width=50, height=1) s.place(relx=0.1, rely=a, anchor="center") a += 0.1 s.pack() if __name__ == '__main__': root = tk.Tk() Desk(root) root.mainloop()
使用place()后不显示按钮, 单独使用pack 无法更改按钮的位置,这个要怎么更改