I am doing my major work for SDD and i am making checkers, i have searched and tried many differnt solutions but nothing has worked, i am trying to make the window size set to 800x800 and have "Checkers" as a title and 4 buttons down the bottom, i would like to have a space between checkers and the 4 buttons but i have had no luck so far.

here is my code

from Tkinter import *
import Tkinter as tk
def startMenu():
    top = tk.Tk()
    top = tk.Canvas(width="800", height="800")
##    top.geometry("800x800")
    top.pack(fill='both', expand='yes')
    square1 = top.create_rectangle(0,0,100,100, fill="white")
    square2 = top.create_rectangle(100,0,200,100, fill="black")
    square3 = top.create_rectangle(200,0,300,100, fill="white")
    square4 = top.create_rectangle(300,0,400,100, fill="black")
    square5 = top.create_rectangle(400,0,500,100, fill="white")
    square6 = top.create_rectangle(500,0,600,100, fill="black")
    square7 = top.create_rectangle(600,0,700,100, fill="white")
    square8 = top.create_rectangle(700,0,800,100, fill="black")
    square9 = top.create_rectangle(0,100,100,200, fill="black")
    square10 = top.create_rectangle(100,100,200,200, fill="white")
    square11 = top.create_rectangle(200,100,300,200, fill="black")
    square12 = top.create_rectangle(300,100,400,200, fill="white")
    square13 = top.create_rectangle(400,100,500,200, fill="black")
    square14 = top.create_rectangle(500,100,600,200, fill="white")
    square15 = top.create_rectangle(600,100,700,200, fill="black")
    square16 = top.create_rectangle(700,100,800,200, fill="white")
    square17 = top.create_rectangle(0,200,100,300, fill="white")
    square18 = top.create_rectangle(100,200,200,300, fill="black")
    square19 = top.create_rectangle(200,200,300,300, fill="white")
    square20 = top.create_rectangle(300,200,400,300, fill="black")
    square21 = top.create_rectangle(400,200,500,300, fill="white")
    square22 = top.create_rectangle(500,200,600,300, fill="black")
    square23 = top.create_rectangle(600,200,700,300, fill="white")
    square24 = top.create_rectangle(700,200,800,300, fill="black")
    square25 = top.create_rectangle(0,300,100,400, fill="black")
    square26 = top.create_rectangle(100,300,200,400, fill="white")
    square27 = top.create_rectangle(200,300,300,400, fill="black")
    square28 = top.create_rectangle(300,300,400,400, fill="white")
    square29 = top.create_rectangle(400,300,500,400, fill="black")
    square30 = top.create_rectangle(500,300,600,400, fill="white")
    square31 = top.create_rectangle(600,300,700,400, fill="black")
    square32 = top.create_rectangle(700,300,800,400, fill="white")
    square33 = top.create_rectangle(0,400,100,500, fill="white")
    square34 = top.create_rectangle(100,400,200,500, fill="black")
    square35 = top.create_rectangle(200,400,300,500, fill="white")
    square36 = top.create_rectangle(300,400,400,500, fill="black")
    square37 = top.create_rectangle(400,400,500,500, fill="white")
    square38 = top.create_rectangle(500,400,600,500, fill="black")
    square39 = top.create_rectangle(600,400,700,500, fill="white")
    square40 = top.create_rectangle(700,400,800,500, fill="black")
    square41 = top.create_rectangle(0,500,100,600, fill="black")
    square42 = top.create_rectangle(100,500,200,600, fill="white")
    square43 = top.create_rectangle(200,500,300,600, fill="black")
    square44 = top.create_rectangle(300,500,400,600, fill="white")
    square45 = top.create_rectangle(400,500,500,600, fill="black")
    square46 = top.create_rectangle(500,500,600,600, fill="white")
    square47 = top.create_rectangle(600,500,700,600, fill="black")
    square48 = top.create_rectangle(700,500,800,600, fill="white")
    square49 = top.create_rectangle(0,600,100,700, fill="white")
    square50 = top.create_rectangle(100,600,200,700, fill="black")
    square51 = top.create_rectangle(200,600,300,700, fill="white")
    square52 = top.create_rectangle(300,600,400,700, fill="black")
    square53 = top.create_rectangle(400,600,500,700, fill="white")
    square54 = top.create_rectangle(500,600,600,700, fill="black")
    square55 = top.create_rectangle(600,600,700,700, fill="white")
    square56 = top.create_rectangle(700,600,800,700, fill="black")
    square57 = top.create_rectangle(0,700,100,800, fill="black")
    square58 = top.create_rectangle(100,700,200,800, fill="white")
    square59 = top.create_rectangle(200,700,300,800, fill="black")
    square60 = top.create_rectangle(300,700,400,800, fill="white")
    square61 = top.create_rectangle(400,700,500,800, fill="black")
    square62 = top.create_rectangle(500,700,600,800, fill="white")
    square63 = top.create_rectangle(600,700,700,800, fill="black")
    square64 = top.create_rectangle(700,700,800,800, fill="white")
    label1 = tk.Label(top, text = 'Checkers', font=('Arial', 36))
    button1 = tk.Button(top, text = "Start", relief=FLAT, font=('Arial', 26))
    button2 = tk.Button(top, text = "Help", relief=FLAT, font=('Arial', 26))
    button3 = tk.Button(top, text = "Options", relief=FLAT, font=('Arial', 26))
    button4 = tk.Button(top, text="Quit", relief=FLAT, command=quit, font=('Arial', 26), anchor = 'center')

Any help here will be greatly appreciated.

8 Years
Discussion Span
Last Post by jimothy

You can not mix canvas and grid. To use a label, button, etc. you must add a frame to the canvas. The following example will get you started on this, as well as using a for loop to create the square.

##-------  Do not import Tkinter twice; use one or the other
from Tkinter import *
##import Tkinter as tk
def startMenu():
    top_tk = Tk()
    top = Canvas(width="800", height="800")

    square_list = []
    color = "white"
    for j in range(0, 701, 100):
        square_list.append(top.create_rectangle(j,0,j+100,100, fill=color))
        if color == "white":
            color = "black"
            color = "white"

    fr = Frame(top, relief=GROOVE, borderwidth=2)
    label1 = Label(fr, text='Checkers', font=('Arial', 36), fg="blue")

    top.create_window(210, 800, window=fr, anchor=SE)
    top.pack(fill='both', expand='yes')

Edited by woooee: n/a

Votes + Comments
Thanks alot! helped greatly

Create a Tkinter.Frame to hold the checker board and another frame to hold the buttons. Pack the frames "top". If you want the buttons along the bottom, pack "left". Add internal padding to each frame to get the desired space.

To eliminate duplication, initialize a list and iterate on columns and rows.

size = 50
    cols = 8
    rows = 8
    squareList = []
    for i in range(cols):
        for j in range(rows):
            if j%2: colors = ["black", "white"]
            else: colors = ["white", "black"]
            squareList.append(top.create_rectangle(i*size,  j*size,
                                                   i*size+size, j*size+size,

Edited by bvdet: n/a


Thank you all for helping me, i have a funny feeling i will need more help later on though.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.