-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgui.py
More file actions
136 lines (97 loc) Β· 4.45 KB
/
gui.py
File metadata and controls
136 lines (97 loc) Β· 4.45 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import sys, os
from sys import path
import tkinter as tk
from tkinter import ttk
path.append(path[0] + '\helpers')
import database as postgres
import guihelper as guihelper
import frame as frame
fontstyle = ("Helvetica", 18)
class main(tk.Tk):
def __init__(self, *args, **kwargs):
# Set icons and title
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.iconbitmap(self, default='./icons/now-black.ico')
tk.Tk.wm_title(self, 'PostgreSQL Developer')
# Setup frame layout for application
container = tk.Frame(self)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
# Frame "Router" for use in the index
self.frames = {}
for Frame in (Index, View, Create, Delete, Upload, Connection):
frame = Frame(container, self)
frame.grid(row=0, column=0, sticky="nsew")
self.frames[Frame] = frame
self.show_frame(Index)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class Index(tk.Frame):
def __init__(self, parent, controller):
# Setup frame layout
self.connectionstr = tk.StringVar()
tk.Frame.__init__(self,parent)
label = tk.Label(self, text="PostgreSQL Developer", font=fontstyle)
label.pack(pady=80, padx=100)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
button2 = ttk.Button(self, text="View", command=lambda: controller.show_frame(View))
button3 = ttk.Button(self, text="Create", command=lambda: controller.show_frame(Create))
button4 = ttk.Button(self, text="Delete", command=lambda: controller.show_frame(Delete))
button5 = ttk.Button(self, text="Upload", command=lambda: controller.show_frame(Upload))
test = ttk.Button(bottom, text="Test Connection", command=lambda: guihelper.connectionTest(self))
output = ttk.Label(self, textvariable=self.connectionstr)
editconn = ttk.Button(bottom, text="Edit Connection Details", command=lambda: controller.show_frame(Connection))
defaultconn = ttk.Button(bottom, text="Use default connection", command=lambda: guihelper.setdefaultconfig(self))
button2.pack(pady=5)
button3.pack(pady=5)
button4.pack(pady=5)
button5.pack(pady=5)
output.pack(pady = 50)
test.pack(pady=(10, 10))
editconn.pack(pady=(10, 10))
defaultconn.pack(pady = (10, 100))
class View(tk.Frame):
def __init__(self, parent, controller):
self.console = tk.StringVar();
tk.Frame.__init__(self, parent)
frame.View(self, parent, controller)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
ttk.Button(bottom, text = "Back to vewx", command = lambda: controller.show_frame(Index)).pack(pady=15)
class Create(tk.Frame):
def __init__(self, parent, controller):
# Setup Frame label and layout
tk.Frame.__init__(self, parent)
frame.Create(self, parent, controller)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
ttk.Button(bottom, text = "Back to vewx", command = lambda: controller.show_frame(Index)).pack(pady=15)
class Upload(tk.Frame):
def __init__(self, parent, controller):
# Setup Frame label and layout
tk.Frame.__init__(self, parent)
frame.Upload(self, parent, controller)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
ttk.Button(bottom, text = "Back to vewx", command = lambda: controller.show_frame(Index)).pack(pady=15)
class Delete(tk.Frame):
def __init__(self, parent, controller):
# Setup Frame label and layout
tk.Frame.__init__(self, parent)
frame.Delete(self, parent)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
ttk.Button(bottom, text = "Back to vewx", command = lambda: controller.show_frame(Index)).pack(pady=15)
class Connection(tk.Frame):
def __init__(self, parent, controller):
# Setup Frame label and layout
self.connectionstr = tk.StringVar()
tk.Frame.__init__(self, parent)
bottom = tk.Frame(self)
bottom.pack(side = 'bottom')
frame.Connection(self, parent)
index = ttk.Button(bottom, text = "Back to Index", command = lambda: controller.show_frame(Index))
index.pack(pady=15)