ProcessStartInfo in .NET MAUI application in macOS adding additional icon in Dock panel

42 views Asked by At

I have .NET MAUI application in macOS. It calling the external application bundle "pythonBundle" which was created from python script and with PyInstaller created the application bundle. The problem what I have that this process is creating additional icon in dock panel in macOS, which I've not expected.

DockPanel Screenshot with 2 icons

Here is the code in .NET where this application is calling.

string filePath = Path.Combine(directoryPath, "pythonBundle");
if (File.Exists(filePath))
{
    string arguments = param[0] + " " + param[1];

    Process process = new Process
    {
        StartInfo = new ProcessStartInfo
        {
            FileName = filePath,
            Arguments = arguments,
            UseShellExecute = false,
            RedirectStandardInput = true,
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            CreateNoWindow = true
        }
    };

    process.OutputDataReceived += new DataReceivedEventHandler(ProcessOutputHandler);
    process.ErrorDataReceived += new DataReceivedEventHandler(ProcessOutputHandler);
    process.Start();

    process.BeginOutputReadLine();
    process.BeginErrorReadLine();
    process.WaitForExit();
}

And here is the simple Python script

import sys
import os
import subprocess
import time
from PyQt6 import QtWidgets, QtGui, QtCore

class LoadingGif(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        
        self.setGeometry(0, 0, 200, 200)
        base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
        imagePath = os.path.join(base_path, "earth.gif")

        self.movie = QtGui.QMovie(imagePath)
        self.movie.setScaledSize(QtCore.QSize(200, 200))

        self.label = QtWidgets.QLabel(self)
        self.label.setGeometry(QtCore.QRect(0, 0, 200, 200))
        self.label.setMovie(self.movie)
        self.label.mousePressEvent = self.CloseWindow
        self.movie.start()
        
        self.setWindowFlag(QtCore.Qt.WindowType.WindowStaysOnTopHint)

    def CloseWindow(self, event):
        sys.exit()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    time.sleep(5)

    window = LoadingGif()
    window.show()
    sys.exit(app.exec())

Can someone help me with this?

0

There are 0 answers