Hey Bytes Community!
I am currently using Tkinter to create a GUI window, and I ran into a problem. Here is my code:
The problem occurs under #Interface#. I am using the .grid geometry manager and it is giving me weird outputs. When I run the program, and click "GO!", it gives me something like this:
(attached)
anyway, I am wondering why the three buttons are outside of the specified place in the .grid-ing. And strangely, why is the one button inside? I am very confused, so help out please!
Thanks in advance!
I am currently using Tkinter to create a GUI window, and I ran into a problem. Here is my code:
Code:
from Tkinter import *
import random
import gameinclude
gi = gameinclude
class App:
def __init__(self, master):
##########
#Menu Bar#
##########
frame = Frame(master)
frame.grid()
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label='File', menu=filemenu)
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=None)
############
#Name Entry#
############
self.pone = Label(frame, text='Player One').grid(row=0, column=0)
self.epone = Entry(frame, textvariable = StringVar)
self.epone.grid(row=0, column=1)
self.ptwo = Label(frame, text='Player Two').grid(row=0, column=4)
self.eptwo = Entry(frame, textvariable = StringVar)
self.eptwo.grid(row=0, column=5)
self.activebtn = Button(frame, text='GO!', command = self.interface)
self.activebtn.grid(row=0, column=3)
###########
#Interface#
###########
def interface(self):
self.stats1 = Button(root, text='STATS', command=None)
self.stats1.grid(row=1, column=0)
self.stats2 = Button(root, text='STATS', command=None)
self.stats2.grid(row=1, column=4)
if gi.turn == 1:
self.attack1 = Button(root, text='ATTACK', fg='red', command=None)
self.attack1.grid(row=1, column=1)
self.attack2 = Button(root, text='ATTACK', fg='red', command=None, state=DISABLED)
self.attack2.grid(row=1, column=5)
if gi.turn == 2:
self.attack1 = Button(root, text='ATTACK', fg='red', command=None, state=DISABLED)
self.attack1.grid(row=1, column=1)
self.attack2 = Button(root, text='ATTACK', fg='red', command=None)
self.attack2.grid(row=1, column=5)
root = Tk()
root.title('Arena I')
app = App(None)
root.mainloop()
(attached)
anyway, I am wondering why the three buttons are outside of the specified place in the .grid-ing. And strangely, why is the one button inside? I am very confused, so help out please!
Thanks in advance!
Comment