#!/usr/bin/python3
import tkinter as tk
import tkinter.ttk as ttk
toplevel1 = tk.Tk()
width = 400
height = 500
x = (toplevel1.winfo_screenwidth() // 2) - (width // 2)
y = (toplevel1.winfo_screenheight() // 2) - (height // 2)
toplevel1.geometry('{}x{}+{}+{}'.format(width, height, x, y))
canvas = tk.Canvas(toplevel1, borderwidth=0, background="#ffffff")
frame= tk.Frame(canvas, background="#ffffff")
vsb = tk.Scrollbar(toplevel1, orient="vertical", command=canvas.yview)
canvas.configure(yscrollcommand=vsb.set)
vsb.pack(side="right", fill="y")
canvas.pack(fill=tk.BOTH, expand=1)
canvas.create_window((0,0), window=frame, anchor="nw", width=width, height=height)
def test(text):
str_var.set(text) # установить значение переменной
value = str_var.get() # получить значение переменной
print(value)
str_var = tk.StringVar(toplevel1) # задать переменную
img_ico_s = [] # массив картинок
img_z_1_s = [] # массив картинок
hhh = [["assets/ico.png","program","opis",1], ["assets/z.1.png","program1","opis1",2], ["assets/ico.png","program2","opias2",3]]# информация приложений 0 - название, 1 - описание, 2 - теги, 3 - номер программы
m = 0
for i in hhh:
str_var.set(i[3])
frame11 = ttk.Frame(frame)
label28 = ttk.Label(frame11)
img_ico_s.append(tk.PhotoImage(file=i[0]))
label28.configure(image=img_ico_s[m], text='label2')
label28.pack(side="left")
frame13 = ttk.Frame(frame11)
label26 = tk.Label(frame13, fg="blue", cursor="hand2")
label26.configure(text=f'{i[1]} - {i[2]}')
label26.pack(anchor="sw", side="top")
label26.bind("<Button-1>", lambda: test(i[1]))
label27 = ttk.Label(frame13)
label27.configure(text='теги: teg1 teg2 teg3 teg4')
label27.pack(anchor="sw", side="top")
frame12 = ttk.Frame(frame13)
frame12.configure(height=20, width=100)
label22 = ttk.Label(frame12)
# img_z_1 = tk.PhotoImage(file="assets/z.1.png")
img_z_1_s.append(tk.PhotoImage(file="assets/z.1.png"))
label22.configure(image=img_z_1_s[m], text='label16')
label22.pack(side="left")
label23 = ttk.Label(frame12)
label23.configure(image=img_z_1_s[m], text='label17')
label23.pack(side="left")
label24 = ttk.Label(frame12)
label24.configure(image=img_z_1_s[m], text='label18')
label24.pack(side="left")
label25 = ttk.Label(frame12)
label25.configure(image=img_z_1_s[m], text='label21')
label25.pack(side="left")
frame12.pack(side="right")
frame13.pack(anchor="n", padx=10, pady=10, side="left")
button2 = ttk.Button(frame11)
button2.configure(text='Установить', command=lambda: test(i[3]))
button2.pack(padx=20, side="right")
frame11.pack(expand=True, fill=tk.BOTH, side="bottom")
m += 1
canvas.update_idletasks()
canvas.configure(scrollregion=canvas.bbox("all"))
toplevel1.mainloop()