0

Help me understand multi threading using the below example. The GUI freezes once I click the submit button. How to call a threading function?

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
label = tk.Label(text='vicks')
label.pack()

def fix():
    a=0
    for i in range(0,1000000000000000):
        a=i
    label['text']=a

button = tk.Button(text='sub', command=fix)
button.pack()
dropdown = ttk.Combobox()
dropdown.pack()

root.mainloop()
user1404
  • 179
  • 1
  • 3
  • 10
  • Read [While Loop Locks Application](https://stackoverflow.com/questions/28639228/python-while-loop-locks-application) – stovfl May 06 '19 at 12:16
  • 1
    import tkinter as tk from tkinter import ttk import threading root = tk.Tk() label = tk.Label(text='vinoth') label.pack() def fix(): a=0 b = threading.Thread(target=count, args=(a,)) b.start() def count(a): for i in range(0,10000000): a=i label['text'] = a button = tk.Button(text='sub', command=fix) button.pack() dropdown = ttk.Combobox() dropdown.pack() root.mainloop() This should work! Call a function from the button, that could trigger a thread (which in turn will call another function to do your job) – User1493 May 06 '19 at 14:36
  • Thanks, that works great. – user1404 May 06 '19 at 14:37

0 Answers0