From 87da5e7c0d3660fab4ea03addbe076100b99f3a2 Mon Sep 17 00:00:00 2001 From: Brett Williams Date: Sat, 3 Jun 2023 13:46:29 -0500 Subject: [PATCH] New job window now lets you pick from all detected servers --- lib/client/{client.py => dashboard_window.py} | 8 ++-- lib/client/new_job_window.py | 39 ++++++------------- start_client.py | 2 +- 3 files changed, 16 insertions(+), 33 deletions(-) rename lib/client/{client.py => dashboard_window.py} (98%) diff --git a/lib/client/client.py b/lib/client/dashboard_window.py similarity index 98% rename from lib/client/client.py rename to lib/client/dashboard_window.py index 551184a..2f4995e 100644 --- a/lib/client/client.py +++ b/lib/client/dashboard_window.py @@ -33,7 +33,7 @@ def available_servers(): return [socket.gethostname()] -class ZordonClient: +class DashboardWindow: lib_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) image_path = os.path.join(lib_path, 'server', 'static', 'images', 'desktop.png') @@ -43,7 +43,7 @@ class ZordonClient: # Create a Treeview widget self.root = tk.Tk() - self.root.title("Zordon Render Client") + self.root.title("Zordon Dashboard") self.local_host = socket.gethostname() self.server_proxy = RenderServerProxy(hostname=self.local_host) self.job_cache = [] @@ -274,12 +274,12 @@ class ZordonClient: new_window.title("New Window") new_window.geometry("500x600+300+300") new_window.resizable(False, height=True) - x = NewJobWindow(parent=new_window, hostname=self.server_proxy.hostname) + x = NewJobWindow(parent=new_window, clients=list(self.server_tree.get_children())) x.pack() def start_client(): - x = ZordonClient() + x = DashboardWindow() x.mainloop() diff --git a/lib/client/new_job_window.py b/lib/client/new_job_window.py index 0502387..da04e83 100755 --- a/lib/client/new_job_window.py +++ b/lib/client/new_job_window.py @@ -64,12 +64,12 @@ class ChecklistBox(Frame): class NewJobWindow(Frame): - def __init__(self, parent=None, hostname=None): + def __init__(self, parent=None, clients=None): super().__init__(parent) - self.server_proxy = RenderServerProxy(hostname=hostname) + self.clients = clients or [] + self.server_proxy = RenderServerProxy(hostname=clients[0] if clients else None) self.chosen_file = None - self.clients = [] self.presets = {} self.renderer_info = {} self.priority = IntVar(value=2) @@ -99,6 +99,10 @@ class NewJobWindow(Frame): self.client_combo = Combobox(client_frame, state="readonly") self.client_combo.pack(fill=X, padx=5, expand=True) + self.client_combo.bind('<>', self.client_picked) + self.client_combo['values'] = self.clients + if self.clients: + self.client_combo.current(0) # renderer frame renderer_frame = Frame(job_frame) @@ -156,16 +160,14 @@ class NewJobWindow(Frame): self.fetch_server_data() + def client_picked(self): + self.server_proxy.hostname = self.client_combo.get() + self.fetch_server_data() + def fetch_server_data(self): - self.clients = self.server_proxy.request_data('clients', timeout=3) or [] self.renderer_info = self.server_proxy.request_data('renderer_info', timeout=3) or {} self.presets = self.server_proxy.request_data('presets', timeout=3) or {} - # update clients - self.client_combo['values'] = self.clients - if self.clients: - self.client_combo.current(0) - # update available renders available_renderers = [x for x in self.renderer_info.keys() if self.renderer_info[x].get('available', False)] self.renderer_combo['values'] = available_renderers @@ -174,25 +176,6 @@ class NewJobWindow(Frame): self.refresh_renderer_settings() - def request_new_hostname(self): - hostname = None - while not hostname: - user_hostname_input = askstring("Server Name", "What is the server's hostname?") - if not user_hostname_input: # user input is none if they press cancel - return - server_status = request_data(user_hostname_input, 'status', timeout=server_setup_timeout) - if not server_status: - messagebox.showerror("Cannot connect", f"Cannot connect to server \"{user_hostname_input}\"") - else: - hostname = user_hostname_input - self.set_hostname(hostname) - - def set_hostname(self, hostname): - self.server_hostname = hostname - self.server_button.configure(text=self.server_hostname) - with open(prefs_name, 'w') as file: # save to prefs - file.write(hostname) - def choose_file_button(self): self.chosen_file = filedialog.askopenfilename() button_text = os.path.basename(self.chosen_file) if self.chosen_file else "no file selected" diff --git a/start_client.py b/start_client.py index 38b8e8d..f4f196b 100644 --- a/start_client.py +++ b/start_client.py @@ -1,4 +1,4 @@ -from lib.client.client import start_client +from lib.client.dashboard_window import start_client if __name__ == '__main__': start_client() \ No newline at end of file