【发布时间】:2020-01-20 21:36:20
【问题描述】:
作为一个整体,我对编程和 python 非常陌生,可能有一个简单的解决方案可以解决我在谷歌搜索中找不到的问题。
所以,问题在于Spared_list 的定义。当我从我的条目spared 中获取值并将它们放入我的列表中时,它们中的每一个都会在它们周围用撇号保存。当我想检查Count_up 的值是否存在于列表中时,这是程序稍后出现的问题。
import subprocess
import tkinter as tk
from tkinter import*
sparedlist=[]
def Spared_list():
print("reached spared list")
sparedlist.append(spared.get())
print(sparedlist)
def execute():
Count_up=0
while Count_up < 1000:
if Count_up in sparedlist:
Count_up=Count_up+1
print("HI")
else:
print("VKSK",Count_up," shut down",sep='')
Count_up = Count_up+1
Chaos = tk.Tk()
Chaos.title("remote shutdown")
tk.Label(Chaos, text="Enter number of spared device(s) (ex:123, if device=VKSK123)").pack()
spared = tk.Entry(Chaos)
spared.pack()
tk.Button(Chaos, text="add", activebackground="Green", command=Spared_list).pack()
tk.Button(Chaos, text="execute", background="Red", command=execute).pack()
我知道这可能不是编码和使用变量的正确方法,但我刚刚开始。
【问题讨论】:
标签: python tkinter append tkinter-entry