1
Fork 0

Added buttons and style (FINALLY)

This commit is contained in:
Jake Howard 2015-04-22 09:52:09 +01:00
parent e28395b918
commit bd90b102e3

61
GUI.py
View file

@ -1,42 +1,57 @@
from tkinter import * from tkinter import *
from tkinter.ttk import * from tkinter.ttk import *
import logging import logging
import game
PADDING_TITLE = 15
PADDING_BUTTON = 9
class Gui: PROGRAM_OPEN = True
class Main_Window:
def __init__(self, master): def __init__(self, master):
self.master = master self.master = master
self.master.title("SPACE INVADERS") self.master.title("SPACE INVADERS")
self.title = Label(master)
self.title.config(text="SPACE INVADERS!", font=("Lucida", 30))
self.title.pack(side="top")
self.title2 = Button(master) self.title = Label(self.master)
self.title2.config(text="SPACE INVADERS!") self.title.config(text="SPACE INVADERS!",font=("Courier New", 37))
self.title2.pack(side="bottom") self.title.pack(side="top", padx=PADDING_BUTTON, pady=PADDING_TITLE/2)
# lbl_fname=Label(master) self.start_button = Button(self.master, style="Menu.TButton")
# lbl_fname.config(text="File Name:") self.start_button.config(text="Play Game")
# lbl_fname.grid(row=0, column = 0, padx=10, pady=20) self.start_button.pack(fill=BOTH, ipadx=PADDING_BUTTON/2, ipady=PADDING_BUTTON/2, padx=PADDING_BUTTON, pady=PADDING_BUTTON)
self.start_button.bind('<Button-1>', self.play_game)
# self.txt_fname=Entry(master) self.exit_button = Button(self.master, style="Quit.TButton")
# self.txt_fname.grid(row=0, column=1) self.exit_button.config(text="Quit Game")
self.exit_button.pack(ipadx=PADDING_BUTTON/3, ipady=PADDING_BUTTON, padx=PADDING_BUTTON, pady=PADDING_BUTTON)
self.exit_button.bind('<Button-1>', self.close)
# random_button = Button(master)
# random_button.config(text="Play File")
# random_button.grid(row=3, column=3)
# random_button1 = Button(master) Style().configure("Menu.TButton", font=("Lucida", 25 ))
# random_button1.config(text="Stop File") Style().configure("Quit.TButton", font=("Lucida", 15))
# random_button1.grid(row=3, column=2)
logging.info("GUI Generated.") logging.info("GUI Generated.")
def main(): def play_game(self, event):
logging.info("Game Started.")
self.master.withdraw()
game.initialise(self.master, None)
def close(self, event):
logging.critical("Closing Main Window.")
self.master.destroy()
def display():
root=Tk() root=Tk()
root.resizable(width=False, height=False) root.resizable(width=False, height=False)
#root.geometry("640x480") front_end=Main_Window(root)
front_end=Gui(root)
root.mainloop() root.mainloop()
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)
if __name__ == "__main__": if __name__ == "__main__":
main() display()