[질문]파이썬으로 간단한 게임만드는중,,
-
안녕하세요 ㅠ 뉴욕에서 공부중인 대학생입니다, 파이썬으로 간단한 게임을 만들려 하는데요 , 돌아가는 방식은, 유저가 start버튼을 누르면, label2 에서 임의대로 여러가지 색깔을 순차적으로 보여준뒤 사라지고, 그후에 유저가 순서대로 색깔버튼을 눌러 맞추는 게임입니다, 지금 대략적인 버튼과 라벨은 위치해놨는데요 , 어떻게 임의의 색깔을 label2 에 나타나게 했다 없어지게 할수 있나요 ㅠㅜㅜㅠ? 또한 각각 버튼의 command functions 들은 어떻게 해야 될까요 ㅜ 고수님들 도움 부탁드립니다 ,
from tkinter import *
from counterWP import *class CreateColor:
def init(self):
root=Tk() root.title("Memory Game") colorFrame=Frame(root) levelFrame=Frame(root) winFrame=Frame(root) topFrame=Frame(root) midFrame=Frame(root) botFrame=Frame(root) button1=Button(topFrame,background='black',activebackground='white',height=10,width=20,command=self.button1) button2=Button(topFrame,background='pink',activebackground='white',height=10,width=20,command=self.button2) button3=Button(topFrame,background='red',activebackground='white',height=10,width=20,command=self.button3) button4=Button(midFrame,background='green',activebackground='white',height=10,width=20,command=self.button4) button5=Button(midFrame,background='blue',activebackground='white',height=10,width=20,command=self.button5) button6=Button(midFrame,background='purple',activebackground='white',height=10,width=20,command=self.button6) button7=Button(botFrame,background='orange',activebackground='white',height=10,width=20,command=self.button7) button8=Button(botFrame,background='navy',activebackground='white',height=10,width=20,command=self.button8) button9=Button(botFrame,background='lightblue',activebackground='white',height=10,width=20,command=self.button9) button10=Button(winFrame,text='START!') button10.pack(side=LEFT) self.__num=IntVar() self.__num.set([]) label1=Label(colorFrame,text="GOAL:") label2=Label(colorFrame,width=50,bg='lightpink',textvariable=self.__num) self.__level=IntVar() self.__level.set(1) label3=Label(levelFrame,text="LEVEL : ") label4=Label(levelFrame,textvariable=self.__level) label5=Label(levelFrame,text='CORRECT : ') self.__win=IntVar() self.__win.set(0) label6=Label(levelFrame,textvariable=self.__win) label1.pack(side=LEFT) label2.pack(side=LEFT) label3.pack(side=LEFT) label4.pack(side=LEFT) label5.pack(side=LEFT) label6.pack(side=LEFT) button1.pack(side=LEFT) button2.pack(side=LEFT) button3.pack(side=LEFT) button4.pack(side=LEFT) button5.pack(side=LEFT) button6.pack(side=LEFT) button7.pack(side=LEFT) button8.pack(side=LEFT) button9.pack(side=LEFT) colorFrame.pack() levelFrame.pack() winFrame.pack() topFrame.pack() midFrame.pack() botFrame.pack() root.mainloop()