Skip to content

Instantly share code, notes, and snippets.

@olamigokayphils
Created May 25, 2017 15:35
Show Gist options
  • Save olamigokayphils/2e993780e3da5ab292c43d8b33157b0c to your computer and use it in GitHub Desktop.
Save olamigokayphils/2e993780e3da5ab292c43d8b33157b0c to your computer and use it in GitHub Desktop.
worked on my first GUI (simple)program.
#
from tkinter import *
class Application(Frame):
"""A updated Version of delete me. """
def __init__(self, master):
super(Application, self).__init__(master)
self.grid()
self.create_widget()
def create_widget(self):
"""Creating the text and Entry widget. """
self.lbl1 = Label(self, text = "The Fradohn Examination")
self.lbl1.grid(row = 0, column = 0, columnspan = 2, sticky = W)
self.lbl2 = Label(self, text = "Enter your name")
self.lbl2.grid(row = 1, column = 0, sticky = W)
self.name_entry = Entry(self)
self.name_entry.grid(row = 1, column = 1, sticky = W)
self.lbl3 = Label(self, text = "Enter your Class")
self.lbl3.grid(row = 2, column = 0, sticky = W)
self.class_entry = Entry(self)
self.class_entry.grid(row = 2, column = 1, sticky = W)
self.button = Button(self, text = "Start Exam", command = self.check)
self.button.grid(row = 3, column = 1, sticky = W)
self.text = Text(self, width = 35, height = 5, wrap = WORD)
self.text.grid(row = 4, column = 0, columnspan = 2, sticky = W)
def check(self):
content1 = self.name_entry.get().lower()
content2 = self.class_entry.get().lower()
if content1 == "user" and content2 == str("user1"):
message = "Good Luck"
else:
message = "Not a valid ID. Try again!"
self.text.delete(0.0, END)
self.text.insert(0.0, message)
#main
root = Tk()
root.title("Fradohn Examination")
root.geometry("400x150")
app = Application(root)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment