button_open = tkButtonframe_buttons1 text=打开文件 font=Arial 12 command=selfopen_file button_openpackpadx=5 button_other1 = tkButtonframe_buttons2 text=跳转到别的界面1 font=Arial 12 bg=blue fg=whi
self.tree.grid(row=0, column=0, sticky='nsew') vsb.grid(row=0, column=1, sticky='ns')
# 设置treeview的样式
style = ttk.Style()
style.theme_use("default")
style.configure("Treeview", font=("Arial", 12), rowheight=25, highlightthickness=0, bd=0)
style.configure("Treeview.Heading", font=("Arial", 12, "bold"), foreground="black")
style.configure("TScrollbar", gripcount=0, background="white", troughcolor="gray", bordercolor="gray")
# 设置treeview的数据
self.tree_data = [("Maruti Swift", "2014", "145000", "28.4 kmpl", "1248 CC", "74 bhp", "5", "3.5 Lakh"),
("Hyundai i20", "2013", "120000", "18.5 kmpl", "1396 CC", "90 bhp", "5", "4.5 Lakh"),
("Volkswagen Vento", "2012", "90000", "20.0 kmpl", "1598 CC", "103 bhp", "5", "6.0 Lakh"),
("Honda City", "2015", "18000", "25.6 kmpl", "1498 CC", "97 bhp", "5", "8.5 Lakh"),
("Maruti Vitara Brezza", "2016", "39000", "24.3 kmpl", "1248 CC", "88 bhp", "5", "7.0 Lakh"),
("Ford EcoSport", "2014", "90000", "22.7 kmpl", "1498 CC", "98 bhp", "5", "6.5 Lakh"),
("Renault KWID", "2016", "20000", "25.17 kmpl", "799 CC", "53 bhp", "5", "3.5 Lakh"),
("Hyundai Grand i10", "2015", "60000", "18.9 kmpl", "1197 CC", "82 bhp", "5", "5.0 Lakh"),
("Toyota Innova Crysta", "2017", "15000", "15.1 kmpl", "2393 CC", "147 bhp", "7", "15.0 Lakh"),
("Mahindra XUV500", "2016", "67000", "16.0 kmpl", "2179 CC", "140 bhp", "7", "12.0 Lakh")]
for i, data in enumerate(self.tree_data):
self.tree.insert("", "end", values=data)
if i % 2 == 0:
self.tree.item(i, tags=("even",))
else:
self.tree.item(i, tags=("odd",))
self.tree.tag_configure("even", background="#fbfbfb")
self.tree.tag_configure("odd", background="#f0f0f0"
原文地址: https://www.cveoy.top/t/topic/gElH 著作权归作者所有。请勿转载和采集!