I'm having trouble with my scrollbar. I tried something but each time I had a little trouble. now I can't even see the scrollbar, other times it doesn't fill the y-axis. firstly I tried without canvas, just with frame (allTelemtry) for using grid() but couldn't achieve it then tried with canvas so I can use pack() but still can't do it properly.
from tkinter import *
from tkinter import ttk
root = Tk()
root.state('zoomed')
# creating notebook
telemetry = ttk.Notebook(root, width=1083, height=200)
telemetry.place(x=440, y=560)
allTelemetry = Frame(telemetry)
allTelemetry.pack(fill="both", expand = 1)
# creating canvas for scrollbar
allTelemetryCanvas = Canvas(allTelemetry)
allTelemetryCanvas.pack(fill="both", expand = 1)
dotTelemetry = Frame(telemetry)
dotTelemetry.pack(fill="both", expand = 1)
telemetry.add(allTelemetry, text= u"Hepsini Goster")
telemetry.add(dotTelemetry, text= u"Anlik Telemetri")
#------------------------------------------------------------
teleTitle = [" ", "Takmno","Paketno","Zaman",
"1Basn","2Basn",
"Nem",
"1kseklik","2Ykseklik",
"rtifaFark","niHz","Scaklk","PilGerilimi",
"La1","Lo1","Al1",
"La2","Lo2","Al2",
"Drm",
"x","y","z",
"DnSays","Video"]
empty = Label(allTelemetryCanvas, text="",width=3)
empty.grid(row=0,column=0,padx=1, pady=1)
for j in range(1,25):
teleTitle[j] = teleTitle[j].encode('UTF-8')
entry = Label(allTelemetryCanvas,text=teleTitle[j].decode(),anchor='w', width=5, bd=2)
entry.grid(row=0, column=j,padx=1, pady=1)
packet=1
for i in range(1,10):
packetNum = Label(allTelemetryCanvas, text = packet, anchor="w",width=3)
packetNum.grid(row=i, column=0,pady=0.5)
packet = packet+1
for j in range(1,25):
takenData = Entry(allTelemetryCanvas,width=5)
takenData.grid(row=i, column=j,pady=0.5)
# !!!!!!!!!!!!!!!!!
scrollbar = ttk.Scrollbar(allTelemetry, orient='vertical', command=allTelemetryCanvas.yview)
scrollbar.pack(side=RIGHT, fill="y")
allTelemetryCanvas['yscrollcommand'] = scrollbar.set
root.mainloop()
source https://stackoverflow.com/questions/72664385/scrollbar-doesnt-fill-or-appear-tkinter
Comments
Post a Comment