2

Please find below the python code I have written:

from tkinter import *
import os

fenetre = Tk()

label = Label(fenetre, text="Power BI is gonna be open as soon as the program finds an optimal solution.")
label.pack()

fenetre.mainloop()

os.system('cmd /c "pbixrefresher C:\\Users\\LFM\\Desktop\\Optimization.pbix '
          '--refresh-timeout 300000 --no-publish --init-wait 6"')

I have used "-w" when I created the exe file with pyinstaller. When I double-clicked on the created exe file, as requested, only a window appears and not the console. Though, Power BI does not open. Power BI opens only when I close the window. And, at that moment, the command prompt appears.

pyinstaller -F ^
-w ^
C:\Users\LFM\PycharmProjects\Tests\Tests.pyw

Is there a way to not open the command prompt even if I use os.system ?

LFM
  • 61
  • 4

1 Answers1

2

I found an answer here:https://stackoverflow.com/a/7006424/12260358. I used the code below instead of using os.system() and it worked perfectly.

si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.call('cmd /c "pbixrefresher C:\\Users\\LFM\\Desktop\\Optimization.pbix --refresh-timeout 300000 --no-publish --init-wait 6"',
startupinfo=si)
LFM
  • 61
  • 4