Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to make a matching game, but when I try to run the program, it wont even pull up a window. Can someone please

I'm trying to make a matching game, but when I try to run the program, it wont even pull up a window. Can someone please tell me what its missing? I just dont know why its not even pulling up a window. (Edit. is this better?)

from tkinter import * from tkinter.ttk import * import random from Windowpro import Window def getList() : file = open("colorsMatch.txt", "r") line = None line = file.readline() allColors = [] while line : allColors.append(line) line = file.readline() file.seek(0) line = file.readline() while line : allColors.append(line) line = file.readline() random.shuffle(allColors) file.close() return allColors def main () : myList = getList() window = Window().makeWindow( myList) mainloop()

Windopro:

from tkinter import * from tkinter.ttk import * class Window: def __showSelection(self, button, index, myList) : button["text"] = myList[index -1] def turnOver (self, button, index) : button["text"] = str(index) def makeWindow(self, myList): myList = myList window = Tk() window.geometry ("800x800") window.title("Match Game") style = Style() style.configure('W.TButton', font = ('calibri', 24, 'bold', 'underline'), foreground = 'red', nackground = 'green') button = Button(window, text = "1", style = "W.TButton", command = lambda: self.__showSelection(button, 1, myList)) button.place(x=10, y = 50) button2 = Button(window, text = "2", style = "W.TButton", command = lambda: self.__showSelection(button2, 2, myList)) button2.place(x=200, y = 50) button3 = Button(window, text = "3", style = "W.TButton", command = lambda: self.__showSelection(button3, 3, myList)) button3.place(x=400, y = 50) button4 = Button(window, text = "4", style = "W.TButton", command = lambda: self.__showSelection(button4, 4, myList)) button4.place(x=600, y = 50) button5 = Button(window, text = "5", style = "W.TButton", command = lambda: self.__showSelection(button5, 5, myList)) button5.place(x=21, y = 200) button6 = Button(window, text = "6", style = "W.TButton", command = lambda: self.__showSelection(button6, 6, myList)) button6.place(x=200, y = 200) button7 = Button(window, text = "7", style = "W.TButton", command = lambda: self.__showSelection(button7, 7, myList)) button7.place(x=400, y = 200) button8 = Button(window, text = "8", style = "W.TButton", command = lambda: self.__showSelection(button8, 8, myList)) button8.place(x=600, y = 200) button9 = Button(window, text = "9", style = "W.TButton", command = lambda: self.__showSelection(button9, 9, myList)) button9.place(x=10, y = 400) button10 = Button(window, text = "10", style = "W.TButton", command = lambda: self.__showSelection(button10, 10, myList)) button10.place(x=200, y = 400) button11 = Button(window, text = "11", style = "W.TButton", command = lambda: self.__showSelection(button11, 11, myList)) button11.place(x=400, y = 400) button12 = Button(window, text = "12", style = "W.TButton", command = lambda: self.__showSelection(button12, 12, myList)) button12.place(x=600, y = 400) button13 = Button(window, text = "13", style = "W.TButton", command = lambda: self.__showSelection(button13, 13, myList)) button13.place(x=600, y = 400) button14 = Button(window, text = "14", style = "W.TButton", command = lambda: self.__showSelection(button14, 14, myList)) button14.place(x=600, y = 400) button15 = Button(window, text = "15", style = "W.TButton", command = lambda: self.__showSelection(button15, 15, myList)) button15.place(x=10, y = 600) button16 = Button(window, text = "16", style = "W.TButton", command = lambda: self.__showSelection(button16, 16, myList)) button16.place(x=200, y = 600) button17 = Button(window, text = "17", style = "W.TButton", command = lambda: self.__showSelection(button17, 17, myList)) button17.place(x=400, y = 600) button18 = Button(window, text = "18", style = "W.TButton", command = lambda: self.__showSelection(button18, 18, myList)) button18.place(x=600, y = 600) button19 = Button(window, text = "19", style = "W.TButton", command = lambda: self.__showSelection(button19, 19, myList)) button19.place(x=10, y = 800) button20 = Button(window, text = "20", style = "W.TButton", command = lambda: self.__showSelection(button20, 20, myList)) button20.place(x=200, y = 800) return window

txt file:

Blue Orange Pink Red Cyan Green Black White Yellow Bro

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

List out some inventory management techniques.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago