-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURL_Shortener_GUI.py
More file actions
78 lines (53 loc) · 2.31 KB
/
URL_Shortener_GUI.py
File metadata and controls
78 lines (53 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Simple enough, just import everything from tkinter.
from tkinter import *
# Here, we are creating our class, Window, and inheriting from the Frame
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
class Window(Frame):
# Define settings upon initialization. Here you can specify
def __init__(self, master=None):
# parameters that you want to send through the Frame class.
Frame.__init__(self, master)
#reference to the master widget, which is the tk window
self.master = master
#with that, we want to then run init_window, which doesn't yet exist
self.init_window()
#Creation of init_window
def init_window(self):
# changing the title of our master widget
self.master.title("GUI")
# allowing the widget to take the full space of the root window
self.pack(fill=BOTH, expand=1)
# creating a menu instance
menu = Menu(self.master)
self.master.config(menu=menu)
# create the file object)
file = Menu(menu)
# adds a command to the menu option, calling it exit, and the
# command it runs on event is client_exit
file.add_command(label="Exit", command=self.client_exit)
#added "file" to our menu
menu.add_cascade(label="File", menu=file)
# create the file object)
edit = Menu(menu)
# adds a command to the menu option, calling it exit, and the
# command it runs on event is client_exit
edit.add_command(label="Undo")
#added "edit" to our menu
menu.add_cascade(label="Edit", menu=edit)
self.show_intro()
def show_intro(self):
intro = Label(self, text = "Welcome to URL Shortener! Please paste your URL down below!", font = "Segoe 12",anchor=CENTER)
ins = Label(self, text = "Paste your URL here:",anchor=W)
intro.pack()
ins.pack()
copyright_text = Label(self, text = "\u00A9 2019 xyz.co")
copyright_text.pack()
def client_exit(self):
exit()
# root window created. Here, that would be the only window, but
# you can later have windows within windows.
root = Tk()
root.geometry("700x200")
#creation of an instance
app = Window(root)
root.mainloop()