我刚刚发现一个解决方案,它可能不是最好的,所以如果有人有任何建议,请写在下面。现在,我必须启动设置,在单击按钮后,当它导入UI时,它会自动打开UI,并按预期在控制台中打印链接。最好是相反的方式,这样用户界面可以打开设置并在其中存储变量。
设置
from UI import itemName, itemSize
itemLink = "predefined" + itemName.get() + "predefined" + itemSize.get()
print(itemLink)
print("end")
keys = {
"link": itemLink,
"email": "your acount email",
"password": "password"
}
用户界面
from tkinter import *
import time
import sys
import subprocess
def generate():
#subprocess.Popen("Nastavitve.py 1", shell=True)
import Settings
time.sleep(0.1)
window = Tk()
window.title("SHOP BOT")
window.configure(background="black")
Label(window, text="Item name").grid(row=0)
Label(window, text="Size").grid(row=1)
global itemName
global itemSize
itemName = Entry(window)
itemSize = Entry(window)
itemName.grid(row=0, column=1)
itemSize.grid(row=1, column=1)
button = Button(window, text="Generate link", fg="red",command=generate)
button.grid(row=0, column=2)
window.mainloop()