
Dimensionar scrollbar con listbox en Tkinter
Publicado por Alberto (2 intervenciones) el 29/12/2014 05:33:05
Hola que tal estoy realizando un programa donde tengo varios listbox en Tkinter, y coloque unas barras de desplazamiento pero como estoy utilizando el atributo de scrollbar.place(x, y), no he encontrado la manera de que la barra se vea de forma mas adecuada. Les muestro el codigo para ver si me pueden ayudar, como aun me falta colocar varias cosas no utilizo grid me parece mas adecuado el atributo place.
Las barras de desplazamiento de alguna manera ligan las tres listas, espero se entienda el problema y puedan ayudarme un poco
Gracias y saludos...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 25 22:54:07 2014
@author: albertnava
"""
from Tkinter import *
import tkMessageBox
import collections
from time import sleep
import os
from collections import deque
root=Tk()
root.geometry("850x850+300+300")
yScroll = Scrollbar(root, orient=VERTICAL)
xScroll = Scrollbar(root, orient=HORIZONTAL)
def yscroll1(*args):
if lb2.yview() != lb1.yview():
lb2.yview_moveto(args[0])
yScroll.set(*args)
def yscroll3(*args):
if lb3.yview() != lb1.yview():
lb3.yview_moveto(args[0])
yScroll.set(*args)
def yscroll2(*args):
if lb1.yview() != lb2.yview():
lb1.yview_moveto(args[0])
yScroll.set(*args)
def yview(*args):
lb1.yview(*args)
lb2.yview(*args)
lb3.yview(*args)
def xscroll1(*args):
if lb2.xview() != lb1.xview():
lb2.xview_moveto(args[0])
xScroll.set(*args)
def xscroll2(*args):
if lb1.xview() != lb2.xview():
lb1.xview_moveto(args[0])
xScroll.set(*args)
def xscroll3(*args):
if lb3.xview() != lb1.xview():
lb3.xview_moveto(args[0])
xScroll.set(*args)
def xview(*args):
lb1.xview(*args)
lb2.xview(*args)
lb3.xview(*args)
def Colocar():
inp=open("codigoCP4.txt","r")
for i in inp.readlines():
lb3.insert(END,i)
inp.close()
cod=open("proCod.txt","r")
proc=cod.readline()
lg=len(proc)/46
print lg
for i in range(lg):
lb2.insert(END, proc[i*45:45*(1+i)])
cod.close()
dirp=open("Dirpro.txt","r")
for i in dirp.readlines():
lb1.insert(END,i)
dirp.close()
lb1=Listbox(root,xscrollcommand=xscroll1,yscrollcommand=yscroll1,width=15,height=23)
lb2=Listbox(root,width=30,height=23,xscrollcommand=xscroll2,yscrollcommand=yscroll2)
lb3=Listbox(root,width=15,height=23,xscrollcommand=xscroll2,yscrollcommand=yscroll2)
lb2.place(x=250,y=30)
lb3.place(x=140, y=30)
lb1.place(x=20, y=30)
yScroll.config(command=yview)
yScroll.place(x=495,y=30)
xScroll.place(x=20,y=405)
xScroll.config(command=xview)
lista1=Label(root, text='Datos X')
lista1.place(x=640,y=10)
label1=Listbox(root, height=25, width=15)
label1.place(x=600,y=30)
lista2=Label(root, text='Datos H')
lista2.place(x=790,y=10)
label2=Listbox(root, height=25, width=15)
label2.place(x=750,y=30)
lista3=Label(root, text='Datos Y')
lista3.place(x=940,y=10)
label3=Listbox(root,height=25,width=15)
label3.place(x=900,y=30)
#boton1 = Button(root, text = "Cargar programa", command = Colocar,width=10)
#boton1.place(x=20,y=420)
mainloop()
Las barras de desplazamiento de alguna manera ligan las tres listas, espero se entienda el problema y puedan ayudarme un poco
Gracias y saludos...
Valora esta pregunta


0