def _default_font(): if osutils.is_msw(): # MSW has MS Shell Dlg 2, which can't be set to. # just use arial 12 pt return "Arial", 12, False return wx.NORMAL_FONT.FaceName, wx.NORMAL_FONT.PointSize, False
def create_toolbar(self): # create the toolbar self.toolbar = wx.ToolBar(self.toolbarpanel, style=wx.TB_FLAT|wx.TB_NODIVIDER|wx.TB_HORZ_TEXT) self.toolbar.SetToolBitmapSize((16, 16)) force_mask = False if osutils.is_msw() and not osutils.is_win2000(): force_mask = not guiutil.is_xp_styled() self.tooltip_config.add_to_toolbar(self.toolbar, permanent=False) self.tooltip_config.bind_to_toolbar(self.toolbar) # self.toolbar.AddSeparator() self.gui_anchor = self.toolbar.AddLabelTool(wx.ID_ANY, _("Anchor"), bmp("anchor.png", force_mask=force_mask), shortHelp=_("Don't hide this tooltip")) self.gui_copy = self.toolbar.AddLabelTool(wx.ID_ANY, _("Copy All"), bmp("page_copy.png", force_mask=force_mask), shortHelp=_("Copy tooltip text (with links)")) self.toolbar.Bind(wx.EVT_TOOL, self.stay_on_top, id=self.gui_anchor.Id) self.toolbar.Bind(wx.EVT_TOOL, self.copy_all, id=self.gui_copy.Id) self.toolbar.Realize()
def create_toolbar(self): # create the toolbar self.toolbar = wx.ToolBar(self.toolbarpanel, style=wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_HORZ_TEXT) self.toolbar.SetToolBitmapSize((16, 16)) force_mask = False if osutils.is_msw() and not osutils.is_win2000(): force_mask = not guiutil.is_xp_styled() self.tooltip_config.add_to_toolbar(self.toolbar, permanent=False) self.tooltip_config.bind_to_toolbar(self.toolbar) # self.toolbar.AddSeparator() self.gui_anchor = self.toolbar.AddLabelTool( wx.ID_ANY, _("Anchor"), bmp("anchor.png", force_mask=force_mask), shortHelp=_("Don't hide this tooltip")) self.gui_copy = self.toolbar.AddLabelTool( wx.ID_ANY, _("Copy All"), bmp("page_copy.png", force_mask=force_mask), shortHelp=_("Copy tooltip text (with links)")) self.toolbar.Bind(wx.EVT_TOOL, self.stay_on_top, id=self.gui_anchor.Id) self.toolbar.Bind(wx.EVT_TOOL, self.copy_all, id=self.gui_copy.Id) self.toolbar.Realize()
def show_popup(self, event): def on_cal_changed(event): dt = event.GetDate() if is_date_conversion_supported(): self.Parent.choose_item(dt.Format("%B ") + str(dt.Day)) else: self.Parent.choose_item(dt.Format("%m.%d")) def on_cal(event): win.Destroy() win = wx.PopupTransientWindow(self, wx.NO_BORDER) now_date = date_to_mmdd(self.text.Value, return_formatted=False) if now_date is None: now_date = wx.DateTime_Now() style = 0 if osutils.is_msw(): style = wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION panel = wx.Panel(win) cal = wx.calendar.CalendarCtrl(panel, -1, now_date, pos=(1, 1), style=wx.RAISED_BORDER | style) panel.ClientSize = cal.Size + (1, 1) cal.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, on_cal_changed) cal.Bind(wx.calendar.EVT_CALENDAR, on_cal) size_combo = 0 if not style & wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION: # hide the spin control for child in panel.Children: if isinstance(child, wx.SpinCtrl): child.Hide() # we will shorten ourselves by this amount size_combo = child.Size[1] + 6 # make combo fill up rest of space for child in panel.Children: if isinstance(child, wx.ComboBox): child.Size = cal.Size[0], -1 win.Size = panel.GetSize() - (0, size_combo) # Show the popup right below or above the button # depending on available screen space... btn = event.GetEventObject() pos = btn.ClientToScreen((btn.Size[0], 0)) win.Position(pos, (-btn.Size[0], btn.Size[1])) win.Popup()
def SelectItem(self, item): # we do this because non-msw platforms don't fire events for # programmatic tree selection changed, and we want this uniformly to # do it res = super(TopicTree, self).SelectItem(item) if not osutils.is_msw(): self.on_selection_changed(item) return res
def popup(self, event): assert(len(mouse_over)) == 1, "Only one thing can have mouse over" name, (pane, rect, title, clipping_rect) = mouse_over.items()[0] if not self.pane_can_be_seen(pane): event.Skip() return frames = [frame for frame, f_title in self.panes if f_title == name] assert len(frames) == 1, "Wrong frame count: %s (%r)" % (name, frames) frame = frames[0] keytext = frame.reference if not isinstance(keytext, basestring): keytext = keytext.text # find the intersection of the clipping rect and the actual rect # this will be the actual rectangle the user can see. r = wx.RectPP( ( max(rect[0], clipping_rect[0]), max(rect[1], clipping_rect[1]), ), ( min(rect.Right, clipping_rect.Right), min(rect.Bottom, clipping_rect.Bottom), ) ) p = ModulePopup(self, event, r, frame.book, keytext) # use the main frame to grab the mouse wheel events, as wxPopupWindow # cannot have focus, nor any of its children # This isn't needed under gtk, as the scroll wheel will automatically # select the window underneath for scrolling if osutils.is_msw(): self.SetFocus() self.Bind(wx.EVT_MOUSEWHEEL, p.box.on_mouse_wheel) def on_dismiss(chosen): if not r.Contains( self.ScreenToClient(wx.GetMousePosition()) ): self.clear_over_list() if chosen is not None: frame.book.SetModule(p.box.modules[chosen]) if osutils.is_msw(): self.Unbind(wx.EVT_MOUSEWHEEL) wx.CallAfter(p.Destroy) p.on_dismiss += on_dismiss p.Popup()
def __init__(self, parent, style=wx.CB_READONLY): super(TreeCombo, self).__init__(parent, style=style) self.readonly = style & wx.CB_READONLY self.on_selected_in_tree = ObserverList() self.popup = TreeCtrlComboPopup() self.popup.SetComboCtrl(self) if not osutils.is_msw(): self.Bind(wx.EVT_KEY_UP, self.on_char)
def on_dismiss(chosen): if not r.Contains(self.ScreenToClient(wx.GetMousePosition())): self.clear_over_list() if chosen is not None: frame.book.SetModule(p.box.modules[chosen]) if osutils.is_msw(): self.Unbind(wx.EVT_MOUSEWHEEL) wx.CallAfter(p.Destroy)
def on_dismiss(chosen): if not r.Contains( self.ScreenToClient(wx.GetMousePosition()) ): self.clear_over_list() if chosen is not None: frame.book.SetModule(p.box.modules[chosen]) if osutils.is_msw(): self.Unbind(wx.EVT_MOUSEWHEEL) wx.CallAfter(p.Destroy)
def popup(self, event): assert (len(mouse_over)) == 1, "Only one thing can have mouse over" name, (pane, rect, title, clipping_rect) = mouse_over.items()[0] if not self.pane_can_be_seen(pane): event.Skip() return frames = [frame for frame, f_title in self.panes if f_title == name] assert len(frames) == 1, "Wrong frame count: %s (%r)" % (name, frames) frame = frames[0] keytext = frame.reference if not isinstance(keytext, basestring): keytext = keytext.text # find the intersection of the clipping rect and the actual rect # this will be the actual rectangle the user can see. r = wx.RectPP(( max(rect[0], clipping_rect[0]), max(rect[1], clipping_rect[1]), ), ( min(rect.Right, clipping_rect.Right), min(rect.Bottom, clipping_rect.Bottom), )) p = ModulePopup(self, event, r, frame.book, keytext) # use the main frame to grab the mouse wheel events, as wxPopupWindow # cannot have focus, nor any of its children # This isn't needed under gtk, as the scroll wheel will automatically # select the window underneath for scrolling if osutils.is_msw(): self.SetFocus() self.Bind(wx.EVT_MOUSEWHEEL, p.box.on_mouse_wheel) def on_dismiss(chosen): if not r.Contains(self.ScreenToClient(wx.GetMousePosition())): self.clear_over_list() if chosen is not None: frame.book.SetModule(p.box.modules[chosen]) if osutils.is_msw(): self.Unbind(wx.EVT_MOUSEWHEEL) wx.CallAfter(p.Destroy) p.on_dismiss += on_dismiss p.Popup()
def __init__(self, parent, event, rect, book, key, style=wx.NO_BORDER): super(ModulePopup, self).__init__(parent, style) panel = wx.Panel(self)#, style=wx.RAISED_BORDER, pos=(0, 0)) self.box = PopupList(panel, book, key) #wx.ListBox( # panel, style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.NO_BORDER, # pos=(0, 0) #) self.box.Bind(wx.EVT_LEFT_DOWN, self.ProcessLeftDown) self.box.Bind(wx.EVT_LEFT_UP, self.ProcessLeftDown) self.box.Bind(wx.EVT_MOTION, self.OnMotion) #self.box.Items = book.GetModuleList() #if book.version: # self.box.SetStringSelection(book.version) #I:\python\bpbible\gui\virtuallist.py:46: RuntimeWarning: tp_compare didn't retur #n -1 or -2 for exception s = [400, 300]#self.box.GetBestSize() + (250, 200) # don't display empty whitespace at the end of the list unless needed bottom = self.box.GetItemRect(self.box.ItemCount - 1).Bottom + 1 if osutils.is_msw(): bottom += 4 if bottom < s[1]: s[1] = bottom self.box.Size = s panel.ClientSize = self.box.Size size_combo = 0 # Show the popup right below or above the button # depending on available screen space... btn = event.EventObject self.SetSize(panel.GetSize())# - (0, size_combo) pos = btn.ClientToScreen(rect.TopRight) self.Position(pos, (-rect.Width, rect.Height)) self.on_dismiss = ObserverList()
def __init__(self, parent, event, rect, book, key, style=wx.NO_BORDER): super(ModulePopup, self).__init__(parent, style) panel = wx.Panel(self) #, style=wx.RAISED_BORDER, pos=(0, 0)) self.box = PopupList(panel, book, key) #wx.ListBox( # panel, style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.NO_BORDER, # pos=(0, 0) #) self.box.Bind(wx.EVT_LEFT_DOWN, self.ProcessLeftDown) self.box.Bind(wx.EVT_LEFT_UP, self.ProcessLeftDown) self.box.Bind(wx.EVT_MOTION, self.OnMotion) #self.box.Items = book.GetModuleList() #if book.version: # self.box.SetStringSelection(book.version) #I:\python\bpbible\gui\virtuallist.py:46: RuntimeWarning: tp_compare didn't retur #n -1 or -2 for exception s = [400, 300] #self.box.GetBestSize() + (250, 200) # don't display empty whitespace at the end of the list unless needed bottom = self.box.GetItemRect(self.box.ItemCount - 1).Bottom + 1 if osutils.is_msw(): bottom += 4 if bottom < s[1]: s[1] = bottom self.box.Size = s panel.ClientSize = self.box.Size size_combo = 0 # Show the popup right below or above the button # depending on available screen space... btn = event.EventObject self.SetSize(panel.GetSize()) # - (0, size_combo) pos = btn.ClientToScreen(rect.TopRight) self.Position(pos, (-rect.Width, rect.Height)) self.on_dismiss = ObserverList()
def on_char(self, event): if osutils.is_msw(): self.force_alt_key_to_work_correctly(event) guiutil.dispatch_keypress(self.get_actions(), event)
or osutils.find_file_in_path("xulrunner-stub")) if xulrunner_path: return os.path.dirname(os.path.realpath(xulrunner_path)) path = os.path.join(os.getcwd(), "xulrunner") if not os.path.isdir(path): # XXX: Perhaps we should make this error handling a little more friendly? sys.stderr.write("Unable to find XULRunner.\n") sys.exit(1) return path xulrunner_path = find_xulrunner_path() dprint(MESSAGE, "XULRunner path is", xulrunner_path) if osutils.is_msw(): os.environ['PATH'] = xulrunner_path + ';' + os.environ['PATH'] dprint(MESSAGE, "importing wx.wc") import wx.wc dprint(MESSAGE, "/importing wx") # make sure contribs can be imported... import contrib import config, guiconfig from util import confparser from util.configmgr import config_manager import util.i18n
osutils.find_file_in_path("xulrunner-stub")) if xulrunner_path: return os.path.dirname(os.path.realpath(xulrunner_path)) path = os.path.join(os.getcwd(), "xulrunner") if not os.path.isdir(path): # XXX: Perhaps we should make this error handling a little more friendly? sys.stderr.write("Unable to find XULRunner.\n") sys.exit(1) return path xulrunner_path = find_xulrunner_path() dprint(MESSAGE, "XULRunner path is", xulrunner_path) if osutils.is_msw(): os.environ['PATH'] = xulrunner_path + ';' + os.environ['PATH'] dprint(MESSAGE, "importing wx.wc") import wx.wc dprint(MESSAGE, "/importing wx") # make sure contribs can be imported... import contrib import config, guiconfig from util import confparser from util.configmgr import config_manager import util.i18n