Kill thread, selenium, tkinter, tinder

332 Views Asked by At

When user press start it starts selenium goes to tinder logins and starts swiping, added another button to stop program but cant get my head around it to make it work code.py have function quit() that is driver.quit() but how to place that. I'm new to python and programming.Thanks

import threading
from tkinter import *
import code
import time


def liker():
    new_canvas.itemconfig(loading, text="Loading..Please wait")
    start = code.TinderBot()
    time.sleep(30)
    start.log()
    time.sleep(10)
    new_canvas.itemconfig(loading, text="Starting to swipe...")
    start.swipe()


def new_process():
    threading.Thread(target=liker).start()
    

def close_window():
    pass

def update_counter():
    new_canvas.itemconfig(likes_counter, text=code.count)
    window.after(1000, update_counter)


window = Tk()
window.minsize(width=640, height=359)
window.title("Tinder Bot")


img = PhotoImage(file="love.png")

new_canvas = Canvas(window, width=640, height=359)
new_canvas.pack(fill="both", expand=True)

new_canvas.create_image(0, 0, image=img, anchor="nw")
welcome = new_canvas.create_text(320, 50, text="Welcome to Tinder Bot", font=("Halvetica", 30))
loading = new_canvas.create_text(320, 150, text="Press Start", font=("Halvetica", 20))
likes = new_canvas.create_text(190, 200, text="Likes counter:", font=("Halvetica", 20))
likes_counter = new_canvas.create_text(310, 200, text="0", font=("Halvetica", 20))

start_button = Button(text="Start Program", command=new_process)
stop_button = Button(text="Stop Program", command=close_window)


button1 = new_canvas.create_window(320, 300, window=start_button)
button2 = new_canvas.create_window(320, 330, window=stop_button)

update_counter()

window.mainloop()
0

There are 0 best solutions below