I'm using the --windowed flag

I am having trouble using the --windowed flag. When I use the flag, my virus and threat protection doesn’t allow me to download the file. Here is my command line:python -m PyInstaller --onefile --add-data “C:\Users\Yarden\OneDrive\Documents\Python\randofolder\Recording.wav;Recording;Recording.wav” random2.py.Where should I be placing the --windowed flag, could/should I be using an alternative flag? Here is my code if it is helpful:

import turtle
import random
import pygame
import tkinter as tk
import os
import sys
turtle.hideturtle()
turtle.penup()
instruct = turtle.Turtle()
instruct.hideturtle()
instruct.penup()
high = turtle.Turtle()
high.hideturtle()
high.penup()
tap = turtle.Turtle()
tap.hideturtle()
num = turtle.Turtle()
num.hideturtle()
count = 0
rando = 2
state = "playing"
key_pressed = None
if getattr(sys, 'frozen', False):
    app_dir = sys._MEIPASS
else:
    app_dir = os.path.dirname(os.path.abspath(__file__))
for r,d,f in os.walk("c:\\"):
    for files in f:
         if files == "high_score.txt":
              high_score_file = os.path.join(r,files)
high_score_file = os.path.join(app_dir, "high_score.txt")
for r,d,f in os.walk("c:\\"):
    for files2 in f:
         if files2 == "Recording.wav":
              sound_file = os.path.join(r,files2)
pygame.init()
def load_high_score():
    if os.path.exists(high_score_file):
        with open(high_score_file, "r") as file:
            return int(file.read().strip())
    else:
        return 0
def save_high_score(score):
    with open(high_score_file, "w") as file:
        file.write(str(score))
score = load_high_score()
instruct.goto(-150, 200)
instruct.write('Instructions: Pressing "Enter" adds 1 to the starting score of\n0, and each number reflects the percentage of potential loss.\nGoal: Get the highest number possible.')
high.goto(0, 100)
high.write('Highscore: ' + str(score), align='center', font=('Comic Sans MS', 30))
def play_sound(sound_file):
    pygame.mixer.init()
    pygame.mixer.music.load(sound_file)
    pygame.mixer.music.play()
def click(x, y):
    global count, state
    if state == "playing":
        if -100 <= x <= 100 and -100 <= y <= 100:
            count += 1
            rando = random.randint(1, 100)
            turtle.hideturtle()
            circle_number(count)
            tap.clear()
            if rando <= count:
                state = "lost"
                turtle.goto(0, -150)
                turtle.write('You Lost!', align='center', font=('Comic Sans MS', 30))
                turtle.onscreenclick(None)
                play_sound(sound_file)
                turtle.goto(-100, -200)
                turtle.fillcolor('#03fc2c')
                rectangle(200, 50)
                turtle.goto(0, -240)
                turtle.write('Retry', align='center', font=('Fixedsys', 30))
                check_high_score()
def check_high_score():
    global count, score
    if count > score:
        score = count
        save_high_score(score)
        high.clear()
        high.write('Highscore: ' + str(score), align='center', font=('Comic Sans MS', 30))
def click2(x, y):
    global count, state
    if state == "lost" and -100 <= x <= 100 and -25 <= y <= 25:
        state = "playing"
        num.clear()
        count = 0
        circle()
def circle():
    turtle.tracer(0)
    turtle.hideturtle()
    turtle.goto(0, 0)
    turtle.dot(200, 'Red')
    turtle.color('Black')
    tap.goto(0, -30)
    tap.write('Tap!', align='center', font=('Ink Free', 30))
    turtle.hideturtle()
def circle_number(number):
    circle()
    num.goto(0, -30)
    num.write(number, align='center', font=('Ink Free', 30))
    turtle.update()
def rectangle(width, height):
    turtle.begin_fill()
    for _ in range(2):
        turtle.forward(width)
        turtle.right(90)
        turtle.forward(height)
        turtle.right(90)
    turtle.end_fill()
def exit_fullscreen():
    screenTk.attributes("-fullscreen", False)
    screen.setup(width=800, height=600, startx=100, starty=100)
def key_press_escape():
    global key_pressed
    key_pressed = "Escape"
    if key_pressed == "Escape":
        exit_fullscreen()
def on_close():
    pygame.mixer.quit()
    turtle.bye()
screen = turtle.Screen()
screen_width = screen.window_width()
screen_height = screen.window_height()
root = tk.Toplevel()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
root.destroy()
window_width = 500
window_height = 500
startx = (screen_width - window_width) // 2
starty = (screen_height - window_height) // 2
screen.setup(width=window_width, height=window_height, startx=startx, starty=starty)
screenTk = screen.getcanvas().winfo_toplevel()
screenTk.attributes("-fullscreen", True)
def exit_fullscreen():
    screenTk.attributes("-fullscreen", False)
    screen.setup(width=window_width, height=window_height, startx=startx, starty=starty)
screen.listen()
screen.onkey(exit_fullscreen, "Escape")
screenTk.protocol("WM_DELETE_WINDOW", on_close)
screen.onscreenclick(click)
circle()
turtle.mainloop()

No, you need to bypass your virus protection, it is a bit over eager here. There is nothing really you can do from the pyinstaller side of things.

How would I bypass the virus protection? Do I need to just turn it off? If so anyone else who would download this program would have to do so aswell right?

Your anti virus vendor should have a way for you to submit your .exe as an example of a false positive. They should update their product to fix the issue for you.

Microsoft, for example, has such a process.

Thank you. I will do this, but let’s say I wouldn’t do this, would the user and myself included have to turn off virus protection in order to use this program?

No, it’s usually possible to identify a particular application as a trustworthy exclusion. But yes, users would have to do the same.

However, if I downloaded something that asked me to turn off protection, I’d choose not to use it. I think your best hope for a program you hope to share with others is to report the false positive and hope that the company will adjust the rules they distribute in updates.

Whitelist your directory that has your Python program in your anti-malware package.

It’s also a good idea to have one directory with all your Python programs and subdirs for other projects, so you whitelist just the Python project dir and it’s subdirs.

Like this:

/home/myuser/pyprojects/
/home/myuser/pyprojects/turtle/

Whitelist the /home/myuser/pyprojects dir and all its subdirectories.

The Windows equivalent would be:

c:\users\myuser\pyprojects\
c:\users\myuser\pyprojects\turtle\

Thanks @jeff5 this answered my question. :grinning: