How to fix an AttributeError when compiling with pyinstaller
When I am compiling my python program with pyinstaller I get this error at the end of compiling:
File "c:usersred4dappdatalocalprogramspythonpython36-32libsite-packagesPyInstallerhookspre_safe_import_modulehook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'
I was not getting this error yesterday, and I have not significantly changed my code. Please Help!
I have a significant amount of code, but I believe the problem is somewhere in the following:
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
Here is the complete individual file in the project:
import pygame
import default as v
#import os
import time
#import webbrowser
import tkinter
import tkinter.ttk
from tkcolorpicker import askcolor
#Primary Menu Functions
def menu():
global menu_done
global submenu
menu_done = False
clear()
print("MENUn", bold=True)
print("1. Instructions")
print("2. History")
print("3. Settings")
print("4. Quit Scoreboard")
print("5. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
instructions()
elif submenu == 2:
history()
elif submenu == 3:
settings()
elif submenu == 4:
quit()
elif submenu == 5:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 5)."
print_input()
def instructions():
global menu_done
global submenu
clear()
print("INSTRUCTIONSn", bold=True)
print("Instructions Window Will Open (Close Before Continuing)")
#webbrowser.open(os.getcwd() + "/assets/ReadMe.txt")
root = tkinter.Tk()
root.title("Instructions")
S = tkinter.Scrollbar(root)
T = tkinter.Text(root, height=34, width=110)
S.pack(side="right", fill="y")
T.pack(side="left", fill="y")
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
T.insert("end", open("assets/ReadMe.txt").read())
tkinter.mainloop()
menu()
def history():
global menu_done
global submenu
clear()
print("HISTORY", bold=True)
print(v.history)
print("n1. Return")
print("2. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
menu()
break
elif submenu == 2:
menu_done = True
break
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
def quit():
global menu_done
global submenu
menu_done = False
clear()
print("QUITn", bold=True)
print("Are you sure you want to quit? Your work will not be saved.n")
print("1. Yes, Quit")
print("2. Return")
print("3. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
v.done = True
v.restart = False
menu_done = True
break
elif submenu == 2:
menu()
break
elif submenu == 3:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 3)."
print_input()
#Simple Action Functions
def clear():
global text_line
global submenu
global submenu_go
pygame.draw.rect(v.screen, (255, 255, 255), [0, 0, 1235, 559]) #[x position, y position, width, height]
pygame.display.flip() #Refresh Screen
text_line = 0
submenu = ""
submenu_go = False
def print(text, **kwargs):
global text_line
font_menu = pygame.font.SysFont('Courier New', 18, bold=kwargs.get("bold", None), italic=kwargs.get("italic", None))
for line in text.split("n"):
menu1 = font_menu.render(line, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), text_line*18))
pygame.display.flip() #Refresh Screen
text_line += 1
def input(**kwargs):
global submenu_go
while not submenu_go:
menu_check_events(characters=kwargs.get("characters", None))
submenu_go = False
def print_input():
global text_line
global submenu
pygame.draw.rect(v.screen, (255, 255, 255), [0, (text_line + 1) * 18, 1235, 18])
font_menu = pygame.font.SysFont('Courier New', 18)
menu1 = font_menu.render(submenu, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), (text_line + 1) * 18))
pygame.display.flip() #Refresh Screen
def write(string, line):
with open("assets/settings/Settings.txt") as settings:
config = settings.readlines()
file = open("assets/settings/Settings.txt","w")
for re_line in range(0, line - 1):
file.write(config[re_line])
file.write(string + "n")
for re_line in range(line, len(config)):
file.write(config[re_line])
def menu_check_events(**kwargs):
global menu_done
global submenu
global submenu_go
characters = kwargs.get("characters", None)
for event in pygame.event.get(): #Event Occurs
if event.type == pygame.QUIT:
quit()
elif event.type == pygame.KEYDOWN: #Key Pressed
try:
if "Please" in submenu:
submenu = ""
except:
pass
if event.key == pygame.K_ESCAPE: #Escape Key
menu_done = True
submenu_go = True
elif event.key == pygame.K_RETURN:
if submenu != "":
if characters == "numbers":
submenu = int(submenu)
submenu_go = True
elif event.key == pygame.K_BACKSPACE:
submenu = submenu[:-1]
print_input()
else:
try:
if -1 < int(event.unicode) < 10:
submenu += event.unicode
print_input()
except:
if not characters == "numbers":
submenu += event.unicode
print_input()
python pyinstaller
add a comment |
When I am compiling my python program with pyinstaller I get this error at the end of compiling:
File "c:usersred4dappdatalocalprogramspythonpython36-32libsite-packagesPyInstallerhookspre_safe_import_modulehook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'
I was not getting this error yesterday, and I have not significantly changed my code. Please Help!
I have a significant amount of code, but I believe the problem is somewhere in the following:
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
Here is the complete individual file in the project:
import pygame
import default as v
#import os
import time
#import webbrowser
import tkinter
import tkinter.ttk
from tkcolorpicker import askcolor
#Primary Menu Functions
def menu():
global menu_done
global submenu
menu_done = False
clear()
print("MENUn", bold=True)
print("1. Instructions")
print("2. History")
print("3. Settings")
print("4. Quit Scoreboard")
print("5. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
instructions()
elif submenu == 2:
history()
elif submenu == 3:
settings()
elif submenu == 4:
quit()
elif submenu == 5:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 5)."
print_input()
def instructions():
global menu_done
global submenu
clear()
print("INSTRUCTIONSn", bold=True)
print("Instructions Window Will Open (Close Before Continuing)")
#webbrowser.open(os.getcwd() + "/assets/ReadMe.txt")
root = tkinter.Tk()
root.title("Instructions")
S = tkinter.Scrollbar(root)
T = tkinter.Text(root, height=34, width=110)
S.pack(side="right", fill="y")
T.pack(side="left", fill="y")
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
T.insert("end", open("assets/ReadMe.txt").read())
tkinter.mainloop()
menu()
def history():
global menu_done
global submenu
clear()
print("HISTORY", bold=True)
print(v.history)
print("n1. Return")
print("2. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
menu()
break
elif submenu == 2:
menu_done = True
break
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
def quit():
global menu_done
global submenu
menu_done = False
clear()
print("QUITn", bold=True)
print("Are you sure you want to quit? Your work will not be saved.n")
print("1. Yes, Quit")
print("2. Return")
print("3. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
v.done = True
v.restart = False
menu_done = True
break
elif submenu == 2:
menu()
break
elif submenu == 3:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 3)."
print_input()
#Simple Action Functions
def clear():
global text_line
global submenu
global submenu_go
pygame.draw.rect(v.screen, (255, 255, 255), [0, 0, 1235, 559]) #[x position, y position, width, height]
pygame.display.flip() #Refresh Screen
text_line = 0
submenu = ""
submenu_go = False
def print(text, **kwargs):
global text_line
font_menu = pygame.font.SysFont('Courier New', 18, bold=kwargs.get("bold", None), italic=kwargs.get("italic", None))
for line in text.split("n"):
menu1 = font_menu.render(line, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), text_line*18))
pygame.display.flip() #Refresh Screen
text_line += 1
def input(**kwargs):
global submenu_go
while not submenu_go:
menu_check_events(characters=kwargs.get("characters", None))
submenu_go = False
def print_input():
global text_line
global submenu
pygame.draw.rect(v.screen, (255, 255, 255), [0, (text_line + 1) * 18, 1235, 18])
font_menu = pygame.font.SysFont('Courier New', 18)
menu1 = font_menu.render(submenu, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), (text_line + 1) * 18))
pygame.display.flip() #Refresh Screen
def write(string, line):
with open("assets/settings/Settings.txt") as settings:
config = settings.readlines()
file = open("assets/settings/Settings.txt","w")
for re_line in range(0, line - 1):
file.write(config[re_line])
file.write(string + "n")
for re_line in range(line, len(config)):
file.write(config[re_line])
def menu_check_events(**kwargs):
global menu_done
global submenu
global submenu_go
characters = kwargs.get("characters", None)
for event in pygame.event.get(): #Event Occurs
if event.type == pygame.QUIT:
quit()
elif event.type == pygame.KEYDOWN: #Key Pressed
try:
if "Please" in submenu:
submenu = ""
except:
pass
if event.key == pygame.K_ESCAPE: #Escape Key
menu_done = True
submenu_go = True
elif event.key == pygame.K_RETURN:
if submenu != "":
if characters == "numbers":
submenu = int(submenu)
submenu_go = True
elif event.key == pygame.K_BACKSPACE:
submenu = submenu[:-1]
print_input()
else:
try:
if -1 < int(event.unicode) < 10:
submenu += event.unicode
print_input()
except:
if not characters == "numbers":
submenu += event.unicode
print_input()
python pyinstaller
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago
add a comment |
When I am compiling my python program with pyinstaller I get this error at the end of compiling:
File "c:usersred4dappdatalocalprogramspythonpython36-32libsite-packagesPyInstallerhookspre_safe_import_modulehook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'
I was not getting this error yesterday, and I have not significantly changed my code. Please Help!
I have a significant amount of code, but I believe the problem is somewhere in the following:
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
Here is the complete individual file in the project:
import pygame
import default as v
#import os
import time
#import webbrowser
import tkinter
import tkinter.ttk
from tkcolorpicker import askcolor
#Primary Menu Functions
def menu():
global menu_done
global submenu
menu_done = False
clear()
print("MENUn", bold=True)
print("1. Instructions")
print("2. History")
print("3. Settings")
print("4. Quit Scoreboard")
print("5. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
instructions()
elif submenu == 2:
history()
elif submenu == 3:
settings()
elif submenu == 4:
quit()
elif submenu == 5:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 5)."
print_input()
def instructions():
global menu_done
global submenu
clear()
print("INSTRUCTIONSn", bold=True)
print("Instructions Window Will Open (Close Before Continuing)")
#webbrowser.open(os.getcwd() + "/assets/ReadMe.txt")
root = tkinter.Tk()
root.title("Instructions")
S = tkinter.Scrollbar(root)
T = tkinter.Text(root, height=34, width=110)
S.pack(side="right", fill="y")
T.pack(side="left", fill="y")
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
T.insert("end", open("assets/ReadMe.txt").read())
tkinter.mainloop()
menu()
def history():
global menu_done
global submenu
clear()
print("HISTORY", bold=True)
print(v.history)
print("n1. Return")
print("2. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
menu()
break
elif submenu == 2:
menu_done = True
break
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
def quit():
global menu_done
global submenu
menu_done = False
clear()
print("QUITn", bold=True)
print("Are you sure you want to quit? Your work will not be saved.n")
print("1. Yes, Quit")
print("2. Return")
print("3. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
v.done = True
v.restart = False
menu_done = True
break
elif submenu == 2:
menu()
break
elif submenu == 3:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 3)."
print_input()
#Simple Action Functions
def clear():
global text_line
global submenu
global submenu_go
pygame.draw.rect(v.screen, (255, 255, 255), [0, 0, 1235, 559]) #[x position, y position, width, height]
pygame.display.flip() #Refresh Screen
text_line = 0
submenu = ""
submenu_go = False
def print(text, **kwargs):
global text_line
font_menu = pygame.font.SysFont('Courier New', 18, bold=kwargs.get("bold", None), italic=kwargs.get("italic", None))
for line in text.split("n"):
menu1 = font_menu.render(line, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), text_line*18))
pygame.display.flip() #Refresh Screen
text_line += 1
def input(**kwargs):
global submenu_go
while not submenu_go:
menu_check_events(characters=kwargs.get("characters", None))
submenu_go = False
def print_input():
global text_line
global submenu
pygame.draw.rect(v.screen, (255, 255, 255), [0, (text_line + 1) * 18, 1235, 18])
font_menu = pygame.font.SysFont('Courier New', 18)
menu1 = font_menu.render(submenu, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), (text_line + 1) * 18))
pygame.display.flip() #Refresh Screen
def write(string, line):
with open("assets/settings/Settings.txt") as settings:
config = settings.readlines()
file = open("assets/settings/Settings.txt","w")
for re_line in range(0, line - 1):
file.write(config[re_line])
file.write(string + "n")
for re_line in range(line, len(config)):
file.write(config[re_line])
def menu_check_events(**kwargs):
global menu_done
global submenu
global submenu_go
characters = kwargs.get("characters", None)
for event in pygame.event.get(): #Event Occurs
if event.type == pygame.QUIT:
quit()
elif event.type == pygame.KEYDOWN: #Key Pressed
try:
if "Please" in submenu:
submenu = ""
except:
pass
if event.key == pygame.K_ESCAPE: #Escape Key
menu_done = True
submenu_go = True
elif event.key == pygame.K_RETURN:
if submenu != "":
if characters == "numbers":
submenu = int(submenu)
submenu_go = True
elif event.key == pygame.K_BACKSPACE:
submenu = submenu[:-1]
print_input()
else:
try:
if -1 < int(event.unicode) < 10:
submenu += event.unicode
print_input()
except:
if not characters == "numbers":
submenu += event.unicode
print_input()
python pyinstaller
When I am compiling my python program with pyinstaller I get this error at the end of compiling:
File "c:usersred4dappdatalocalprogramspythonpython36-32libsite-packagesPyInstallerhookspre_safe_import_modulehook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'
I was not getting this error yesterday, and I have not significantly changed my code. Please Help!
I have a significant amount of code, but I believe the problem is somewhere in the following:
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
Here is the complete individual file in the project:
import pygame
import default as v
#import os
import time
#import webbrowser
import tkinter
import tkinter.ttk
from tkcolorpicker import askcolor
#Primary Menu Functions
def menu():
global menu_done
global submenu
menu_done = False
clear()
print("MENUn", bold=True)
print("1. Instructions")
print("2. History")
print("3. Settings")
print("4. Quit Scoreboard")
print("5. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
instructions()
elif submenu == 2:
history()
elif submenu == 3:
settings()
elif submenu == 4:
quit()
elif submenu == 5:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 5)."
print_input()
def instructions():
global menu_done
global submenu
clear()
print("INSTRUCTIONSn", bold=True)
print("Instructions Window Will Open (Close Before Continuing)")
#webbrowser.open(os.getcwd() + "/assets/ReadMe.txt")
root = tkinter.Tk()
root.title("Instructions")
S = tkinter.Scrollbar(root)
T = tkinter.Text(root, height=34, width=110)
S.pack(side="right", fill="y")
T.pack(side="left", fill="y")
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
T.insert("end", open("assets/ReadMe.txt").read())
tkinter.mainloop()
menu()
def history():
global menu_done
global submenu
clear()
print("HISTORY", bold=True)
print(v.history)
print("n1. Return")
print("2. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
menu()
break
elif submenu == 2:
menu_done = True
break
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
def settings():
global menu_done
global submenu
try:
if v.sport.lower() == "football":
import football.initialize as img
elif v.sport.lower() == "hockey":
import hockey.initialize as img
except:
v.sport = ""
clear()
print("SETTINGSn", bold=True)
print("Note: Settings will not update until menu is exited.n", italic=True)
print("1. Sport: " + v.sport)
print("2. Logo")
print("3. Home Name: " + v.home_name)
print("4. Home Standings: " + v.home_standings)
print("5. Home Color: " + str(v.home_color))
print("6. Home Logo")
print("7. Guest Name: " + v.guest_name)
print("8. Guest Standings: " + v.guest_standings)
print("9. Guest Color: " + str(v.guest_color))
print("10. Guest Logo")
print("11. Possession Position: " + v.possession_position)
print("n12. Return")
print("13. Exit")
while True:
if menu_done:
submenu = 0
break
input(characters="numbers")
if submenu < 1 or submenu > 13:
print("Please input a numbered option (1 - 13).")
else:
break
#Sport
if submenu == 1:
clear()
print("SETTINGSn", bold=True)
print("Choose Sportn")
print("1. Football")
print("2. Hockey")
print("3. Return")
while True:
if menu_done:
submenu = 0
break
else:
input(characters="numbers")
if submenu < 1 or submenu > 3:
print("Please input a numbered option (1 - 3).")
else:
break
if submenu == 3:
settings()
elif submenu == 1 or submenu == 2:
print("nThis setting requires a program restart, your scores will not be saved.n")
print("Would you like to continue with the restart?n")
print("1. Yes, Restart")
print("2. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
if submenu == 1:
v.sport = "Football"
elif submenu == 2:
v.sport = "Hockey"
write(v.sport, 2)
v.restart = True
v.done = True
menu_done = True
elif submenu == 2:
settings()
else:
submenu = "Please input a numbered option (1, 2)."
print_input()
#Logo
elif submenu == 2:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Logon")
if not menu_done:
if v.open_image("assets/logo.png", 86):
img.logo_img = pygame.transform.scale(pygame.image.load('assets/logo.png'), (86, 86))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Home Name
elif submenu == 3:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_name = submenu
write(v.home_name, 5)
settings()
#Home Standings
elif submenu == 4:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Standingsn")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.home_standings = submenu
write(v.home_standings, 8)
settings()
#Home Color
elif submenu == 5:
clear()
print("SETTINGSn", bold=True)
print("Enter New Home Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.home_color, parent=None, title="Home Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.home_color = col[0]
v.home_dark_color = list()
for x in range(3):
if v.home_color[x] >= 30:
v.home_dark_color.append(v.home_color[x] - 30)
else:
v.home_dark_color.append(0)
settings()
# if not menu_done:
# input()
# if submenu == "1":
# settings()
# else:
# while True:
# try:
# v.home_color = submenu
# write(str(v.home_color), 11)
# v.home_color = v.home_color.replace("(", "")
# v.home_color = v.home_color.replace(")", "")
# v.home_color = (int(v.home_color.split(",")[0]), int(v.home_color.split(",")[1]), int(v.home_color.split(",")[2]))
# v.home_dark_color = list()
# for x in range(3):
# if v.home_color[x] >= 30:
# v.home_dark_color.append(v.home_color[x] - 30)
# else:
# v.home_dark_color.append(0)
# settings()
# break
# except:
# print("nPlease use format "#, #, #"")
# input()
#Home Logo
elif submenu == 6:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Home Logon")
if not menu_done:
if v.open_image("assets/home_logo.png", 45):
img.home_logo_img = pygame.transform.scale(pygame.image.load('assets/home_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Guest Name
elif submenu == 7:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Name")
print("<12 characters recommendedn")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_name = submenu
write(v.guest_name, 14)
settings()
#Guest Standings
elif submenu == 8:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Standings")
print(""#-#" or "#-#-#"n")
print("1. Return")
if not menu_done:
input()
if submenu == "1":
settings()
else:
v.guest_standings = submenu
write(v.guest_standings, 17)
settings()
#Guest Color
elif submenu == 9:
clear()
print("SETTINGSn", bold=True)
print("Enter New Guest Colorn")
print("Color Window Will Open (Close All Windows Before Continuing)n")
root = tkinter.Tk()
col = askcolor(color=v.guest_color, parent=None, title="Guest Color", alpha=False)
root.mainloop()
if col[0] is not None:
write(str(col[0]), 11)
v.guest_color = col[0]
v.guest_dark_color = list()
for x in range(3):
if v.guest_color[x] >= 30:
v.guest_dark_color.append(v.guest_color[x] - 30)
else:
v.guest_dark_color.append(0)
settings()
#Guest Logo
elif submenu == 10:
clear()
print("SETTINGSn", bold=True)
print("Choose A New Guest Logon")
if not menu_done:
if v.open_image("assets/guest_logo.png", 45):
img.guest_logo_img = pygame.transform.scale(pygame.image.load('assets/guest_logo.png'), (45, 45))
else:
submenu = "ERROR: Please select an image file (.png, .jpg, .jpeg, .gif)"
print_input()
time.sleep(2)
submenu = ""
settings()
#Possession Position
elif submenu == 11:
clear()
print("SETTINGSn", bold=True)
print("Choose a Possession Position")
print("(For Football Only)n")
print("1. Top (reccomended)")
print("2. Bottom")
print("3. None")
print("4. Return")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 4:
settings()
elif submenu == 1 or submenu == 2 or submenu == 3:
if submenu == 1:
v.possession_position = "top"
elif submenu == 2:
v.possession_position = "bottom"
elif submenu == 3:
v.possession_position = "none"
write(v.possession_position, 23)
settings()
break
else:
print("Please input a numbered option (1, 2, 3, 4).")
#Return
elif submenu == 12:
menu()
#Exit
elif submenu == 13:
menu_done = True
def quit():
global menu_done
global submenu
menu_done = False
clear()
print("QUITn", bold=True)
print("Are you sure you want to quit? Your work will not be saved.n")
print("1. Yes, Quit")
print("2. Return")
print("3. Exit")
while True:
if menu_done:
break
input(characters="numbers")
if submenu == 1:
v.done = True
v.restart = False
menu_done = True
break
elif submenu == 2:
menu()
break
elif submenu == 3:
menu_done = True
break
else:
submenu = "Please input a numbered option (1 - 3)."
print_input()
#Simple Action Functions
def clear():
global text_line
global submenu
global submenu_go
pygame.draw.rect(v.screen, (255, 255, 255), [0, 0, 1235, 559]) #[x position, y position, width, height]
pygame.display.flip() #Refresh Screen
text_line = 0
submenu = ""
submenu_go = False
def print(text, **kwargs):
global text_line
font_menu = pygame.font.SysFont('Courier New', 18, bold=kwargs.get("bold", None), italic=kwargs.get("italic", None))
for line in text.split("n"):
menu1 = font_menu.render(line, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), text_line*18))
pygame.display.flip() #Refresh Screen
text_line += 1
def input(**kwargs):
global submenu_go
while not submenu_go:
menu_check_events(characters=kwargs.get("characters", None))
submenu_go = False
def print_input():
global text_line
global submenu
pygame.draw.rect(v.screen, (255, 255, 255), [0, (text_line + 1) * 18, 1235, 18])
font_menu = pygame.font.SysFont('Courier New', 18)
menu1 = font_menu.render(submenu, True, (0, 0, 0))
v.screen.blit(menu1, (617 - (menu1.get_rect().width/2), (text_line + 1) * 18))
pygame.display.flip() #Refresh Screen
def write(string, line):
with open("assets/settings/Settings.txt") as settings:
config = settings.readlines()
file = open("assets/settings/Settings.txt","w")
for re_line in range(0, line - 1):
file.write(config[re_line])
file.write(string + "n")
for re_line in range(line, len(config)):
file.write(config[re_line])
def menu_check_events(**kwargs):
global menu_done
global submenu
global submenu_go
characters = kwargs.get("characters", None)
for event in pygame.event.get(): #Event Occurs
if event.type == pygame.QUIT:
quit()
elif event.type == pygame.KEYDOWN: #Key Pressed
try:
if "Please" in submenu:
submenu = ""
except:
pass
if event.key == pygame.K_ESCAPE: #Escape Key
menu_done = True
submenu_go = True
elif event.key == pygame.K_RETURN:
if submenu != "":
if characters == "numbers":
submenu = int(submenu)
submenu_go = True
elif event.key == pygame.K_BACKSPACE:
submenu = submenu[:-1]
print_input()
else:
try:
if -1 < int(event.unicode) < 10:
submenu += event.unicode
print_input()
except:
if not characters == "numbers":
submenu += event.unicode
print_input()
python pyinstaller
python pyinstaller
edited 2 days ago
DJ Martin
asked Dec 28 '18 at 23:53
DJ MartinDJ Martin
63
63
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago
add a comment |
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965531%2fhow-to-fix-an-attributeerror-when-compiling-with-pyinstaller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965531%2fhow-to-fix-an-attributeerror-when-compiling-with-pyinstaller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show your code?
– pizza static void main
Dec 29 '18 at 0:20
I just added most of it, but there is a significant amount
– DJ Martin
2 days ago