Tkinter GUI freezes while running looping | import threading

 import threading


def open_ebay():
print('i did something')
thread = threading.Thread(target=ebay)
thread.start()
# thread.join()


def ebay():
inp = videos_Url.get(1.0, "end-1c")
count = 0
url_count = 0

root.after(1000, do_something())

for url_line in inp.splitlines():

time.sleep(1)
webbrowser.open(url_line, new=2, autoraise=True, )
time.sleep(5)
count += 1
url_count += 1
if count == 3:
webbrowser_name("chrome")
count = 0
print(f"No Proxy: | Url: {url_line}| total Url count {str(url_count)}")

tButton =  Button(root, text="Start Bot" , command=open_ebay).grid(row = 5, column = 3,   sticky = SE,   pady = 5, padx=5)


-----------------------------------------------------------------

import threading
import sys
import os
import webbrowser
sys.path.append(os.path.abspath("SO_site-packages"))
import pyperclip
import tkinter as tk


def ebay():
    current = ""
    new = pyperclip.paste()
    if new != current:
        current = new
        webbrowser.open('https://www.ebay.ca/sch/i.html?_from=R40&_nkw=' + str(new) + '&LH_Sold=1&LH_Complete=1&LH_ItemCondition=3000')


def open_ebay():
    thread = threading.Thread(target=ebay)
    thread.start()
    thread.join()


def main():
    root = tk.Tk()
    root.title("EbayPaste")
    root.geometry('400x300')
    tk.Button(root, text="load ebay from clipboard", command=open_ebay).pack()
    root.mainloop()


if __name__ == '__main__':
    main()
link: https://stackoverflow.com/questions/55597169/tkinter-ui-becomes-unresponsive-while-for-loop-is-running


Post a Comment

أحدث أقدم