Ok, so who knows about Python? I have a program here that I'm writing for class, but for some reason the bloody canvas won't work and I can't work out why.
from Tkinter import * from tkColorChooser import * import time import random import sys import pickle
rectStatus =0 ovalStatus =0 text1Status =0 polyStatus =0
#Control Window# class Control(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid() self.createWidgets()
def createWidgets(self): top=self.winfo_toplevel() top.rowconfigure(0, weight=1) top.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1)
##Temperature CB## self.cbTemp = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Temperature", indicatoron=0, anchor=N) self.cbTemp.grid(row=1, column=1, sticky=N+S+E+W, padx=2, pady=2) ##Pressure CB## self.cbPressure = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Pressure", indicatoron=0, anchor=N) self.cbPressure.grid(row=2, column=1, sticky=N+S+E+W, padx=2, pady=2)
##Humidity CB## self.cbHumidity = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Humidity", indicatoron=0, anchor=N) self.cbHumidity.grid(row=3, column=1, sticky=N+S+E+W, padx=2, pady=2) ##Wind Speed CB## self.cbSpeed = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Wind Speed", indicatoron=0, anchor=N) self.cbSpeed.grid(row=4, column=1, sticky=N+S+E+W, padx=2, pady=2)
##Rainfall CB## self.cbRainfall = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Rainfall", indicatoron=0, anchor=N) self.cbRainfall.grid(row=5, column=1, sticky=N+S+E+W, padx=2, pady=2)
##Wind Direction CB## self.cbDirection = Checkbutton(self, relief=RAISED, selectcolor='Green', text="Wind Direction", indicatoron=0, anchor=N) self.cbDirection.grid(row=6, column=1, sticky=N+S+E+W, padx=2, pady=2)
def set_partner(self,pf): self.pf = pf
#Display Window# class Display(Frame): def __init__(self,parent): global widget Frame.__init__(self,parent,bg='Green')
parent.wm_geometry(newGeometry="+10+10") parent.wm_title("Display Panel") parent.config(bg='Grey') self.cvs = Canvas(self, background="blue", width=400, height=400, borderwidth=15, relief='groove')
##Pressure Button## self.pressurebutton = Button(self.cvs, text="Pressure", bd=5, padx=2, pady=2, relief=GROOVE) self.pressurebutton.pack(anchor=NW) self.cvs.create_window(50, 50, window=self.pressurebutton,anchor=NW)
##Wind Indicator## self.rectID= self.cvs.create_rectangle( 50,150, #x1,y1, 200,300, #x2,y2, fill="White", #fill color outline="Black", tags='Rect'); #outline color #Pointer N self.North= self.cvs.create_polygon( 125,150, 140,170, 130,170, 130,200, 120,200, 120,170, 110,170, fill="Black", #fill color outline="Blue", #outline color tags="North"); #Pointer S self.South= self.cvs.create_polygon( 125,300, 140,280, 130,280, 130,250, 120,250, 120,280, 110,280, fill="Black", #fill color outline="Blue", #outline color tags="South"); #Pointer E self.East= self.cvs.create_polygon( 200,225, 180,240, 180,230, 150,230, 150,220, 180,220, 180,210, fill="Black", #fill color outline="Blue", #outline color tags="East");
#Pointer W self.West= self.cvs.create_polygon( 50,225, 70,240, 70,230, 100,230, 100,220, 70,220, 70,210, fill="Black", #fill color outline="Blue", #outline color tags="West");
#Pointer SW self.SouthWest= self.cvs.create_polygon( 60,290, 60,260, 70,270, 100,240, 110,250, 80,280, 90,290, fill="Black", #fill color outline="Blue", #outline color tags="SW"); #Pointer SE self.SouthEast= self.cvs.create_polygon( 190,290, 190,260, 180,270, 150,240, 140,250, 170,280, 160,290, fill="Black", #fill color outline="Blue", #outline color tags="SE");
#Pointer NE self.NorthEast= self.cvs.create_polygon( 190,160, 190,190, 180,180, 150,210, 140,200, 170,170, 160,160, fill="Black", #fill color outline="Blue", #outline color tags="NE"); #Pointer NW self.NorthWest= self.cvs.create_polygon( 60,160, 60,190, 70,180, 100,210, 110,200, 80,170, 90,160, fill="Black", #fill color outline="Blue", #outline color tags="NW");
#Text N self.N = self.cvs.create_text(120,150, text="N" , fill="Blue", anchor=SW, font=("Comic Sans Ms",10), tags="N"); #Text S self.S = self.cvs.create_text(120,320, text="S" , fill="Blue", anchor=SW, font=("Comic Sans Ms",10), tags="S"); #Text W self.W = self.cvs.create_text(30,235, text="W" , fill="Blue", anchor=SW, font=("Comic Sans Ms",10), tags="W"); #Text E self.E = self.cvs.create_text(210,235, text="E" , fill="Blue", anchor=SW, font=("Comic Sans Ms",10), tags="E"); #Text Wind Direction self.text3 = self.cvs.create_text(60,350, text="Wind Direction" , fill="Blue", anchor=SW, font=("Comic Sans Ms",12,"italic"), tags="lable2");
pw = Toplevel() pf = Display(pw) cw = Control() #cw.set_partner(pf) pw.mainloop()
For those wondering it's a sort of Simulated environment control thingy.
Can anyone tell me what I'm missing here?
|