class _PopupWindowBase(object): def __init__(self, size, detachable=True, autohide=False): # print("DEBUG: PopupWindow at init") self.panel = self._create_ui(size) if autohide: self._set_auto_hiding() if detachable: self._set_detachable() self.SetSize(size) def _create_ui(self, size): if wx.VERSION >= (3, 0, 3, ''): # DEBUG wxPhoenix panel = wx.MiniFrame(self) # DEBUG wx.Panel would not detach on wxPython 4 else: panel = wx.Panel(self) panel.SetBackgroundColour(POPUP_BACKGROUND) szr = VerticalSizer() self._details = HtmlWindow(self, size=size) szr.add_expanding(self._details) panel.SetSizer(szr) panel.Fit() return panel def _set_detachable(self): # print("DEBUG: PopupWindow at Binding mouse on help") self._details.Bind(wx.EVT_LEFT_UP, self._detach) self._details.Bind(wx.EVT_LEFT_DCLICK, self._detach) # DEBUG add double-click def _detach(self, event): # print("DEBUG: PopupWindow at detached call") self.hide() dlg = HtmlDialog(self._detached_title, self._current_details) dlg.SetPosition((wx.GetMouseState().x, wx.GetMouseState().y)) dlg.Show() event.Skip() def show_at(self, position): if self.GetPosition() != position: self.SetPosition(position) if not self.IsShown(): self.Show() def hide(self, event=None): self.Show(False) @property def screen_position(self): return self.ScreenPosition @property def size(self): return self.Size def set_content(self, content, title=None): color = ''.join(hex(item)[2:] for item in POPUP_BACKGROUND) self._current_details = '<body bgcolor=#%s>%s</body>' % \ (color, content) self._details.SetPage(self._current_details) self._detached_title = title
class _PopupWindowBase(object): def __init__(self, size, detachable=True, autohide=False): self.panel = self._create_ui(size) if autohide: self._set_auto_hiding() if detachable: self._set_detachable() self.SetSize(size) def _create_ui(self, size): panel = wx.Panel(self) panel.SetBackgroundColour(POPUP_BACKGROUND) szr = VerticalSizer() self._details = HtmlWindow(self, size=size) szr.add_expanding(self._details) panel.SetSizer(szr) panel.Fit() return panel def _set_detachable(self): self._details.Bind(wx.EVT_LEFT_UP, self._detach) def _detach(self, event): self.hide() dlg = HtmlDialog(self._detached_title, self._current_details) dlg.SetPosition((wx.GetMouseState().x, wx.GetMouseState().y)) dlg.Show() if IS_WINDOWS: event.Skip() def show_at(self, position): if not self.IsShown(): self.SetPosition(position) self.Show() def hide(self, event=None): self.Show(False) @property def screen_position(self): return self.ScreenPosition @property def size(self): return self.Size def set_content(self, content, title=None): color = ''.join(hex(item)[2:] for item in POPUP_BACKGROUND) self._current_details = '<body bgcolor=#%s>%s</body>' % \ (color, content) self._details.SetPage(self._current_details) self._detached_title = title
def _value_display_control(self): ctrl = HtmlWindow(self, (-1, 100)) ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnEdit) return ctrl