Hi all, im new to Python and the raspberry. im trying to make a fairly complex tester, im starting with the gui and ive been able to get a functioning button and separate text window to display messages but now I want to put a colour to the background of that window with each of the 2 messages I currently have it displaying but anything I try from searching online fails to work with my current code.. # ive hashed what colours im trying to have appear as back ground
import Tkinter as tk
from Tkinter import *
import time
class GridDemo(Frame):
def var1(self):
self.label4String.set("Panel Test Began") # I Want This Background To Be Green
if self.button1["text"] == "Begin Panel Test":
print "You have started the panel test:", self.label4String.get()
self.button1["text"] = "Stop Panel Test"
else:
self.button1["text"] = "Begin Panel Test"
self.label4String.set("Panel Test Ended") # I Want This Background To Be Red
print "You have stopped the panel test:", self.label4String.get()
time.sleep(0.5)
def __init__(self):
Frame.__init__(self)
self.master.title( "Grid Demo" )
self.variable = "Start Variable"
self.master.rowconfigure( 0, weight=1)
self.master.columnconfigure( 0, weight=1)
self.grid(sticky=W+E+N+S)
self.button1 = Button(self, text = "Begin Panel Test", command = self.var1)
self.button1.grid(row=1, column=1, sticky=W+E+N+S)
self.button2 = Button(self, text="Quit", command=exit)
self.button2.grid(row=1, column=2, sticky=W+E+N+S)
self.label4String = StringVar()
self.label4 = Label(self, textvariable=self.label4String)
self.label4.grid(row=2, column=1, columnspan=2, sticky=W+E+N+S)
self.rowconfigure(1, weight=1)
self.columnconfigure(1, weight=1)
def main():
GridDemo().mainloop()
if __name__ == '__main__':
main()