def open_browser(word, config): if (not config.get('open_in_browser', True)): return None url = 'https://en.oxforddictionaries.com/definition/' + str(word) tooltip(("Loading..."), period=1000) url = QUrl(url) QDesktopServices.openUrl(url)
def wadoku(self, field_list=expression_fields): "Look up TEXT with Wadoku (German-Japanese)." if field_list: text = self.get_text_from_fields(field_list) else: text = self.get_selection() if len(text) == 0: raise ValueError(u"Kein Text zum nachschlagen.") base_url = "http://www.wadoku.de/wadoku/search/" url = base_url + urllib.quote(text.encode("utf-8")) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def forvo(self, field_list=expression_fields): "Look up pronunciation on forvo." if field_list: text = self.get_text_from_fields(field_list) else: text = self.get_selection() if len(text) == 0: raise ValueError(u"No text to look up.") new_text = urllib.quote(text.encode("utf-8")) url = ("http://de.forvo.com/search/" + new_text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def lookup_forvo(field_list): "Look up pronunciation on forvo." if field_list: text = get_text_from_fields(field_list) else: text = get_selection() if len(text) == 0: raise ValueError(u"No text to look up.") new_text = urllib.quote(text.encode("utf-8")) url = ("http://de.forvo.com/search/" + new_text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def lookup_wadoku(field_list): "Look up text with Wadoku (German-Japanese)." if field_list: text = get_text_from_fields(field_list) else: text = get_selection() if len(text) == 0: raise ValueError(u"Kein Text zum nachschlagen.") base_url = "http://www.wadoku.de/wadoku/search/" url = base_url + urllib.quote(text.encode("utf-8")) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def kanjilexikon(self, field_list=expression_fields): """Look up first kanji in text on Kanji-Lexikon.""" if field_list: kanji = self.get_text_from_fields(field_list) else: kanji = self.get_selection() kanji = self.get_han_characters(kanji) if len(kanji) == 0: raise ValueError("No kanji found.") new_text = urllib.quote(kanji.encode("utf-8")) url = ("http://lingweb.eva.mpg.de/kanji/index.html?kanji=" + new_text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def lookup_kanjilexikon(field_list): """Look up the kanji in text on Kanji-Lexikon.""" if field_list: kanji = get_text_from_fields(field_list) else: kanji = get_selection() kanji = get_han_characters(kanji) if len(kanji) == 0: raise ValueError("No kanji found.") new_text = urllib.quote(kanji.encode("utf-8")) url = ("http://lingweb.eva.mpg.de/kanji/index.html?kanji=" + new_text) qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def saiga(self, field_list=expression_fields): """Look up first kanji in text on Saiga.""" # I don’t really use this dictionary any more. Feel free to # add it to your menu again. if field_list: kanji = self.get_text_from_fields(field_list) else: kanji = self.get_selection() kanji = self.get_first_han_character(kanji) if len(kanji) == 0: raise ValueError("No kanji found.") new_text = urllib.quote(kanji.encode("utf-8")) url = ("http://www.saiga-jp.com/cgi-bin/dic.cgi?m=search&sc=0&f=0&j=" + new_text + "&g=&e=&s=&rt=0&start=1") qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def lookup_saiga(field_list): """Look up the first kanji in text on Saiga.""" # I don’t really use this dictionary any more. Feel free to # add it to your menu again. if field_list: kanji = get_text_from_fields(field_list) else: kanji = get_selection() kanji = get_first_han_character(kanji) if len(kanji) == 0: raise ValueError("No kanji found.") new_text = urllib.quote(kanji.encode("utf-8")) url = ("http://www.saiga-jp.com/cgi-bin/dic.cgi?m=search&sc=0&f=0&j=" + new_text + "&g=&e=&s=&rt=0&start=1") qurl = QUrl() qurl.setEncodedUrl(url) QDesktopServices.openUrl(qurl)
def show_in_filemanager(filename): """mod of aqt.utils openFolder""" _, path, _, _ = process_path(filename) if isWin: subprocess.Popen(f'explorer /select, "file://{path}" ') elif isMac: with noBundledLibs(): script = """ tell application \"Finder\" activate select POSIX file \"{}\" end tell """.format(path) subprocess.Popen(osascript_to_args(script)) elif isLin: us = gc("File Manager in Linux and its args") us = check_if_executable_exists(us[0]) if not us: return if us: us.append("file://" + path) subprocess.Popen(us, env=env_adjust()) else: select_supported = ["dolphin", "nautilus" ] # caja 1.24 doesn't have "--select" for fm in select_supported: if which(fm) is not None: subprocess.Popen([fm, "--select", "file://" + path], env=env_adjust()) else: showInfo( "The file manager will show your media folder. The name of the file you " f"clicked is:\n\n{os.path.dirname(path)}") with noBundledLibs(): QDesktopServices.openUrl( QUrl("file://" + os.path.dirname(path)))
def openLink(link): tooltip(_("Loading..."), period=1000) with noBundledLibs(): QDesktopServices.openUrl(QUrl(link))
def openFolder(path): if isWin: subprocess.Popen(["explorer", "file://"+path]) else: with noBundledLibs(): QDesktopServices.openUrl(QUrl("file://" + path))
def get_help() -> None: "Launch the documentation for this dialog in a browser." url = QUrl( r"https://sobjornstad.github.io/TiddlyRemember/#Configuring%20the%20Anki%20add-on" ) QDesktopServices.openUrl(url)
def lookup_online(url, searchterm): # searches based on a url and a term if searchterm: QDesktopServices.openUrl(QUrl(url % searchterm))