View Single Post
Old 06-01-2025, 12:31 PM   #43
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,689
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Doitsu View Post
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?
Hmmm... what you have should really be enough--provided you have the iswindows piece from plugin_utils_light.

I don't see any app.exec() though. So I'm not sure your QApplication (and its icon) is technically being utilized. Try inserting it (app.exec())after the call to ensure_windows_taskbar_icon().

Last edited by DiapDealer; 06-01-2025 at 01:50 PM.
DiapDealer is offline   Reply With Quote