0

I have created different lables of tables. I am having trouble with adding scroll bar with multiple labels.

from tkinter import Tk,Frame,Label,ttk
import time
from tkinter import *
from random import randint
import threading
mainwindow=Tk()

scroll=Scrollbar(mainwindow)
scroll.pack(side=RIGHT,fill=Y)


mainframe=Frame(mainwindow,bg="white")
mainframe.pack(fill="both",expand=True)

grid_frame=Frame(mainframe)

label=Label(mainframe,text="Numbers",bg="black",fg="white",padx=5,pady=5)
label.config(font=("Arial",18))
label.pack(fill="x")
no=1
for row in range(1,11):
    for column in range(1,11):
        label=Label(grid_frame,text=str(no),bg="red",fg="white",padx=5,pady=5)
        label.grid(row=row,column=column,padx=5,pady=5,sticky="nsew")
        no+=1

        grid_frame.grid_columnconfigure(column,weight=1)
            
        
            
grid_frame.pack(fill="x")

    
labels=[]
#grid data
for i in range(4):
    grid_frame=Frame(mainframe)
    label=Label(mainframe,text="Player "+str(i+1),bg="black",fg="white",padx=5,pady=5)
    label.config(font=("Arial",18))
    label.pack(fill="x")
    
    for row in range(3):
        for column in range(5):
            label=Label(grid_frame,text="Item ",bg="green",fg="white",padx=5,pady=5)
            label.grid(row=row,column=column,padx=5,pady=5,sticky="nsew")

            grid_frame.grid_columnconfigure(column,weight=1)
            
            #Add all labels here:
            labels.append(label)
            
    grid_frame.pack(fill="x")
def update1(i):
    labels[i].config(bg = "orange", fg = "white")
    mainwindow.update_idletasks()
    time.sleep(0.5)
def fun1():
    for i in range(40):
        update1(i)
mainwindow.update()
mainwindow.after(1000,fun1)
grid_frame.pack(side=LEFT)
mainwindow.mainloop()

I am having a trouble with scroll bar. I need to get scroll bar only for players not for full window and I stored all labels in array for convient use.

Kindly please help!!

prudhvi ch
  • 21
  • 3
  • you might want to look at [this](https://stackoverflow.com/questions/16188420/tkinter-scrollbar-for-frame) – JacksonPro Jan 21 '21 at 04:46
  • I have gone through that and did not able to achieve. I am beginner to tkinter. Kindly please modify my code by adding scroll bar through that I will be very clear with my task and with tkinter. – prudhvi ch Jan 21 '21 at 05:05
  • I am sorry but this question is marked as duplicate I will no longer be able to answer. – JacksonPro Jan 21 '21 at 05:06
  • Do I have to repost again? prudhvichallapalli@gmail.com this my mail id. I will be very thankful if you send the modified one to my mail. – prudhvi ch Jan 21 '21 at 05:07
  • No, You can make an edit to this question explaining why this question is not a duplicate. If the mods agrees then this question will be reopened. – JacksonPro Jan 21 '21 at 05:09

0 Answers0