I'm trying to make a UI using Tkinter and I'm having problems to put three Scrollbars
inside LabelFrames
.
I've an array called self.que_lt_ver
that contains some names: self.que_lt_ver = ['CARGA', 'MAQUINA', SOLTAR']
. I want to create 3 LabelFrames and each one with a Scrollbar
. I've created a Canvas
for it, but it only shows the Scroll for the last window:
So how can I modify the code to show a scroll for each LabelFrame
?
This is the part of the code where the windows are created:
def createBox(self, window):
for i in xrange(len(self.que_lt_ver)):
mybox = LabelFrame(window, padx=5, pady=4)
mybox.grid(row=i, column=0)
self.createWindow(mybox, self.que_lt_ver[i], i)
def createWindow(self, box, lt_actual, i):
self.canvas = Canvas(box, borderwidth=0)
frame = Frame(self.canvas)
vsb = Scrollbar(box, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=vsb.set, width=1200, heigh=80)
vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window((4,4), window=frame, anchor="nw", tags="frame")
frame.bind("<Configure>", self.OnFrameConfigure)
self.fillWindow(lt_actual, frame)
def fillWindow(self, lt_ver, frame):
piezas = ['time: 39.41597 BT: 3025.5923', 'time: 21.637377 BT: 3025.5923', 'time: 52.185192 BT: 3025.5923', 'time: 57.804752 BT: 3025.5923', 'time: 47.700306 BT: 3025.5923', 'time: 21.1827 BT: 3025.5923', 'time: 35.244156 BT: 3025.5923', 'time: 47.26321 BT: 3025.5923']
fechaentrada = ['26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '21-02-2014']
fechasalida = ['26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '26-02-2014', '21-02-2014']
horacomienzo = ['12:00', '12:39', '01:00', '01:52', '02:49', '03:36', '03:57', '12:00']
horafinal = ['12:39', '01:00', '01:52', '02:49', '03:36', '03:57', '04:32', '12:47']
ide = [0, 1, 2, 3, 4, 5, 6, 7]
self.idpieza_w1 = Label(frame, text = "Id", width=20, font="bold")
self.idpieza_w1.grid(row=0, column=0)
self.pieza_w1 = Label(frame, text = "Pieza", width=20, font="bold")
self.pieza_w1.grid(row=0, column=1)
self.fechainiciopromo_w1 = Label(frame, text = "Dia inicio " + str(lt_ver), width=20, font="bold")
self.fechainiciopromo_w1.grid(row=0, column=2)
self.horainiciopromo_w1 = Label(frame, text = "Hora inicio " + str(lt_ver), width=20, font="bold")
self.horainiciopromo_w1.grid(row=0, column=3)
self.fechafinalpromo_w1 = Label(frame, text = "Dia fin carga " + str(lt_ver), width=20, font="bold")
self.fechafinalpromo_w1.grid(row=0, column=4)
self.horafinalpromo_w1 = Label(frame, text = "Hora final carga " + str(lt_ver), width=20, font="bold")
self.horafinalpromo_w1.grid(row=0, column=5)
for i in xrange(len(piezas)):
self.idtextos_w1 = Label(frame, text=str(ide[i]))
self.idtextos_w1.grid(row=i+1, column=0)
self.textos_w1 = Label(frame, text=str(piezas[i]))
self.textos_w1.grid(row=i+1, column=1)
self.fechainiciogrid_w1 = Label(frame, text=str(fechaentrada[i]))
self.fechainiciogrid_w1.grid(row=i+1, column=2)
self.horainiciogrid_w1 = Label(frame, text=str(horacomienzo[i]))
self.horainiciogrid_w1.grid(row=i+1, column=3)
self.fechafinalgrid_w1 = Label(frame, text=str(fechasalida[i]))
self.fechafinalgrid_w1.grid(row=i+1, column=4)
self.horafinalgrid_w1 = Label(frame, text=str(horafinal[i]))
self.horafinalgrid_w1.grid(row=i+1, column=5)
def OnFrameConfigure(self, event):
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
Thanks in advance.
See Question&Answers more detail:
os