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
| import tkinter as tk
from tkinter import ttk
def on_configure(event):
canvas.configure(scrollregion=canvas.bbox('all'))
root = tk.Tk()
canvas = tk.Canvas(root)
canvas.pack(side=tk.LEFT,expand=1)
scrollbar = tk.Scrollbar(root, command=canvas.yview)
scrollbar.pack(side=tk.LEFT, fill='y')
canvas.configure(yscrollcommand = scrollbar.set)
canvas.bind('<Configure>', on_configure)
frame = tk.Frame(canvas,borderwidth=5)
canvas.create_window((0,0), window=frame, anchor='nw')
button = tk.Button(frame,text="Ok",command=lambda:ApplytoLabel()).grid(column=2)
height = 2
List_Entry = []
for i in range(height):
b = tk.Entry(frame, text="")
b.grid(row=i)
List_Entry.append(b)
Values = []
def ApplytoLabel():
for i in range(height):
Values_obtained = List_Entry[i].get()
L.append(Values_obtained)
return Values
print(ApplytoLabel())
root.mainloop() |
Partager