-
Notifications
You must be signed in to change notification settings - Fork 0
/
second.py
66 lines (52 loc) · 2.16 KB
/
second.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
from Tkinter import Tk, BOTH
from ttk import Frame, Label, Button, Style
import httplib2
import json
username = username
password = password
class ticketWindow(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Zendesk Views")
self.style = Style()
self.style.theme_use("default")
self.style.configure("TFrame", background="#333")
self.style.configure("TLabel", backgroun="#444")
self.pack(fill=BOTH, expand=1)
self.centerWindow()
ticket1 = ticketViews(parent, 26887076)
ticket2 = ticketViews(parent, 35868228)
def centerWindow(self):
w = 250
h = 100
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
x = (sw) /2
y = (sh) /2
self.parent.geometry('%dx%d+%d+%d' % (w, h ,x ,y))
def createQuit(self):
quitButton = Button(self, text="Quit", command=self.quit)
quitButton.place(x=50, y=50)
class ticketViews():
def __init__(self, parent, id):
self.client = client = httplib2.Http(disable_ssl_certificate_validation=True)
self.client.add_credentials(username, password)
## Pull View Name
self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json")
self.viewData = json.loads(self.viewContent)
print repr(self.viewData)
self.countResp, self.countContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + "/count.json")
self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json")
self.countData = json.loads(self.countContent)
print repr(self.countContent)
self.parent = parent
print(self.parent.winfo_width())
self.label = Label(text=self.viewData["view"]["title"] + " " + str(self.countData["view_count"]["value"]))
self.label.pack(fill=BOTH)
def main():
root = Tk()
ex = ticketWindow(root)
root.mainloop()
if __name__ == '__main__':
main()