SHOW:
|
|
- or go back to the newest paste.
1 | import tkinter as tk | |
2 | from tkinter import Listbox | |
3 | from tkinter import Entry | |
4 | ||
5 | ventana = tk.Tk() | |
6 | ventana.geometry("500x500") | |
7 | ||
8 | var = tk.StringVar() | |
9 | var.set(tuple(range(100))) | |
10 | ||
11 | lb = Listbox(ventana,width=27,height=27,listvariable=var) | |
12 | lb.place(x=50,y=50) | |
13 | lb.config(background="#FFFFFF") | |
14 | ||
15 | def enter(_): | |
16 | entrylistBox.place_forget() | |
17 | lb.config(state="normal") | |
18 | select = lb.curselection() | |
19 | valor_ = entrylistBox.get() | |
20 | lb.delete(select) | |
21 | lb.insert(select,valor_) | |
22 | ||
23 | def doubleClick(_): | |
24 | lb.config(state="disabled",disabledforeground="#A2A2A2") | |
25 | valor = lb.get(lb.curselection()) | |
26 | _, y, _, h = lb.bbox(lb.curselection()) | |
27 | x = lb.winfo_x() | |
28 | y += lb.winfo_y() | |
29 | w = lb.winfo_width() | |
30 | ||
31 | global entrylistBox | |
32 | entrylistBox = Entry(ventana) | |
33 | entrylistBox.focus_set() | |
34 | entrylistBox.place(x=x,y=y,width=w,height=h) | |
35 | entrylistBox.config(highlightthickness=2,highlightcolor="green") | |
36 | entrylistBox.insert(0,valor) | |
37 | entrylistBox.bind('<Return>', enter) | |
38 | ||
39 | lb.bind('<Double-Button-1>', doubleClick) | |
40 | ||
41 | ventana.mainloop() |