-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceSelector.py
More file actions
58 lines (49 loc) · 1.88 KB
/
DeviceSelector.py
File metadata and controls
58 lines (49 loc) · 1.88 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
from tkinter import *
from DeviceInfo import DeviceInfo
class DeviceSelector:
def __init__(self,parallel=False):
#Create Window
self.root = Tk()
win = self.root
#Set Window Properties
win.iconbitmap(default='runner.ico')
win.wm_title("Test Runner")
win.minsize(width=500, height=500)
#Create Listbox
scrollbar = Scrollbar(win)
scrollbar.pack(side=RIGHT, fill=Y)
if parallel:
label = Label(win, text="Please Select one or more devices to run")
label.pack()
self.listbox = Listbox(win, selectmode=EXTENDED)
else:
label = Label(win, text="Please Select one device to run")
label.pack()
self.listbox = Listbox(win, selectmode=SINGLE)
self.listbox.pack(fill=BOTH, expand=1)
#Attach Scrollbar to Listbox
self.listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.listbox.yview)
#Generate Listbox Data
info = DeviceInfo()
for deviceId in info.gridDevices():
device = info.getDevice(deviceId)
self.listbox.insert(END, device['udid'] + ' -- ' + device['name'])
self.frame = Frame(win)
self.frame.pack(fill=X)
#Create Buttons
Button(self.frame, text="Cancel", fg="red", command=self.frame.quit, width=50).pack(side=RIGHT, fill=Y)
Button(self.frame, text="Run Test", command=self.saveDevices, width=50).pack(side=LEFT, fill=Y)
def getDevice(self):
self.root.mainloop()
self.root.destroy()
return self.devices
def saveDevices(self):
devices = self.listbox.curselection()
output=[]
for device in devices:
output.append(self.listbox.get(device))
self.frame.quit()
self.devices = output
device = DeviceSelector().getDevice()
print(device)