def set_font(self): if self.list.book.mod is None: return font = fonts.get_module_gui_font(self.list.book.mod) self.list.Font = font self.text_entry.text.Font = font self.Layout()
def make_lookup_text(self, href): update_ui = self._get_text(_("Look up %s in the dictionary"), href) def on_lookup_click(): """Lookup the selected text in the dictionary""" text = self.SelectionToText() if not text: text = self.get_clicked_cell_text() text = self.strip_text(text) guiconfig.mainfrm.dictionarytext.UpdateUI(text) assert hasattr(self, "mod"), self font = fonts.get_module_gui_font(self.mod, default_to_None=True) return MenuItem("Dictionary lookup", on_lookup_click, update_ui=update_ui, font=font)
def make_search_text(self, href): frame = self.get_frame_for_search() if frame.book == biblemgr.bible: search_text = _("Search for %s in the Bible") else: search_text = _("Search for %s in this book") update_ui = self._get_text(search_text, href, is_search=True) def on_search_click(): """Search for the selected word in the Bible""" strongs_number = None text = None if href: match = re.match(u'strongs://(Greek|Hebrew)/(\d+)(!\w+)?', href) if match: prefix, number, extra = match.group(1, 2, 3) strongs_number = "HG"[prefix == "Greek"] + number if extra: strongs_number += extra[1:] text = "strongs:" + strongs_number if not text: match = re.match(u'morph://(\w*)((:|%3A)[^/]+)/([\w-]+)', href) if match: module, value = match.group(1, 4) if module == "Greek": module = "Robinson" text = "morph:%s:%s" % (module, value) ref = None if not text: match = (re.match( u'n?bible:([^#]*)(#.*)?', href) or re.match( u'passagestudy.jsp\?action=showRef&type=scripRef&' 'value=([^&]*)&module=.*', href)) if match: ref = match.group(1) if ref: ref = SW.URL.decode(str(ref)).c_str() vl = VerseList(ref) first_ref = VerseList([vl[0] ]).GetBestRange(userOutput=True) # only search on the first item or range text = 'ref:"%s"' % first_ref if not text: text = self.SelectionToText() if not text: text = self.get_clicked_cell_text() text = self.strip_text(text) # get rid of a few special characters text = re.sub(r'[\()"/:\-]', '', text) # if this is a phrase, put quotes around it. if " " in text: text = '"%s"' % text search_panel = frame.get_search_panel_for_frame() assert search_panel, "Search panel not found for %s" % self search_panel.search_and_show(text) assert hasattr(self, "mod"), self font = fonts.get_module_gui_font(self.mod, default_to_None=True) return MenuItem("Search on word", on_search_click, update_ui=update_ui, font=font)
def make_search_text(self, href): frame = self.get_frame_for_search() if frame.book == biblemgr.bible: search_text = _("Search for %s in the Bible") else: search_text = _("Search for %s in this book") update_ui = self._get_text( search_text, href, is_search=True) def on_search_click(): """Search for the selected word in the Bible""" strongs_number = None text = None if href: match = re.match(u'strongs://(Greek|Hebrew)/(\d+)(!\w+)?', href) if match: prefix, number, extra = match.group(1, 2, 3) strongs_number = "HG"[prefix=="Greek"] + number if extra: strongs_number += extra[1:] text = "strongs:" + strongs_number if not text: match = re.match(u'morph://(\w*)((:|%3A)[^/]+)/([\w-]+)', href) if match: module, value = match.group(1, 4) if module == "Greek": module = "Robinson" text = "morph:%s:%s" % (module, value) ref = None if not text: match = (re.match(u'n?bible:([^#]*)(#.*)?', href) or re.match( u'passagestudy.jsp\?action=showRef&type=scripRef&' 'value=([^&]*)&module=.*', href)) if match: ref = match.group(1) if ref: ref = SW.URL.decode(str(ref)).c_str() vl = VerseList(ref) first_ref = VerseList([vl[0]]).GetBestRange(userOutput=True) # only search on the first item or range text = 'ref:"%s"' % first_ref if not text: text = self.SelectionToText() if not text: text = self.get_clicked_cell_text() text = self.strip_text(text) # get rid of a few special characters text = re.sub(r'[\()"/:\-]', '', text) # if this is a phrase, put quotes around it. if " " in text: text = '"%s"' % text search_panel = frame.get_search_panel_for_frame() assert search_panel, "Search panel not found for %s" % self search_panel.search_and_show(text) assert hasattr(self, "mod"), self font = fonts.get_module_gui_font(self.mod, default_to_None=True) return MenuItem("Search on word", on_search_click, update_ui=update_ui, font=font)