|
| 1 | +#a tool to remotely control a group of Christie WU7K-M projectors using their network interfaces. This is the GUI version. |
| 2 | + |
| 3 | +import tkinter as tk |
| 4 | +from tkinter import ttk |
| 5 | +from christie import transmit |
| 6 | + |
| 7 | +class App(tk.Frame): |
| 8 | + def __init__(self, master=None): |
| 9 | + super().__init__(master) |
| 10 | + self.master = master |
| 11 | + root.title('Marquette Visualization Lab Control') |
| 12 | + root.geometry("450x470") |
| 13 | + |
| 14 | + s = ttk.Style() |
| 15 | + s.theme_use('vista') |
| 16 | + s.configure('Heading.TLabel', font=('Helvetica Bold', 14)) |
| 17 | + #s.configure('TLabel', font=('Helvetica', 11)) |
| 18 | + |
| 19 | + def create_widgets(self): |
| 20 | + #header |
| 21 | + header = tk.Frame(root) |
| 22 | + ttk.Label(header, text='Marquette Visualization Lab Control', style='Heading.TLabel').pack() |
| 23 | + ttk.Label(header, text='Select a command').pack() |
| 24 | + ttk.Separator(header).pack(expand=True, fill='x', pady=10) |
| 25 | + header.pack(expand=False, fill='x', pady=10) |
| 26 | + |
| 27 | + #main area layout |
| 28 | + f = tk.Frame(root) |
| 29 | + ttk.Label(f, text='Power:').grid(row=0, column=0) |
| 30 | + ttk.Radiobutton(f, text='On', variable=p_power, value="on").grid(row=0, column=1, sticky="W") |
| 31 | + ttk.Radiobutton(f, text='Off', variable=p_power, value="off").grid(row=0, column=2, sticky="W") |
| 32 | + |
| 33 | + ttk.Label(f, text='Shutters:').grid(row=1, column=0) |
| 34 | + ttk.Radiobutton(f, text='Open', variable=p_shutters, value="open").grid(row=1, column=1, sticky="W") |
| 35 | + ttk.Radiobutton(f, text='Closed', variable=p_shutters, value="close").grid(row=1, column=2, sticky="W") |
| 36 | + |
| 37 | + ttk.Label(f, text='Stereo:').grid(row=2, column=0) |
| 38 | + ttk.Radiobutton(f, text='Frame Doubled', variable=p_3d, value="3d").grid(row=2, column=1, sticky="W") |
| 39 | + ttk.Radiobutton(f, text='Disabled', variable=p_3d, value="2d").grid(row=2, column=2, sticky="W") |
| 40 | + |
| 41 | + ttk.Label(f, text='Floor:').grid(row=3, column=0) |
| 42 | + ttk.Radiobutton(f, text='Normal', variable=p_floor, value="floorOn").grid(row=3, column=1, sticky="W") |
| 43 | + ttk.Radiobutton(f, text='Disabled', variable=p_floor, value="floorOff").grid(row=3, column=2, sticky="W") |
| 44 | + |
| 45 | + f.columnconfigure(0, pad=0, weight=2) |
| 46 | + f.columnconfigure(1, pad=0, weight=1) |
| 47 | + f.columnconfigure(2, pad=0, weight=1) |
| 48 | + f.rowconfigure(0, pad=20) |
| 49 | + f.rowconfigure(1, pad=20) |
| 50 | + f.rowconfigure(2, pad=20) |
| 51 | + f.rowconfigure(3, pad=20) |
| 52 | + f.pack(expand=False, fill='x', padx=10, pady=0) |
| 53 | + |
| 54 | + #footer |
| 55 | + footer = tk.Frame(root) |
| 56 | + ttk.Separator(footer).pack(expand=True, fill='x', pady=5) |
| 57 | + ttk.Label(footer, textvariable=p_info).pack(pady=5) |
| 58 | + footer.pack(expand=False, fill='x', pady=0) |
| 59 | + |
| 60 | +def onclick(s): |
| 61 | + p_info.set("Please wait..."); |
| 62 | + app.update() |
| 63 | + p_info.set(transmit(s)); |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + root = tk.Tk() |
| 67 | + app = App(master=root) |
| 68 | + |
| 69 | + #state variables & callbacks |
| 70 | + p_power = tk.StringVar() |
| 71 | + p_shutters = tk.StringVar() |
| 72 | + p_3d = tk.StringVar() |
| 73 | + p_floor = tk.StringVar() |
| 74 | + p_command = tk.StringVar() |
| 75 | + p_info = tk.StringVar(value="") |
| 76 | + p_power.trace_add('write', lambda *args: p_command.set(p_power.get())) |
| 77 | + p_shutters.trace_add('write', lambda *args: p_command.set(p_shutters.get())) |
| 78 | + p_3d.trace_add('write', lambda *args: p_command.set(p_3d.get())) |
| 79 | + p_floor.trace_add('write', lambda *args: p_command.set(p_floor.get())) |
| 80 | + p_command.trace_add('write', lambda *args: onclick(p_command.get())) |
| 81 | + |
| 82 | + #keyboard shortcuts |
| 83 | + root.bind('<Escape>', lambda x: root.destroy()) |
| 84 | + |
| 85 | + app.create_widgets() |
| 86 | + app.mainloop() |
0 commit comments