There are 2 threads. One is providing the number, the other is the one using tkinter that catches the number once it is produced.
I use scrollbar for the number sequences. However, i want to see some details of what i click, like the square number.
For example, if i click 8 in Result,i can get 64 in Detail
picture of my idea
So how to achieve this? My current code is here:
from concurrent.futures import ThreadPoolExecutor
from tkinter import *
from time import sleep
global root
global scrollbar
global listb
def my_func1():
global root
global Scrollbar
root = Tk()
lbl1 = Label(root, text="Result:", fg='black',
font=("Helvetica", 16, "bold"))
lbl2 = Label(root, text="Detail:", fg='black',
font=("Helvetica", 16, "bold"))
lbl1.grid(row=0, column=0, sticky=W)
lbl2.grid(row=2, column=0, sticky=W)
frm = Frame(root)
frm.grid(row=1, columnspan=2, sticky=N + S + W + E)
try:
scrollbar = Scrollbar(frm, orient=VERTICAL)
global listb
listb = Listbox(frm, yscrollcommand=scrollbar.set, width=50)
scrollbar.config(command=listb.yview)
scrollbar.pack(side=RIGHT, fill=Y)
listb.pack(fill=BOTH, expand=YES)
detail = Listbox(root, height=10, font=("Helvetica", 12))
detail.grid(row=6, columnspan=2, sticky=E + W + N)
except:
pass
root.mainloop()
def my_func2():
global listb
sleep(0.1)
for i in range(1000):
sleep(0.3)
vw = listb.yview()
listb.insert(END, i)
listb.yview_moveto(vw[-1])
print(i)
executors_list = []
with ThreadPoolExecutor(max_workers=5) as executor:
executors_list.append(executor.submit(my_func1))
executors_list.append(executor.submit(my_func2))