Hey Bytes Community!
I am learning Tkinter GUI and have come across a problem.
what i want to do (the important parts are underlined), is be able to recall the strings inputted in the GUI.
so if i said:
print(hmn1)
it would say what was put into the entry boxes.
similarly, a = input('')
print(a)
any help would be appreciated!
Thanks!
I am learning Tkinter GUI and have come across a problem.
Code:
from Tkinter import * import random class App: def __init__(self, master): frame = Frame(master) frame.pack() menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label='File', menu=filemenu) filemenu.add_command(label='Practice', command=self.namesetare) filemenu.add_command(label='Story Mode', command=self.namesetadv) filemenu.add_command(label='Quit', command=frame.quit) infomenu = Menu(menu) menu.add_cascade(label='About...', menu=infomenu) infomenu.add_command(label='About BattlerIII', command=self.about) def namesetare(self): nsa = Toplevel() self.pone = Label(nsa, text='Player One:').grid(row=0) [U]self.e1 = Entry(nsa).grid(row=0, column=1)[/U] self.ptwo = Label(nsa, text='Player Two:').grid(row=1) [U]self.e2 = Entry(nsa).grid(row=1, column=1)[/U] self.next = Button(nsa, text='Next', command=self.arena) self.next.grid(row=2, column=1) return self.e1 def arena(self): areone = Toplevel() [U]hmn1 = str(self.e1.get()) hmn2 = str(self.e2.get())[/U] self.text1 = Label(areone, text=hmn1) self.text1.pack() aretwo = Toplevel() self.text2 = Label(aretwo, text=hmn2) self.text2.pack() self.attack1 = Button(areone, text='ATTACK', fg='red', command=self.atk1) self.attack1.pack(side=LEFT) self.attack2 = Button(aretwo, text='ATTACK', fg='red', command=self.atk2) self.attack2.pack(side=LEFT) root = Tk() root.title('BattlerIII') app = App(None) root.mainloop()
so if i said:
print(hmn1)
it would say what was put into the entry boxes.
similarly, a = input('')
print(a)
any help would be appreciated!
Thanks!
Comment