So I'm running a python GUI script, but it gives me the following error:
SyntaxError: Non-UTF-8 code starting with '\x92' in file D:\AIAssistant\build\gui.py on line 92, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
And I'm using this script:
window = Tk()
window.geometry("1440x1024")
window.configure(bg = "#FFFFFF")
canvas = Canvas(
window,
bg = "#FFFFFF",
height = 1024,
width = 1440,
bd = 0,
highlightthickness = 0,
relief = "ridge"
)
canvas.place(x = 0, y = 0)
canvas.create_rectangle(
28.0,
22.0,
534.0,
140.0,
fill="#06FF96",
outline="")
canvas.create_rectangle(
28.0,
367.0,
534.0,
485.0,
fill="#06FF96",
outline="")
canvas.create_rectangle(
28.0,
702.0,
534.0,
820.0,
fill="#06FF96",
outline="")
canvas.create_rectangle(
951.0,
165.0,
1412.0,
283.0,
fill="#00C5F1",
outline="")
canvas.create_rectangle(
951.0,
498.0,
1412.0,
616.0,
fill="#00C5F1",
outline="")
canvas.create_text(
55.0,
52.0,
anchor="nw",
text="Hi there! How can I help?",
fill="#000000",
font=("RobotoCondensed Light", 40 * -1)
)
canvas.create_text(
53.0,
400.0,
anchor="nw",
text="I’m 3y/o on this March. ",
fill="#000000",
font=("RobotoCondensed Light", 40 * -1)
)
canvas.create_text(
55.0,
735.0,
anchor="nw",
text="I’m 3y/o on this March. ",
fill="#000000",
font=("RobotoCondensed Light", 40 * -1)
)
canvas.create_text(
971.0,
199.0,
anchor="nw",
text="Open Google",
fill="#000000",
font=("RobotoCondensed Light", 40 * -1)
)
canvas.create_text(
979.0,
531.0,
anchor="nw",
text="Open Google",
fill="#000000",
font=("RobotoCondensed Light", 40 * -1)
)
entry_image_1 = PhotoImage(
file=relative_to_assets("entry_1.png"))
entry_bg_1 = canvas.create_image(
607.0,
957.5,
image=entry_image_1
)
entry_1 = Entry(
bd=0,
bg="#FFFFFF",
highlightthickness=0
)
entry_1.place(
x=55.0,
y=920.0,
width=1104.0,
height=73.0
)
button_image_1 = PhotoImage(
file=relative_to_assets("button_1.png"))
button_1 = Button(
image=button_image_1,
borderwidth=0,
highlightthickness=0,
command=lambda: print("button_1 clicked"),
relief="flat"
)
button_1.place(
x=1176.0,
y=919.0,
width=118.0,
height=75.0
)
window.resizable(False, False)
window.mainloop()
I searched for this question too but didn't find the right solution. And the most important thing is I'm using Python 3.10.1. The file was generated by TKdesigner and my os system is Windows 10.
Thanks in advance!