Tk Development Demo

Description

Create the "large" chunks of the layout (frames?). Uses different sizes and colors for the background. Later, after more has been filled in, the background colors and sizes will be removed.

# =========================================================
#
# =========================================================

# ---------------------------------------------------------
# --- imports
# ---------------------------------------------------------

import sys

# --- what version of Python an I running?

if sys.version_info.major == 3:
    from tkinter import *
    from tkinter.font import *
    py3 = True
else:
    from Tkinter import *
    from tkFont import *
    py3 = False


# ---------------------------------------------------------
# -- global variables
# ---------------------------------------------------------

canvasWidth  = 500
canvasHeight = 500

buttonFont = ('arial', 12, 'bold')
titleFont  = ('arial', 14, 'bold')

drawingAreaColors = ['red', 'light blue', 'green', 'orange']

lineColors = ['black', 'white', 'purple', 'yellow']

# ---------------------------------------------------------
# --- functions
# ---------------------------------------------------------

def quit():
    sys.exit()

def reset():
    pass

def drawingAreaBgColor():
    pass

# ---------------------------------------------------------
# --- main
# ---------------------------------------------------------

# --- root window

root = Tk()
root.title('Drawing Program')


# --- frame to hold everything

f = Frame(root, relief='flat', padx=4, pady=4, bg='red')
f.grid(row=0, column=0, sticky=N+S+E+W)


# --- title label

lt = Label(f, text='Drawing Program', font=titleFont, bg='light blue')
lt.grid(row=0, column=0)


# --- canvas drawing area

c = Canvas(f, width=canvasWidth, height=canvasHeight, bg='pink')
c.grid(row=1, column=0)


# --- frame for buttons

fb = Frame(f, relief='groove', padx=4, pady=4, bg='green')
fb.grid(row=2, column=0)

# --- background color buttons

rw = 0
cl = 0
for c in drawingAreaColors:
    b = Button(fb, text=c, bg=c, font=buttonFont)
    b.grid(row=rw, column=cl, sticky=EW)
    cl += 1


# --- line color buttons

rw += 1
cl = 0
for c in lineColors:
    b = Button(fb, text=c, bg=c, font=buttonFont)
    b.grid(row=rw, column=cl, sticky=EW)
    cl += 1 


# --- reset button

rw += 1
cl = 1
br = Button(fb, text='Reset', font=buttonFont, command=reset)
br.grid(row=rw, column=cl, sticky=EW)


# --- quit button

cl += 1
bq = Button(fb, text='Quit', font=buttonFont, command=quit)
bq.grid(row=rw, column=cl, sticky=EW)


# -- main loop

mainloop()