def _handle_connection_error(self, error_message=None):
"""Handle connection errors that might be thrown when initially connecting to IRIDA.
Args:
error_message: A more detailed error message than "Can't connect"
"""
logging.error("Handling connection error.")
self.Freeze()
connection_error_sizer = wx.BoxSizer(wx.HORIZONTAL)
connection_error_header = wx.StaticText(self, label=u"? Uh-oh. I couldn't to connect to IRIDA.")
connection_error_header.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD))
connection_error_header.SetForegroundColour(wx.Colour(255, 0, 0))
connection_error_header.Wrap(350)
connection_error_sizer.Add(connection_error_header, flag=wx.LEFT | wx.RIGHT, border=5)
self._sizer.Add(connection_error_sizer, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
if error_message:
self._sizer.Add(wx.StaticText(self, label=wordwrap(error_message, 350, wx.ClientDC(self))), flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
open_settings_button = wx.Button(self, label="Open Settings")
self.Bind(wx.EVT_BUTTON, self._parent._open_settings, id=open_settings_button.GetId())
self._sizer.Add(open_settings_button, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
self.Layout()
self.Thaw()
pub.unsubscribe(self._handle_connection_error, APIConnectorTopics.connection_error_topic)
评论列表
文章目录