Scrollbar sur groupe de wigets
Résolu
Phil_1857
Messages postés
1956
Statut
Membre
-
Phil_1857 Messages postés 1956 Statut Membre -
Phil_1857 Messages postés 1956 Statut Membre -
A voir également:
- Canvas.create_window
- Comment créer un groupe whatsapp - Guide
- Sous groupe whatsapp - Accueil - WhatsApp
- Comment créer un groupe sur facebook - Guide
- Mail groupé - Guide
- Comment supprimer un groupe sur messenger - Astuces et Solutions
4 réponses
Salut, le scroll s'applique au contenu du canvas, or dans ton code, ton canvas ne contient aucun item. Il faut donc intégrer tes items sur le canvas avec create_window.
Par exemple.
from tkinter import *
WIDTH, HEIGHT = 1000, 600
main_win = Tk()
main_win.title('Test')
main_win.geometry(f'{WIDTH}x{HEIGHT}+200+50')
f1 = Frame(main_win, width=230, height=500, bd=2, relief=GROOVE)
f1.place(x=10, y=10)
graph_area = Canvas(f1, height=580, width=185)
graph_area.pack(side=LEFT)
e = []
for k in range(40):
l = Label(graph_area, text='{:0>2d}'.format(k + 1))
graph_area.create_window(10, k * 25, window=l)
e.append(Entry(graph_area))
graph_area.create_window(110, k * 25, window=e[k])
scroll = Scrollbar(f1, command=graph_area.yview)
scroll.pack(side='right', fill=Y)
graph_area.config(
yscrollcommand=scroll.set,
yscrollincrement=25,
scrollregion=graph_area.bbox(ALL),
)
main_win.mainloop()
Au lieu de label, tu pourrais à la place utiliser canvas.text.
Bonjour,
merci bien, ça marche
je pensais que créer les widgets dans le canvas ( l = Label(graph_area,... ) était suffisant..
yg_be
Messages postés
24281
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 585
bonjour,
si tu partages ton code, nous pouvons essayer.
cela coince où?
Bonjour yg_be,
Le code avec ajout de scrollbar :
# -*- coding:Utf-8 -*-
# 28/02/2023 14:45:16
from tkinter import *
WIDTH, HEIGHT = 1000, 600
main_win = Tk()
main_win.title('Test')
main_win.geometry(str(WIDTH)+'x'+str(HEIGHT)+'+200+50')
f1 =Frame(main_win, width = 230, height = 500, bd = 2, relief = GROOVE)
f1.place(x=10,y=10)
graph_area = Canvas(f1,height=580,width=185)
graph_area.pack(side =LEFT)
yp = 10
e = []
for k in range(40):
l = Label(graph_area, text = '{:0>2d}'.format(k))
l.place(x=10,y = yp)
e.append(Entry(graph_area))
e[k].place(x=30,y = yp)
yp += 25
scrol =Scrollbar(f1, command = graph_area.yview)
scrol.pack(side = 'right', fill = Y)
graph_area.config(yscrollcommand = scrol.set)
main_win.mainloop()