mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix (client-utils): start server if not running for 'show' and 'new'
This commit is contained in:
@ -254,10 +254,9 @@ class BECGuiClient(RPCBase):
|
|||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""Show the GUI window."""
|
"""Show the GUI window."""
|
||||||
if self._process is not None:
|
if self._check_if_server_is_alive():
|
||||||
return self._show_all()
|
return self._show_all()
|
||||||
# backward compatibility: show() was also starting server
|
return self._start(wait=True)
|
||||||
return self._start_server(wait=True)
|
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
"""Hide the GUI window."""
|
"""Hide the GUI window."""
|
||||||
@ -278,8 +277,7 @@ class BECGuiClient(RPCBase):
|
|||||||
Returns:
|
Returns:
|
||||||
client.BECDockArea: The new dock area.
|
client.BECDockArea: The new dock area.
|
||||||
"""
|
"""
|
||||||
if len(self.window_list) == 0:
|
self.show()
|
||||||
self.show()
|
|
||||||
if wait:
|
if wait:
|
||||||
with wait_for_server(self):
|
with wait_for_server(self):
|
||||||
rpc_client = RPCBase(gui_id=f"{self._gui_id}:window", parent=self)
|
rpc_client = RPCBase(gui_id=f"{self._gui_id}:window", parent=self)
|
||||||
@ -345,6 +343,14 @@ class BECGuiClient(RPCBase):
|
|||||||
#### Private methods ####
|
#### Private methods ####
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
|
def _check_if_server_is_alive(self):
|
||||||
|
"""Checks if the process is alive"""
|
||||||
|
if self._process is None:
|
||||||
|
return False
|
||||||
|
if self._process.poll() is not None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def _gui_post_startup(self):
|
def _gui_post_startup(self):
|
||||||
timeout = 10
|
timeout = 10
|
||||||
while time.time() < time.time() + timeout:
|
while time.time() < time.time() + timeout:
|
||||||
|
Reference in New Issue
Block a user