python treeview 滚动条隐藏_水平滚动条工作不正常,treeview python

在Python应用中,遇到Treeview组件的滚动条问题,特别是水平滚动条在添加新列后无法正常工作。本文讨论如何设置Treeview的大小,并通过水平滚动条来适应多列数据的显示,同时解决窗口大小与内容显示的适配问题。
摘要由CSDN通过智能技术生成

滚动水平条时出现问题。当我添加另一列时是完整的

我要离开展示它的窗口。是否可以永久设置treeview的大小并用水平条滚动列?

目前屏幕可能太小。显示数据内容。在

这是我的消息来源def wczytaj_dane(page):

ok = Toplevel()

width_of_window = 1030

height_of_window = 570

screen_width = ok.winfo_screenwidth()

screen_height = ok.winfo_screenheight()

x_coordinate = (screen_width/2) - (width_of_window/2)

y_coordinate = (screen_height/2) - (height_of_window/2)

ok.geometry("%dx%d+%d+%d" % (width_of_window, height_of_window, x_coordinate, y_coordinate))

"""Polączenie z bazą danych oraz pobieranie danych"""

connection = pymysql. connect ( host = '192.168.10.100' ,

database = 'tester_produkcja' ,

user = 'marcin' ,

password = 'marcin96' )

try:

with connection . cursor () as cursor :

sql= "SELECT * FROM `Historia` WHERE `Poczernin_kod_Produktu`='DP^8E0E1^0005'"

cursor.execute ( sql,)

result_dpcode = cursor.fetchall () #fetchone ()

""" zamiana krotki(tuple) na liczbę całkowitą"""

#result_dp = int(result_dpcode[0])

finally:

connection.close()

tree = ttk.Treeview(ok,height=5)

tree["columns"]=("one","two","three","four","five","six","seven","eight","nine","ten","ten1","ten2","ten3","ten4","ten5",

"ten6","ten7")

tree.column("#0", width=40)

tree.column("one", width=100 )

tree.column("two", width=50)

tree.column("three", width=220)

tree.column("four", width=50 )

tree.column("five", width=50)

tree.column("six", width=50)

tree.column("seven", width=50)

tree.column("eight", width=50)

tree.column("nine", width=50)

tree.column("ten", width=50)

tree.column("ten1", width=50)

tree.column("ten2", width=70)

tree.column("ten3", width=70)

tree.column("ten4", width=125)

tree.column("ten5", width=120)

tree.column("ten6", width=100)

tree.column("ten7", width=100)

tree.heading("#0", text="Lp.")

tree.heading("one", text="Godzina/Data")

tree.heading("two", text="KTM")

tree.heading("three",text="Nazwa Produktu")

tree.heading("four",text="Funkcja")

tree.heading("five",text="PW")

tree.heading("six", text="VAC")

tree.heading("seven",text="WATT")

tree.heading("eight",text="ŁAD")

tree.heading("nine",text="ROZŁ")

tree.heading("ten",text="VDC")

tree.heading("ten1",text="Uwagi")

tree.heading("ten2",text="Pracownik")

tree.heading("ten3",text="Inspektor")

tree.heading("ten4",text="Poprawność Montażu")

tree.heading("ten5",text="Wygląd zewnętrzny")

tree.heading("ten6",text="Wygląd zewnętrzny")

tree.heading("ten7",text="Wygląd zewnętrzny")

cpt = 0

for row in result_dpcode:

tree.insert('','end', text=str(cpt), values=(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],

row[9],row[10],row[11],row[12],row[13],row[14],row[15] ))

cpt +=1

ysb = ttk.Scrollbar (ok, orient = 'vertical', command = tree.yview)

xsb = ttk.Scrollbar (ok, orient = 'horizontal', command = tree.xview)

tree.grid(row=0,column=0)

ysb.grid (row = 0, column = 1, sticky = N+S)

xsb.grid (row = 1,column = 0, sticky = E+W)

tree.configure (yscroll = ysb.set)

tree.configure (xscroll = xsb.set)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值