-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.py
executable file
·132 lines (102 loc) · 4.34 KB
/
GUI.py
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
from Tkinter import *
class GUI(Frame):
def __init__(self, master=Tk()):
Frame.__init__(self, master)
master.config(menu=self.menuBar())
self.createWidgets()
self.pack(fill=BOTH, expand=1)
def createWidgets(self):
serverListFrame = Frame()
scrollbar = Scrollbar(serverListFrame, orient=VERTICAL)
serverListbox = Listbox(serverListFrame, yscrollcommand=scrollbar.set)
scrollbar.config(command=serverListbox.yview)
scrollbar.pack(side=RIGHT, fill=Y)
serverListbox.pack(side=LEFT, fill=Y, expand=1)
serverListFrame.pack(side=LEFT, fill=Y)
conversationFrame = Frame(self)
outputBox = OutputBox(conversationFrame)
outputBox.pack(fill=BOTH, expand=1)
InputBox(conversationFrame)
conversationFrame.pack(fill=BOTH, expand=1)
listFrame = Frame()
scrollbar = Scrollbar(listFrame, orient=VERTICAL)
listbox = Listbox(listFrame, yscrollcommand=scrollbar.set)
scrollbar.config(command=listbox.yview)
scrollbar.pack(side=RIGHT, fill=Y)
listbox.pack(side=LEFT, fill=Y, expand=1)
listFrame.pack(side=RIGHT, fill=Y)
serverListbox.insert(END, "a list entry")
ServerList()
def menuBar(self):
menubar = Menu(self)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command=self.quit())
filemenu.add_command(label="Exit", command=None)
menubar.add_cascade(label="File", menu=filemenu)
return menubar
class ServerList(Frame):
def __init__(self, master=Toplevel()):
Frame.__init__(self, master)
serverListFrame = Frame(self)
scrollbar = Scrollbar(serverListFrame, orient=VERTICAL)
serverListbox = Listbox(serverListFrame, yscrollcommand=scrollbar.set)
serverListbox.pack(fill=BOTH, side=LEFT, expand=1)
scrollbar.config(command=serverListbox.yview)
scrollbar.pack(side=RIGHT, fill=Y)
serverListFrame.pack(fill=BOTH, expand=1)
buttonFrame = Frame(self)
connectButton = Button(buttonFrame, text="Connect", command=self.connect())
connectButton.pack(side=LEFT)
addServerButton = Button(buttonFrame, text="Add Server", command=self.addServer())
addServerButton.pack(side=LEFT)
editServerButton = Button(buttonFrame, text="Edit Server", command=self.editServer())
editServerButton.pack(side=LEFT)
deleteServerButton = Button(buttonFrame, text="Delete Server", command=self.deleteServer())
deleteServerButton.pack(side=LEFT)
buttonFrame.pack()
self.pack(fill=BOTH, expand=1)
def connect(self):
pass
def addServer(self):
pass
def editServer(self):
pass
def deleteServer(self):
pass
class NewServerDialog(Frame):
def __init__(self, master=Toplevel()):
class OutputBox(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.outputBox = Text(self)
self.scrollbar = Scrollbar(self)
self.scrollbar.pack(side=RIGHT, fill=Y)
self.outputBox.configure(wrap=WORD,
yscrollcommand=self.scrollbar.set)
self.outputBox.pack(fill = "both", side = "top", expand = True)
self.outputBox.insert(INSERT, "Welcome to PyRC 0.1a\n")
self.scrollbar.config(command=self.outputBox.yview)
def append(self, text):
self.outputBox.insert(INSERT, text + "\n")
class InputBox(Entry):
def takeInput(self, event):
line = self.get()
if line[0] == "/":
line = line[1:]
print line
line = line.split(" ")
print line
self.parseCommand(line[0], line[1:])
else:
GUI.irc_instance.send(line)
self.contents.set("")
self["textvariable"] = self.contents
def __init__(self, master=None):
Entry.__init__(self, master)
self.pack(fill=X, side=BOTTOM)
self.contents = StringVar()
self.bind('<Key-Return>',
self.takeInput)
if __name__ == '__main__':
app = GUI()
app.mainloop()