当用户按下开始时,它开始 selenium 进入 tinder 登录并开始刷卡,添加了另一个按钮来停止程序,但我无法理解它以使其工作code.py
具有但如何放置它quit()
的功能。driver.quit()
我是 python 和编程新手。谢谢
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()