提问人:newbies 提问时间:11/5/2023 更新时间:11/6/2023 访问量:45
Tkinter TreeVIew 水平滚动条不起作用
Tkinter TreeVIew Horizontal Scrollbar not working
问:
我正在使用 tkinter 和 treeview 构建一个普通表。水平滚动条是可见的,但未激活,尽管我已经配置了设置。想知道代码有什么问题吗?
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.ttk import LabelFrame
from PIL import ImageTk, Image
from tkcalendar import Calendar
from tkinter import messagebox
import webbrowser
import datetime
from io import BytesIO
from tkinter import filedialog
login_window = tk.Tk()
login_window.geometry('950x600')
Table_frame = tk.Frame(login_window, bd=15, relief='ridge', width=900, height=200)
Table_frame.grid(row=3, column=0, sticky='nsew')
destination_table = ttk.Treeview(Table_frame)
destination_table.pack(fill=BOTH, expand=1)
scroll_x = ttk.Scrollbar(Table_frame, orient='horizontal')
scroll_x.configure(command=destination_table.xview)
scroll_x.pack(side=BOTTOM, fill=X)
destination_table.configure(xscrollcommand = scroll_x.set)
destination_table["columns"]=("destinationname", "rate", "description", "estimatedprice","address", "contact", "operationtime", "type", "tags")
destination_table["show"] = "headings"
destination_table.heading("destinationname", text="Destination Name")
destination_table.heading("rate", text="Ratings")
destination_table.heading("description", text="Description")
destination_table.heading("estimatedprice", text="Estimated Price")
destination_table.heading("address", text="Address")
destination_table.heading("contact", text="Contact")
destination_table.heading("operationtime", text="Operation Time")
destination_table.heading("type", text="Destination type")
destination_table.heading("tags", text="Tags")
destination_table.column("destinationname", width=100)
login_window.mainloop()
答:
评论
geometry('950x600')