View Single Post
Old 06-01-2025, 09:54 AM   #41
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,739
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Since my plugin only has one QFileDialog importing the whole plugin_utils_light.py library might be a bit overkill.
I put a valid plugin.ico file in the plugin folder and used the following code, but the taskbar icon is still shown.

Spoiler:
Code:
def run(bk):   
    # check for supported versions
    if bk.launcher_version() < 20160707:
        print("This plugin requires Sigil 0.9.8 or later.\n\nPlease click OK to close the Plugin Runner window.")
        return -1

    def ensure_windows_taskbar_icon():
        if not iswindows:
            return
        import ctypes
        myappid = 'mycompany.myproduct.subproduct.version'  # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    # Try to import PySide6, then PyQt5
    try:
        from PySide6.QtWidgets import QApplication, QFileDialog
        from PySide6.QtGui import QClipboard, QIcon
    except ImportError:
        try:
            from PyQt5.QtWidgets import QApplication, QFileDialog
            from PyQt5.QtGui import QClipboard, QIcon
        except ImportError:
            raise RuntimeError("No supported GUI framework found (PySide6 or PyQt5).")

    def get_file_path():
        ''' displays a file selection dialog '''
        app = QApplication(sys.argv)
        app.setWindowIcon(QIcon("plugin.ico"))
        ensure_windows_taskbar_icon()
        fpath, _ = QFileDialog.getOpenFileName(
            None,
            "Select LanguageTool Java file",
            "",
            "languagetool-commandline.jar (*.jar)"
        )
        app.quit()

        if not fpath:
            print("Plugin cancelled by user.")
            bk.add_result('info', None, None, 'Plugin cancelled by user.')
            return 0
        else:
            return fpath


What other parts of plugin_utils_light.py will I also need to add to get rid of the icon?
Doitsu is offline   Reply With Quote