How am I able to open the contents of a text file into a GUI with each character in the text being an individual button. Say the text file contains 25 characters that are either "A" or "B" in random order. The text file also have 5 rows with which each row having five characters. All i have is this:
from Tkinter import *
from tkFileDialog import *
class Open(Frame):
def __init__(self,root):
Frame.__init__(self,root)
self.grid()
self.button()
def button(self):
self.button_list = []
for x in range(5):
self.button_list.append([])
for y in range(5):
button = Button (self, text = "")
button.bind("<Button-1>",self.open_file)
button.grid(row=x,column=y)
self.button_list[x].append(button)
def open_file(self,event):
file = askopenfile(mode = "rU")
lines = file.readlines()
for x in range(5):
for y in range(5):
if lines.config() == "X'
file.close()
(Driver code is goes here)