Rainbox Six Siege에 대한 임의의 연산자 이름 생성기를 프로그래밍했으며 이름이 올라 왔을 때 연산자 그림을 표시합니다. 이미지는 잘 보이지만 사라지지 않을 것입니다. 내가 필요로하는 모든이 나타나는 일단 사진을 제거하는 방법을 알고있다, 이것은 여전히 WIP입니다 :tkinter에서 이미지가 사라지게 만드는 방법
from tkinter import *
import tkinter
import random
names = ['Sledge','Thatcher','Ash','Thermite','Twitch','Montagne','Glaz','Fuze','Blitz','IQ','Buck','Blackbeard','Capitão','Hibana']
name = ["Smoke","Mute","Castle","Pulse","Doc","Rook","Kapkan","Tachanka","Jäger","Bandit","Frost","Valkyrie","Caveira","Echo"]
root = tkinter.Tk()
def pickName():
rad = random.choice(names)
photo = PhotoImage(file=rad+".png")
label = Label(image=photo)
label.image = photo # keep a reference!
label.pack()
nameLabel.configure(text=rad, foreground="white", background="blue")
root.configure(background='blue')
def pickName1(): nameLabel.configure(text=random.choice(name),background="orange",foreground="black")
root.configure(background='orange')
root.title("Operator Picker")
root.geometry("250x100")
nameLabel = tkinter.Label(root, text="", font=('Helvetica', 32))
nameLabel.pack()
Grid()
f1 = tkinter.Frame(root, height=100, width=100) #defines frame size in
pixels
f1.pack(side=tkinter.LEFT) #packs on the left
f1.pack_propagate(0) #tells frame not to let children control size
pickButton1 = tkinter.Button(f1, command=pickName, text="Pick
Attack",background="blue",foreground="white")
pickButton1.pack(fill=tkinter.BOTH, expand=1) #takes up all available space
f2 = tkinter.Frame(root, height=100, width=100)
f2.pack(side=tkinter.RIGHT)
f2.pack_propagate(0)
pickButton2 = tkinter.Button(f2, command=pickName1, text="Pick
Defend",background="orange",foreground="black")
pickButton2.pack(fill=tkinter.BOTH, expand=1)
root.mainloop()
참고 :이 내 코드입니다. 두 개 이상의 이미지가 나타날 때의 모습입니다. https://imgur.com/eroXLLn
당신도 기존의 위젯이 사라 만들기 위해 노력하고 어디 어디에서나 볼 수 없습니다. 당신은 그것을 파괴하지 않으며 당신은 그것을 숨기지 않습니다. –
@BryanOakley 나는 그가 어떻게하는지 모른다고 생각한다. – Nae
@BryanOakley 예 내 문제를 해결하는 방법을 모르겠다. –