Related
I have a window to display multiple treeview widgets. Currently there are some empty row spaces below the treeview when I expand it and I'm not sure on how to fill the empty spaces below dynamically when I expand the window. I have tried adjusting the rowspan/columnspan options but could not get the desired output as described in image below. I have also included a reproduceable code below for testing my program. Please help to advise on which part I need to make changes. Thanks!
import shutil
import tkinter as tk
import tkinter.ttk as ttk
import tempfile
import zipfile, re, os
from tkinter import *
from tkinter import filedialog
from pathlib import Path
import tkinter.messagebox
from fpdf import FPDF
from datetime import datetime, timedelta
import ctypes
DEPTH = 2
EXCLUDES = {'__MACOSX', 'resources'}
class HomePage(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
self.notebook = ttk.Notebook() # Create a notebook widget
self.add_tab1()
self.notebook.grid(row=0)
self.notebook.pack(expand=1, fill="both")
def add_tab1(self):
tab1 = tab_one(self.notebook)
self.notebook.add(tab1, text="Home")
class data_table(object):
def __init__(self, site, panels_count, tev_count):
self.site = site
self.panels_count = panels_count
self.tev_count = tev_count
class tab_one(Frame):
def __init__(self, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
# Creating frames on the window/canvas for the first tab
frame_selectfile = tk.LabelFrame(self, text="Step 1: Zip File Extraction ", bd=6) # Frame1 on the window/canvas
frame_selectfile.grid(column=0, row=0, padx=10, pady=10, sticky='NSEW') # Positioning frame1
frame_selectfile.configure(borderwidth=1)
self.grid_columnconfigure(1, weight=1) # Configuring the column for the main window/canvas
self.grid_rowconfigure(1, weight=1) # Configuring the row for the main window/canvas
frame_checkpd = tk.LabelFrame(self, text="Step 2: Check PD ", bd=6) # Frame2 on the window/canvas
frame_checkpd.grid(column=1, row=0, padx=10, pady=10, sticky='NSEW') # Positioning frame2
frame_checkpd.configure(borderwidth=1)
self.grid_columnconfigure(1, weight=1) # Configuring the column for the main window/canvas
self.grid_rowconfigure(1, weight=1) # Configuring the row for the main window/canvas
#Frame to display data in treeview
frame_tree = tk.LabelFrame(self, text="PD Results ", bd=6) # Frame2 on the window/canvas
frame_tree.grid(column=0, row=1, columnspan=2, rowspan=2, padx=10, pady=10, sticky='NSEW') # Positioning frame2
frame_tree.configure(borderwidth=1)
self.grid_columnconfigure(1, weight=1) # Configuring the column for the main window/canvas
self.grid_rowconfigure(1, weight=1) # Configuring the row for the main window/canvas
# Initializing all variables in frame_selectfile
file_ID = tk.StringVar()
location_id = tk.StringVar()
unzip_status = tk.StringVar()
tmpdir = tempfile.TemporaryDirectory().name
f_tem_sdir = open(os.getcwd()+"\\temp_dir.txt", "w")
f_tem_sdir.write(tmpdir)
f_tem_sdir.close()
zip_filename = tk.StringVar()
site_id = tk.StringVar()
site_id.set("0")
data_table_list = []
middleframe = tk.LabelFrame(frame_selectfile, bd=5)
databaseView = ttk.Treeview(middleframe, selectmode="browse")
label_filename = tk.Label(frame_selectfile, text=" ", width=10, relief='flat').grid(column=0, row=1, padx=5,
pady=5, sticky='NW')
label_filelocation = tk.Label(frame_selectfile, text="File Location:", width=12, relief='flat').grid(column=0,
row=2,
padx=5,
pady=5,
sticky='NW')
filename_Entry = tk.Label(frame_selectfile, width=52, textvariable=file_ID)
filename_Entry.grid(column=1, row=1, padx=5, pady=5, sticky='NW')
filename_Entry.configure(state='normal')
filelocation_Entry = tk.Entry(frame_selectfile, width=63, textvariable=location_id)
filelocation_Entry.grid(column=1, row=2, padx=5, pady=5, sticky='W')
filelocation_Entry.configure(background='palegreen', foreground='black')
unzip_status.set("")
label_unzipstatus = tk.Label(frame_selectfile, width=20, relief='flat', textvariable=unzip_status)
label_unzipstatus.grid(column=1, row=5, padx=5, pady=5, sticky='NSEW')
selectzip_button = tk.Button(frame_selectfile, width=20, text="Select Zip File",
command=lambda: self.upload_action(location_id, zip_filename, tmpdir))
selectzip_button.grid(column=1, row=3, padx=5, pady=3, ipady=3, sticky='SW')
unzip_button = tk.Button(frame_selectfile, width=20, text="Extract",
command=lambda: self.extract_nested_zip(databaseView, data_table_list,
location_id.get(), tmpdir, zip_filename,
site_id, False))
unzip_button.grid(column=1, row=3, padx=5, pady=3, ipady=3, sticky='NE')
# Creating LabelFrame in frame_unzip
upperframe = tk.LabelFrame(frame_selectfile, bd=0)
frame_selectfile.rowconfigure(0, weight=1)
frame_selectfile.columnconfigure(2, weight=1)
upperframe.grid(column=0, row=6, columnspan=2, sticky='W')
# middleframe = tk.LabelFrame(frame_selectfile, bd=5)
middleframe.configure(borderwidth=1)
frame_selectfile.columnconfigure(2, weight=1)
frame_selectfile.rowconfigure(1, weight=1)
middleframe.grid(column=0, row=7, columnspan=2, sticky="NSEW")
lowerframe = tk.LabelFrame(frame_selectfile, bd=0)
lowerframe.grid(column=0, row=7)
frame_selectfile.columnconfigure(2, weight=1)
frame_selectfile.rowconfigure(2, weight=0)
# Labels in frame_unzip
label18 = tk.Label(upperframe, text="Number of sites:", relief='flat')
label18.grid(column=0, row=0, padx=5, pady=5, sticky='W')
site_Entry = tk.Entry(upperframe, width=61, textvariable=site_id)
site_Entry.grid(column=1, row=0, padx=10, pady=5, sticky='E')
site_Entry.configure(state='normal', background='palegreen', foreground='black')
label_details = tk.Label(upperframe, text=" ", relief='flat')
label_details.grid(column=0, row=2, padx=5, pady=0, sticky='W')
databaseView.columnconfigure(2, weight=1)
databaseView.grid(column=0, row=0, columnspan=2, sticky="NSEW")
# Creating treeview in frame_unzip
vsb = Scrollbar(middleframe, orient="vertical", command=databaseView.yview())
hsb = Scrollbar(middleframe, orient="horizontal")
middleframe.columnconfigure(0, weight=1)
middleframe.rowconfigure(0, weight=1)
databaseView["show"] = "headings"
databaseView["columns"] = ("site", "panels", "tevs")
vsb.configure(command=databaseView.yview)
vsb.grid(column=1, row=0, sticky="NS")
# Treeview column headings
databaseView.heading("site", text="Site")
databaseView.column("site", anchor='w', width=250)
databaseView.heading("panels", text="Number of Panels")
databaseView.column("panels", anchor='center', width=150)
databaseView.heading("tevs", text="Number of TEVs")
databaseView.column("tevs", anchor='center', width=200)
findpd_btn = tk.Button(frame_checkpd, width=20, text="Find PDs",
command=lambda: self.run_pd_model_exe(tmpdir, zip_filename,parent_tree, tree))
findpd_btn.grid(column=0, row=0, padx=5, pady=5, sticky='E')
export_pdf_btn = tk.Button(frame_checkpd, width=20, text="Export to PDF",
command=lambda: self.export_to_pdf(tmpdir, location_id.get()))
export_pdf_btn.grid(column=1, row=0, padx=5, pady=5, sticky='E')
find_files_btn = tk.Button(frame_checkpd, width=20, text="Clear All",
command=lambda: self.clear_all_files(tmpdir,parent_tree,tree,databaseView))
find_files_btn.grid(column=2, row=0, padx=5, pady=5, sticky='W')
scrollbary = Scrollbar(frame_tree, orient=VERTICAL)
scrollbarx = Scrollbar(frame_tree, orient=HORIZONTAL)
parentframe = tk.LabelFrame(frame_checkpd, bd=0)
frame_checkpd.rowconfigure(2, weight=1)
frame_checkpd.columnconfigure(2, weight=1, )
parentframe.grid(column=0, row=1, columnspan=3, sticky='W')
# PARENT TREE
parent_tree = ttk.Treeview(parentframe,
columns=("1", "2",
"3", "4",
"5", "6",
"7", "8"),
selectmode="extended")
parent_tree.grid(row=1, column=0, pady=2, sticky=N + S + E + W)
#self.parent_tree.pack(expand=True, fill='both')
vsbb = Scrollbar(parentframe, orient="vertical", command=parent_tree.yview())
vsbb.configure(command=parent_tree.yview)
vsbb.grid(column=2, row=1, sticky="NS")
parent_tree.heading("#0", text="")
parent_tree.heading("1", text="File ID")
parent_tree.heading("2", text="Date")
parent_tree.heading("3", text="No")
parent_tree.heading("4", text="Engineer")
parent_tree.heading("5", text="Station")
parent_tree.heading("6", text="Voltage (kV)")
parent_tree.heading("7", text="Max dB")
parent_tree.heading("8", text="Max PD (%)")
# parent_tree.heading("8", text = "Panel No")
parent_tree.column('#0', stretch=YES, minwidth=0, width=5, anchor=CENTER)
parent_tree.column('#1', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#2', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#3', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#4', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#5', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#6', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#7', stretch=YES, minwidth=0, width=130, anchor=CENTER)
parent_tree.column('#8', stretch=YES, minwidth=0, width=130, anchor=CENTER)
# CHILD TREE
tree = ttk.Treeview(frame_tree,
columns=("1", "2", "3", "4"
, "5", "6", "7", "8"
, "9"),
selectmode="extended")
#yscrollcommand=scrollbary.set,
#xscrollcommand=scrollbarx.set)
tree.grid(row=0, column=0, pady=2, sticky=N + S + E + W)
# scrollbary.config(command=tree.yview)
# scrollbary.grid(row=0, column=1, pady=2, sticky=N + S)
#
# scrollbarx.config(command=tree.xview)
# scrollbarx.grid(row=2, column=0, sticky=W + E)
tree_vsb = Scrollbar(frame_tree, orient="vertical", command=tree.yview())
tree_hsb = Scrollbar(frame_tree, orient="horizontal")
tree_vsb.configure(command=tree.yview)
tree_vsb.grid(column=1, row=0, sticky="NS")
tree.heading("#0", text="")
tree.heading("1", text="Panel No")
tree.heading("2", text="TEV Name")
tree.heading("3", text="Component")
tree.heading("4", text="Sublocation")
tree.heading("5", text="Phase Ref Lock")
tree.heading("6", text="dB")
tree.heading("7", text="PRPD")
tree.heading("8", text="Pulse Wave")
tree.heading("9", text="PD %")
tree.column('#0', stretch=NO, minwidth=0, width=0, anchor=CENTER)
tree.column('#1', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#2', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#3', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#4', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#5', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#6', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#7', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#8', stretch=YES, minwidth=0, width=175, anchor=CENTER)
tree.column('#9', stretch=YES, minwidth=0, width=175, anchor=CENTER)
if __name__ == '__main__':
homePage = HomePage()
homePage.title("Waveform Identifier") # Window title
screen_width = homePage.winfo_screenwidth()
screen_height = homePage.winfo_screenheight()
width = 1600
height = 800
x = (screen_width / 2) - (width / 2)
y = (screen_height / 2) - (height / 2)
homePage.geometry("%dx%d+%d+%d" % (width, height, x, y))
homePage.resizable(1, 1)
homePage.mainloop()
Issues found
Wrong row number on frame_checkpd.rowconfigure(2, weight=1), it should be row 1.
Wrong sticky option on parentframe.grid(column=0, row=1, columnspan=3, sticky='W'), it should be 'NSEW'.
missing parentframe.rowconfigure(...) and parentframe.columnconfigure(...)
missing frame_tree.rowconfigure(...) and frame_tree.columnconfigure(...)
Below is the required changes to achieve it:
class tab_one(Frame):
def __init__(self, *args, **kwargs):
...
parentframe = tk.LabelFrame(frame_checkpd, bd=0)
frame_checkpd.rowconfigure(1, weight=1) ### row 2 -> 1
frame_checkpd.columnconfigure(2, weight=1, )
parentframe.grid(column=0, row=1, columnspan=3, sticky='NSEW') ### 'W' -> 'EW'
# PARENT TREE
parentframe.rowconfigure(1, weight=1) ### added
parentframe.columnconfigure(0, weight=1) ### added
...
# CHILD TREE
frame_tree.rowconfigure(0, weight=1) ### added
frame_tree.columnconfigure(0, weight=1) ### added
...
Result:
from tkinter import *
root = Tk()
root.geometry("400x400")
my_canvas = Canvas(root)
my_canvas["bg"] = '#808080'
my_canvas.place(relx=0, rely=0, relheight=1, relwidth=1)
This frame I want to change to fill the X axis instead of being dependent on grid inside it
frame = Frame(my_canvas, width=100, height=10)
frame.grid(row=0, column=0, padx=5, pady=5, sticky="ew")
example = Label(frame, text="Hello World!", bg="#1d1d1d", fg="#ffffff")
example.grid(row=1, column=1, sticky="ew")
root.mainloop()
I was wondering why when I use the columnspan parameter in the .grid() function the button does not change size. Should it not span all columns within the frame? Below I have my code and the output. Thanks all.
# Import Modules
from tkinter import ttk
import tkinter as tk
import os
# Basic Structure
root = tk.Tk()
root.minsize(600, 700)
root.maxsize(600, 700)
root.title("Training HUB")
root.config(bg="slategray")
# Create Frames - Title, Left and Right Frames
title_frame = tk.Frame(root, width=580, height=50, bg='white', highlightbackground="black", highlightthickness=1)
title_frame.grid(row=0, columnspan=2, padx=10, pady=5)
left_frame = tk.Frame(root, width=280, height=550, bg='white', highlightbackground="black", highlightthickness=1)
left_frame.grid(row=1, column=0, padx=10, pady=5)
left_frame.grid_propagate(0)
right_frame = tk.Frame(root, width=280, height=550, bg='white', highlightbackground="black", highlightthickness=1)
right_frame.grid(row=1, column=1, padx=10, pady=5)
right_frame.grid_propagate(0)
# Buttons
button1 = ttk.Button(right_frame, text="Run Processing").grid(
row=0, column=0, columnspan = 2, padx=5, pady=5, sticky = 'ew')
# Run Application
root.mainloop()
Tkinter Output:
My problem is: The output should show 2 side bars (column 0 and 2) with content Labels and Entrys and one central Window(column 1) much bigger than the other side bars in the middle. But the middle column always appears on the right side and as a very little frame.
Pls help.
My code and a picture:
import tkinter as tk, tkinter.ttk as ttk
root = tk.Tk()
root.title("THE FRIDGER")
root.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(2, weight=1)
#prepared data
dflt = dict(fg="white", bg="black")
pads = dict(pady=4, padx=4)
#header frame
header = tk.Frame(root, bg="black")
header.grid(row=0, column=0, columnspan=3, sticky="nsew")
for i in range(2):
header.grid_columnconfigure(i, weight=1)
#header labels
tk.Label(header, text="Fridge", **dflt).grid(column=0, row=0, **pads)
tk.Label(header, text="Recipes", **dflt).grid(column=1, row=0, **pads)
#separator
s = ttk.Style()
s.configure('custom.TSeparator', background='blue')
ttk.Separator(root, style='custom.TSeparator').grid(row=1, column=0, columnspan=3, sticky="ew")
#left side content
l_content = tk.Frame(root, bg="black")
l_content.grid(row=2, column=0, sticky="nsew")
tk.Label(l_content, text="Content:", **dflt).grid(column=0, row=0, sticky=tk.W)
l_query = tk.Entry(l_content, width=36, relief=tk.FLAT, bg = "white", fg = "black")
l_query.grid(column=0, row=1, sticky=tk.W)
#right side content
r_content = tk.Frame(root, bg="black")
r_content.grid(row=2, column=2, sticky="nsew")
tk.Label(r_content, text="Content:", **dflt).grid(column=0, row=2, sticky=tk.W)
r_query = tk.Entry(r_content, width=36, relief=tk.FLAT, bg = "white", fg = "black")
r_query.grid(column=0, row=3, sticky=tk.W)
#middle content
m_content = tk.Frame(root, bg="white")
m_content.grid(row=2, column=1, sticky="nsew")
tk.Label(m_content, text="This should appear in the middle", **dflt).grid(column=0, row=2, sticky=tk.W)
m_content.grid_columnconfigure(1, weight = 1)
root.mainloop()
The reason the left column is so large is that you are giving it a weight of 1. If you want the center column to take up all of the extra space, you need to give it a positive weight instead of giving the weight to column 0.
root.grid_columnconfigure(1, weight=1)
You set weight=1 on wrong column:
root.grid_columnconfigure(0, weight=1) should be root.grid_columnconfigure(1, weight=1)
m_content.grid_columnconfigure(1, weight=1) should be m_content.grid_columnconfigure(0, weight=1)
And remove sticky option from:
tk.Label(m_content, text="This should appear in the middle", **dflt).grid(column=0, row=2, sticky=tk.W)
Dear StackOverflow community,
I am trying to get my head around programming with Python and I am having a hard time with the grid layout manager. I have been trying to find the answer myself and tried various options, but I just can't get my UI to look how I want it to.
I hope that you can help me. Unfortunately, I cannot post pictures because I am new here. But basically I wanted all the coloured buttons on the left hand side EVENLY spaced on top each other, in column 1. Then the Labels in column 2 and the text areas in column 3.
I also wanted to create a border at the bottom with the close button underneath, but this doesn't even show up at all.
Please could you give me some hints as to what I am doing wrong?
import Tkinter
from Tkinter import *
from ttk import Frame, Button, Style
class KarateSyllabus(Frame):
"""A program that displays karate grading syllabi"""
#define the constructor
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
#define the GUI
def initUI(self):
#define the basic parameters of the window
self.parent.title("Karate Syllabus")
self.style = Style()
self.style.theme_use("default")
#self.parent.geometry("500x500")
self.parent.config(background = "black")
self.parent.wm_iconbitmap("favicon.ico")
self.grid()
#create the buttons for the syllabus
button1 = Tkinter.Button(self, text = "White Belt", bg = "white", height=1, width =10).grid(row=0, column=0, pady=4, padx=10, sticky=N)
button2 = Tkinter.Button(self, text = "Red Belt", bg="red", height=1, width =10).grid(row=1,column=0, pady=4, padx=10, sticky=N )
button3 = Tkinter.Button(self, text = "Orange Belt",bg="orange", height=1, width =10).grid(row=2,column=0, pady=4, padx=10, sticky=N)
button4 = Tkinter.Button(self, text = "Yellow Belt",bg="yellow", height=1, width =10).grid(row=3, column=0, pady=4, padx=10, sticky=N)
button5 = Tkinter.Button(self, text = "Green Belt", bg="green", height=1, width =10).grid(row=4, column=0, pady=4, padx=10, sticky=N)
button6 = Tkinter.Button(self, text = "Purple Belt",bg="purple", height=1, width =10).grid(row=5, column=0, pady=4, padx=10, sticky=N)
button7 = Tkinter.Button(self, text = "Brown Belt", bg="brown", height=1, width =10).grid(row=6, column=0, pady=4, padx=10, sticky=N)
button8 = Tkinter.Button(self, text = "Black Belt", bg="black", foreground="white", height=1, width =10).grid(row=7, column=0, pady=2, padx=10, sticky=N)
#create the three text areas to display the text and according labels
BasicsLabel = Label(self, text="Basics:").grid(row =0, column =2)
BasicTextArea = Text(self, width=50, height=6, takefocus=0)
BasicTextArea.grid(row=0, column=3, padx=10, pady=2)
BasicTextArea.config(font =("Arial",10), bg="grey", wrap = WORD)
KataLabel = Label(self, text="Kata:").grid(row =2, column =2)
KataTextArea = Text(self, width=50, height=6, takefocus=0)
KataTextArea.grid(row=2, column=3, padx=30, pady=2)
KataTextArea.config(font =("Arial",10), bg="grey")
KumiteLabel = Label(self, text="Kumite:").grid(row =3, column =2)
KumiteTextArea = Text(self, width=50, height=6, takefocus=0)
KumiteTextArea.grid(row=3, column=3, padx=10, pady=2)
KumiteTextArea.config(font =("Arial",10), bg="grey")
#create the second frame for the bottom with the close button
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.grid(row=8, column= 1)
closeButton = Button(self, text="Exit")
closeButton.grid(row = 8, column = 3)
def main():
root = Tk()
app = KarateSyllabus(root)
root.mainloop()
if __name__ == '__main__':
main()
It sounds like you don't need to be using grid, since you aren't creating a grid. It sounds like you want each column to be evenly spaced vertically, which precludes a grid-like layout.
You're creating three columns, so I would start with packing a frame along the bottom for your quit button, and then three vertical frames, packed left-to-right, all in the main window.
Next, pack the color buttons in the left-most frame, top to bottom. With the right options they will be evenly spaced (though you could also use grid if you want).
Finally, use the exact same technique for the other two columns - pack everything top-to-bottom, having each one expand to fill the area they are allotted.
You should use at least a Frame to group all the left buttons and another one for the Exit button, as in the following code:
import Tkinter
from ttk import Frame, Button, Style
class KarateSyllabus(Frame):
"""A program that displays karate grading syllabi"""
#define the constructor
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
#define the GUI
def initUI(self):
#define the basic parameters of the window
self.parent.title("Karate Syllabus")
self.style = Style()
self.style.theme_use("default")
#self.parent.geometry("500x500")
self.parent.config(background = "black")
self.parent.wm_iconbitmap("favicon.ico")
self.grid(sticky=Tkinter.NSEW)
button_panel = Frame(self)
#create the buttons for the syllabus
button1 = Tkinter.Button(button_panel, text="White Belt", bg="white", height=1, width =10).grid(row=0, column=0, pady=4, padx=10, sticky=Tkinter.N)
button2 = Tkinter.Button(button_panel, text="Red Belt", bg="red", height=1, width =10).grid(row=1, column=0, pady=4, padx=10, sticky=Tkinter.N)
button3 = Tkinter.Button(button_panel, text="Orange Belt", bg="orange", height=1, width =10).grid(row=2, column=0, pady=4, padx=10, sticky=Tkinter.N)
button4 = Tkinter.Button(button_panel, text="Yellow Belt", bg="yellow", height=1, width =10).grid(row=3, column=0, pady=4, padx=10, sticky=Tkinter.N)
button5 = Tkinter.Button(button_panel, text="Green Belt", bg="green", height=1, width =10).grid(row=4, column=0, pady=4, padx=10, sticky=Tkinter.N)
button6 = Tkinter.Button(button_panel, text="Purple Belt", bg="purple", height=1, width =10).grid(row=5, column=0, pady=4, padx=10, sticky=Tkinter.N)
button7 = Tkinter.Button(button_panel, text="Brown Belt", bg="brown", height=1, width =10).grid(row=6, column=0, pady=4, padx=10, sticky=Tkinter.N)
button8 = Tkinter.Button(button_panel, text="Black Belt", bg="black", height=1, width =10, foreground="white").grid(row=7, column=0, pady=2, padx=10, sticky=Tkinter.N)
button_panel.grid(row=0, column=0, rowspan=3, sticky=Tkinter.N)
#create the three text areas to display the text and according labels
BasicsLabel = Tkinter.Label(self, text="Basics:").grid(row=0, column=1, sticky=Tkinter.N)
BasicTextArea = Tkinter.Text(self, width=50, height=6, takefocus=0)
BasicTextArea.grid(row=0, column=2, padx=10, pady=2, sticky=Tkinter.NSEW)
BasicTextArea.config(font=("Arial",10), bg="grey", wrap=Tkinter.WORD)
KataLabel = Tkinter.Label(self, text="Kata:").grid(row=1, column=1, sticky=Tkinter.N)
KataTextArea = Tkinter.Text(self, width=50, height=6, takefocus=0)
KataTextArea.grid(row=1, column=2, padx=10, pady=2, sticky=Tkinter.NSEW)
KataTextArea.config(font =("Arial",10), bg="grey")
KumiteLabel = Tkinter.Label(self, text="Kumite:").grid(row=2, column=1, sticky=Tkinter.N)
KumiteTextArea = Tkinter.Text(self, width=50, height=6, takefocus=0)
KumiteTextArea.grid(row=2, column=2, padx=10, pady=2, sticky=Tkinter.NSEW)
KumiteTextArea.config(font=("Arial",10), bg="grey")
#create the second frame for the bottom with the close button
close_frame = Tkinter.Frame(self, relief=Tkinter.RAISED, borderwidth=2)
close_frame.grid(row=3, column=0, columnspan=3, sticky=Tkinter.EW)
close_frame.columnconfigure(0, weight=1)
closeButton = Tkinter.Button(close_frame, text="Exit", command=self.quit)
# Move 'Exit' to the right. Comment out next line to leave it centered.
closeButton.grid(sticky=Tkinter.E)
self.rowconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
self.rowconfigure(2, weight=1)
# Leave row 3 (close_frame) non-expandable.
# Leave columns 1 and 2 (button_panel and labels) non-expandable.
self.columnconfigure(2, weight=1)
self.parent.rowconfigure(0, weight=1)
self.parent.columnconfigure(0, weight=1)
def main():
root = Tkinter.Tk()
app = KarateSyllabus(root)
root.mainloop()
if __name__ == '__main__':
main()