def do_connect(self, evt): if evt != 'gesture': evt.Skip() last_cons = get_config()['connections']['last_connected'] last = '' if last_cons: last = last_cons[-1] # Translators: Title of the connect dialog. dlg = dialogs.DirectConnectDialog(parent=gui.mainFrame, id=wx.ID_ANY, title=_("Connect")) dlg.panel.host.SetValue(last) dlg.panel.host.SelectAll() def handle_dlg_complete(dlg_result): if dlg_result != wx.ID_OK: return if dlg.client_or_server.GetSelection() == 0: #client server_addr = dlg.panel.host.GetValue() server_addr, port = address_to_hostport(server_addr) channel = dlg.panel.key.GetValue() if dlg.connection_type.GetSelection() == 0: self.connect_slave((server_addr, port), channel) else: self.connect_control((server_addr, port), channel) else: #We want a server channel = dlg.panel.key.GetValue() self.server = server.Server(SERVER_PORT, channel) server_thread = threading.Thread(target=self.server.run) server_thread.daemon = True server_thread.start() if dlg.connection_type.GetSelection() == 0: self.connect_slave(('127.0.0.1', SERVER_PORT), channel) else: self.connect_control(('127.0.0.1', SERVER_PORT), channel) gui.runScriptModalDialog(dlg, callback=handle_dlg_complete)
def do_connect(self, evt): evt.Skip() last_cons = configuration.get_config()['connections']['last_connected'] last = '' if last_cons: last = last_cons[-1] # Translators: Title of the connect dialog. dlg = dialogs.DirectConnectDialog(parent=gui.mainFrame, id=wx.ID_ANY, title=_("Connect")) dlg.panel.host.SetValue(last) dlg.panel.host.SelectAll() def handle_dlg_complete(dlg_result): if dlg_result != wx.ID_OK: return if dlg.client_or_server.GetSelection() == 0: #client server_addr = dlg.panel.host.GetValue() server_addr, port = address_to_hostport(server_addr) channel = dlg.panel.key.GetValue() if dlg.connection_type.GetSelection() == 0: self.connect_as_master((server_addr, port), channel) else: self.connect_as_slave((server_addr, port), channel) else: #We want a server channel = dlg.panel.key.GetValue() self.start_control_server(int(dlg.panel.port.GetValue()), channel) if dlg.connection_type.GetSelection() == 0: self.connect_as_master( ('127.0.0.1', int(dlg.panel.port.GetValue())), channel) else: self.connect_as_slave( ('127.0.0.1', int(dlg.panel.port.GetValue())), channel) gui.runScriptModalDialog(dlg, callback=handle_dlg_complete)