我如何在循环运行时进行此操作,以比较tkinter单选按钮的值

时间:2019-12-28 13:23:07

标签: python python-3.x user-interface tkinter while-loop

from source import *
from tkinter import *
from PIL import ImageTk, Image

# Basic Window
root = Tk()
root.title("Maple")
root.iconbitmap("maple.ico")
root.geometry("400x400")

# Maple Banner
banner = ImageTk.PhotoImage(Image.open("maple_banner.png"))
Label(image=banner).grid(row=0, column=0)


def run():
    if var == "ZERO":
        setup_system()
        auto_likes()
    else:
        auto_likes()


# Contents
var = StringVar()
Radiobutton(root, text="RUN FROM STAGE ZERO", variable=var, value="ZERO").grid(row=1, padx=120, sticky=W)
Radiobutton(root, text="RUN FROM STAGE ONE", variable=var, value="ONE").grid(row=2, padx=120, sticky=W)
Button(root, text="START", width=20, command=run).grid(row=3, pady=10)
Button(root, text="END", width=20, command=root.quit()).grid(row=4, pady=5)

#End
root.mainloop()

在上面的代码中,setup_system()和auto_likes()均起作用。 run()由于某种原因无法正常工作,即使var ==“ ZERO”,它也会直接运行else部分

0 个答案:

没有答案