#!/usr/bin/env python2
import os,sys
from Tkinter import *
location="start"
class App:
def __init__(self,master):
global location
Backgroundphoto=PhotoImage (file=os.path.normcase("assets/ibm_pc.gif")) #Draw the background
global x #Need to keep around a refrence so the garbage
x=Backgroundphoto #collector doesn't pick it up.
Backgroundlabel=Label(master, image=Backgroundphoto)
Backgroundlabel.pack()
master.bind("<Key>",self.keypress) #Start catching keypresses
self.comptext=StringVar()
self.comptext.set("Welcome to my project.\nTo navigate, please type the number of your selection.\n\n1. TestnQ. Exit")
textcontainer=Label(master, fg="green",bg="black", textvariable=self.comptext, width=68, height=26)
textcontainer.place(x=105, y=98) #Values found by guessing
def keypress(self,event):
global location
if location=="start":
if event.char=='1':
location="works"
if event.char == 'q':
print 'one'
if event.char=='Q':
location='quit'
if location=="start": #Final update of the text.
self.comptext.set("Welcome to my project.\nTo navigate, please type the number of your selection.\n\n1. TestQ. Exit")
elif location=="works":
self.comptext.set("it works!")
elif location=='quit':
root.quit()
root=Tk(className="The history of personal computers - Bratmon")
app=App(root)
root.mainloop()
root.destroy() #Needed because otherwise the window wouldn't dissappear