Windowed mode cannot run

2024/7/7 7:28:03

Why does pyinstaller exe not run in windowed mode but fine without it? I have changed over to a windows OS from Linux. Never had any issue before hand, how do I correct this.

Answer

IHO don’t use windowed mode, rather suppress output if you have to.

If you insist on using it, Read this.

In other words:

import sys
import subprocess
from PyQt4 import QtGuidef verify_license():tmp_file = '.license_output'try:with open(tmp_file, 'w+') as file_obj:proc = subprocess.Popen(['echo', 'hi'], shell=True,stdout=file_obj, stderr=subprocess.STDOUT,stdin=subprocess.PIPE)ret = proc.wait()if ret != 0:sys.exit(-1)with open(tmp_file, 'r') as file_obj:output = file_obj.read()except Exception as err:sys.exit(-1)if 'hi' not in output:raise Exception('bad news: output was %s' % (output))def main():app = QtGui.QApplication(sys.argv)w = QtGui.QWidget()w.resize(250, 150)w.move(300, 300)w.setWindowTitle('Simple')w.show()sys.exit(app.exec_())if __name__ == '__main__':verify_license()main()

I still do not recommend this approach however. Redirect or suppress stdout is much better.

https://en.xdnf.cn/q/120312.html

Related Q&A

inserting a variable into an fstring using .replace()

I have a code something similar to bellow. name = Dave message = f<name> is a really great guy! message = message.replace(<name>, {name}) print(message)the variables are a little more compl…

How to allow caps in this input box program for pygame?

I found this input box module on the internet but it only allows lower case no upper. So could someone tell me what to change in the module to allow caps as im creating a small multiplayer game and i n…

Why testing error rate increases at high values of K in KNN algorithm?

I am getting the error rates like this up to 20 values what might be the reason for this ?k_values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] Error [0.0, 0.0, 0.0, 0.0, 0…

Divide and Conquer. Find the majority of element in array

I am working on a python algorithm to find the most frequent element in the list. def GetFrequency(a, element): return sum([1 for x in a if x == element])def GetMajorityElement(a):n = len(a)if n == …

Scraping dynamic webpage using Python

I am trying to scrape following dynamically generated webpage https://www.governmentjobs.com/careers/capecoral?page=1 Ive used requests, scrapy, scrapy-splash but I simply get page source code and I d…

numba cuda deprecation error : how to update my code?

Im running a jupyter notebook frome here : https://github.com/noahgift/nuclear_powered_command_line_tools/blob/master/notebooks/numba-cuda.ipynb The docs of current numba/cuda is here : https://numba.r…

reverse nested dicts using python

I already referred these posts here, here and here. I have a sample dict like as shown below t = {thisdict:{"brand": "Ford","model": "Mustang","year": …

python how to generate permutations of putting a singular character into a word

No idea how to word this so the title sucks my bad, Basically, I have a 4 letter word and I want to generate every permutation of putting a dash in it. So if my word was Cats, I want to get every permu…

Selenium Scraping Javascript Table

I am stuggling to scrape as per code below. Would apprciate it if someone can have a look at what I am missing? Regards PyProg70from selenium import webdriver from selenium.webdriver import FirefoxOp…

PYTHON REGEXP to replace recognized pattern with the pattern itself and the replacement?

Text- .1. This is just awesome.2. Google just ruined Apple.3. Apple ruined itself! pattern = (dot)(number)(dot)(singlespace)Imagine you have 30 to 40 sentences with paragraph numbers in the above patt…