URL: https://linuxfr.org/forums/programmation-python/posts/interaction-scale-listbox Title: interaction SCALE LISTBOX Authors: DAN Date: 2018年11月07日T16:10:45+01:00 License: CC By-SA Tags: Score: -1 Bonjour à tous. Je suis débutant sur python mais je tiens bon. Voici un petit code pour tenter de vous expliquer mon problème. J'ai une fenêtre listbox et un Scale. Lorsque je sélectionne dans ma listbox une ligne, la 2par exemple je voudrais que mon scale se positionne automatiquement sur le 2. Lorsque je positionne mon scae sur le 3 par exemple je voudrais que la ligne trois correspondantes se met en surbrillance. J'ai fait ce petit code uniquement pour expliquer mon problème mais mon application gère en réalité des répertoires photos mais de ce côté-là pour le moment j'obtiens ce que je veux. D'avance merci à tous ceux qui pourront m'aider à résoudre ce problème. ```python import tkinter as tk import os, sys from PIL import ImageTk from tkinter import END from tkinter import * root = Tk() global value global NBL NBL =100 def save_value(val): global value value = listbox2.get(val) # value =(listbox2 .get(value)) print("avec scaol vous avez selzctionné la ligne ",val," ",value) #RRRRRRRRRRRRRRRRRRRRRRRRRRRR def LISTERIMAGES(NBL): #effacet contenu fr listbox2 listbox2.delete('0','end') NBL = 0 listbox2.insert(1, "Python") listbox2.insert(2, "Perl") listbox2.insert(3, "C") listbox2.insert(4, "PHP") listbox2.insert(5, "JSP") listbox2.insert(6, "a") listbox2.insert(7, "b") listbox2.insert(8, "n") listbox2.insert(9, ",") listbox2.insert(10, "v") listbox2.insert(11, "d") listbox2.insert(12, "Ruby") listbox2.insert(13, "o") NBL =12 NBL1 = NBL y = NBL1 interval =y/10 var = DoubleVar() Scale2 = Scale( root, orient='horizontal', from_=0, to=y, resolution=1, tickinterval=interval, #increment=50, length=300, command=save_value, variable = var, ) Scale2.place(x=300, y=5, width=400, height=60) #surligner #listbox2.selection_set(first=0) #TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT def onselect2(evt): # Note here that Tkinter passes an event object to onselect() w = evt.widget index = int(w.curselection()[0]) value = listbox2.get(index) print("danzs listbox2 vous avez selctionné la ligne ",index," ",value) #TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT from PIL import Image, ImageTk # on ajuste la frnetre a la dimention ecran width = .9*root.winfo_screenwidth() height =.9*root.winfo_screenheight() root.geometry("%dx%d" % (width, height)) # w.winfo_screenmmwidth()t.geometry("1200x800") root.title("change label on listbox selection") root.resizable(0,0) root.configure(background='lightgrey') #Show selected currency for from in label frmcur_text = tk.StringVar() frmcur = tk.Label(root, textvariable=frmcur_text, font="Helvetica 10 bold", anchor='w', background='lightgrey').place(x=195,y=50) #TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT #ggggggggggggggggggggggggggggggggg listbox2 = tk.Listbox(root, font="Helvetica 11 bold", height=10, width=50,) #Scale2 = Scale(root) #Scale2.place(x=300, y=7, width=400, height=60) #textlabel = Label(root) #textlabel.configure( height=3, width=50) #textlabel.place(x=800,y=20) listbox2.place(x=300,y=200) #FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF LISTERIMAGES(NBL) listbox2.bind('<>', onselect2) root.mainloop() ```

AltStyle によって変換されたページ (->オリジナル) /