Aldığım hata bu kodu aşağıya bırakıyorum. Vlc sürümü güncel
File “\Programs\Python\Python310\lib\tkinter_init_.py”, line 1921, in call
return self.func(*args)
File “Bilgi Yarışması\Bilgi_Yarismasi.py”, line 221, in startIspressed
startquiz()
File “Bilgi Yarışması\Bilgi_Yarismasi.py”, line 160, in startquiz
music()
File “Desktop\Bilgi Yarışması\Bilgi_Yarismasi.py”, line 35, in music
G = vlc.MediaPlayer("\Bilgi Yarışması\yeni.mp3")
File “…\Python\Python310\lib\site-packages\vlc.py”, line 3263, in new
o = instance.media_player_new()
AttributeError: ‘NoneType’ object has no attribute ‘media_player_new’
import json
import tkinter
from tkinter import *
import random
with open('./data.json', encoding="utf8") as f:
data = json.load(f)
import time
import vlc
from threading import Thread
# from gpiozero import LED # gpiozero kütüphanesi içinden LED'i import ettik.
# ledPin= LED(14) #ledPin'imizi GPIO14 pini olarak ayarladık
# ledPin.on() #Led'imizi yaktık.
questions = [v for v in data[0].values()]
answers_choice = [v for v in data[1].values()]
answers = [0,0,0,0,0,0]
user_answer = []
indexes = []
def gen():
global indexes
while (len(indexes) < 5):
x = random.randint(0, 5)
if x in indexes:
continue
else:
indexes.append(x)
def music():
G = vlc.MediaPlayer("\Bilgi Yarışması\yeni.mp3")
G.play()
time.sleep(2)
G.stop()
def music2():
G = vlc.MediaPlayer("\Bilgi Yarışması\kazanma.mp3")
G.play()
time.sleep(2)
G.stop()
def showresult(score):
lblQuestion.destroy()
r1.destroy()
r2.destroy()
r3.destroy()
r4.destroy()
labelimage = Label(
root,
background="#ffffff",
border=0,
)
labelimage.pack(pady=(50, 30))
labelresulttext = Label(
root,
font=("Consolas", 20),
background="#ffffff",
)
labelresulttext.pack()
labelyazi = Label(
root,
font=("Consolas", 20),
background="#ffffff",
)
labelyazi.pack()
labelscore = Label(
root,
font=("Consolas", 20),
background="#ffffff",
)
labelscore.pack()
if score >= 20:
img = PhotoImage(file="great.png")
labelimage.configure(image=img)
labelimage.image = img
labelresulttext.configure(text="Çok İyisin !!!")
elif (score >= 10 and score < 20):
img = PhotoImage(file="ok.png")
labelimage.configure(image=img)
labelimage.image = img
labelresulttext.configure(text="İyi Ama Biraz Daha Çalışmalısın !!!")
else:
img = PhotoImage(file="bad.png")
labelimage.configure(image=img)
labelimage.image = img
labelresulttext.configure(text="Başarasızz !!!")
labelyazi.configure(text="Toplam Puan")
labelscore.configure(text=score)
def calc():
global indexes, user_answer, answers
x = 0
score = 0
for i in indexes:
if user_answer[x] == answers[i]:
score = score + 20
x += 1
print(score)
showresult(score)
ques = 1
def selected():
global radiovar, user_answer
global lblQuestion, r1, r2, r3, r4
global ques
x = radiovar.get()
user_answer.append(x)
radiovar.set(-1)
if user_answer[ques-1] == answers[ques-1]:
music2()
music()
if ques < 5:
lblQuestion.config(text=questions[indexes[ques]])
r1['text'] = answers_choice[indexes[ques]][0]
r2['text'] = answers_choice[indexes[ques]][1]
r3['text'] = answers_choice[indexes[ques]][2]
r4['text'] = answers_choice[indexes[ques]][3]
ques += 1
else:
print(indexes)
print(user_answer)
# these two lines were just developement code
# we don't need them
calc()
def startquiz():
global lblQuestion, r1, r2, r3, r4
lblQuestion = Label(
root,
text=questions[indexes[0]],
font=("Consolas", 16),
width=500,
justify="center",
wraplength=400,
background="#ffffff",
)
lblQuestion.pack(pady=(100, 30))
music()
global radiovar
radiovar = IntVar()
radiovar.set(-1)
r1 = Radiobutton(
root,
text=answers_choice[indexes[0]][0],
font=("Times", 12),
value=0,
variable=radiovar,
command=selected,
background="#ffffff",
)
r1.pack(pady=5)
r2 = Radiobutton(
root,
text=answers_choice[indexes[0]][1],
font=("Times", 12),
value=1,
variable=radiovar,
command=selected,
background="#ffffff",
)
r2.pack(pady=5)
r3 = Radiobutton(
root,
text=answers_choice[indexes[0]][2],
font=("Times", 12),
value=2,
variable=radiovar,
command=selected,
background="#ffffff",
)
r3.pack(pady=5)
r4 = Radiobutton(
root,
text=answers_choice[indexes[0]][3],
font=("Times", 12),
value=3,
variable=radiovar,
command=selected,
background="#ffffff",
)
r4.pack(pady=5)
def startIspressed():
labelimage.destroy()
labeltext.destroy()
lblInstruction.destroy()
lblRules.destroy()
btnStart.destroy()
gen()
startquiz()
root = tkinter.Tk()
root.title("Bilgi Yarışması")
root.geometry("700x670")
root.config(background="#ffffff")
root.resizable(0, 0)
img1 = PhotoImage(file="foto.png")
labelimage = Label(
root,
image=img1,
background="#ffffff",
)
labelimage.pack(pady=(40, 0))
labeltext = Label(
root,
text="Bilgi Yarışması",
font=("Comic sans MS", 24, "bold"),
background="#ffffff",
)
labeltext.pack(pady=(0, 50))
img2 = PhotoImage(file="Frame.png")
btnStart = Button(
root,
image=img2,
relief=FLAT,
border=0,
command=startIspressed,
)
btnStart.pack()
lblInstruction = Label(
root,
text="Kuralları Oku Ve\nHazır Olduğunda Yarışmaya Başla",
background="#ffffff",
font=("Consolas", 14),
justify="center",
)
lblInstruction.pack(pady=(10, 100))
lblRules = Label(
root,
text="Topla 5 Soru Var Ve Her Soru 20 Puan\nSoruları Dikkatli Okuyun Ve Emin Olunca Cevaplayın\nÇünkü Cevapları Değiştiremezsiniz",
width=100,
font=("Times", 14),
background="#000000",
foreground="#FACA2F",
)
lblRules.pack()
root.mainloop()