我的问题是我只想将字符串“Karte1”一次添加到列表中。但是现在,字符串“Karte1”无限次添加到列表中..希望你能帮助我:)
import random
Deck1 = []
def startgame():
try:
"Karte1" not in Deck1
if True:
Deck1.append("Karte1")
if False:
pass
except:
pass
while True:
startgame()
print(Deck1)
Run Code Online (Sandbox Code Playgroud) 所以基本上我正在尝试制作多个进度条,每个progressbars值从0到100运行.但是现在我的函数也从其他函数中获取值,这看起来很奇怪.希望有人可以帮助我.谢谢 :)
# -*- coding: utf-8 -*-
import tkinter.ttk as ttk
import tkinter as tk
from threading import Thread
import time
class Main(object):
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master, width=400, height=400)
self.frame.pack(expand=True)
self.button = tk.Button(self.frame, text="Add Bar", command=self.start_thread)
self.button.pack(fill="y")
def start_thread(self):
self.t = Thread(target=self.add_bar)
self.t.start()
def add_bar(self):
self.var = tk.IntVar()
self.var.set(0)
self.progessbar = ttk.Progressbar(self.frame, variable=self.var, orient=tk.HORIZONTAL, length=200)
self.progessbar.pack()
self.add_values(self.var)
def add_values(self, var):
self.variable = var
for self.x in range(100):
time.sleep(0.1)
self.variable.set(self.x)
root = tk.Tk()
app = Main(root) …Run Code Online (Sandbox Code Playgroud)