Merhaba herkese,
Sorun denemez gerçi belki de çok basit bir gözden kaçmış bir sorun veya ufak yer değişikliği sırasında çözülebilecek bir problemdir diye düşünüyorum. Sorunumu ss ler ile aktarayım:
from tkinter import *
root = Tk()
for i in range(49):
Label(root,text="a").pack()
mainloop()
Görüyoruz ki hiçbir sorun yok.
(bunu örnek açısından verdim)
Youtube Data V3 API’si ile uğraşıyorum burada da hiç bir problemim yok.
şimdi geliyorum asıl olayaa…
from tkinter import *
from PIL import ImageTk,Image
import requests
import os
from getpass import getuser
class Window:
def mainWindow(self):
cmd = Commands()
self.root = Tk()
self.root.configure(bg="#CCCCCC")
self.root.resizable(False,False)
self.root.geometry("900x500")
img = PhotoImage(file="C:\\Users\\"+getuser()+"\\Desktop\\Coding\\Dogaclama\\6-Proje\\icons\\navbar.png")
img2 = PhotoImage(file="C:\\Users\\"+getuser()+"\\Desktop\\Coding\\Dogaclama\\6-Proje\\icons\\search.png")
# Button(self.root,text="bas",command=cmd.command_1).pack()
navButton=Button(self.root,image=img,border=0,cursor="hand2",bg="#CCCCCC",activebackground="#CCCCCC",command=self.toggleWindow)
navButton.place(x=5,y=10)
navButton.image = img
self.searchEntry = Entry(self.root,width=27,font=(15),bg="#CCCCCC",highlightthickness=2,
highlightbackground="#CCCCCC",fg="black",highlightcolor="gray",
insertbackground="gray")
self.searchEntry.place(x=290,y=10)
self.searchButton = Button(self.root,image=img2,border=0,bg="#CCCCCC",activebackground="#CCCCCC",command=cmd.command_1)# Arama Butonu
self.searchButton.place(x=600,y=10)
self.searchButton.image = img2
##
resim = ImageTk.PhotoImage(Image.open("C:\\Users\\"+getuser()+"\\Desktop\\default.jpg"))
# l = Label(self.root,image=resim)
# l.place(x=80,y=200)
# l.image = resim
def toggleWindow(self):
self.frame = Frame(self.root,width=300,height=500,bg="#A9A9A9")
self.frame.place(x=0,y=0)
img = PhotoImage(file="C:\\Users\\"+getuser()+"\\Desktop\\Coding\\Dogaclama\\6-Proje\\icons\\back.png")
img2 = PhotoImage(file="C:\\Users\\"+getuser()+"\\Desktop\\Coding\\Dogaclama\\6-Proje\\icons\\settings.png")
self.searchEntry.place(x=305,y=10)
self.searchButton.place(x=610,y=10)
# self.searcLabel.place(x=305,y=50)
def shutDown():
self.frame.destroy()
self.searchEntry.place(x=290,y=10)
self.searchButton.place(x=600,y=10)
# self.searcLabel.place(x=300,y=50)
backButton = Button(self.frame,border=0,bg="#A9A9A9",cursor="hand2",activebackground="#A9A9A9",image=img,command=shutDown)
backButton.place(x=5,y=10)
backButton.image = img
l = Label(self.frame,text="Versiyon 0.0.1",bg="#A9A9A9",fg="black",font=("arial",10,"bold"))
l.place(x=100)
settingButton = Button(self.frame,border=0,image=img2,activebackground="#A9A9A9", # Ayarlar
bg="#A9A9A9",cursor="hand2")
settingButton.place(x=260,y=8)
settingButton.image = img2
# self.l.place(x=50,y=80)
class Commands:
def command_1(self):
if ui.searchEntry.get() == "":
pass
else:
self.searcLabel = Label(ui.root,text=ui.searchEntry.get().capitalize()+" İçin Sonuçlar")
self.searcLabel.place(x=300,y=50)
youtube.search_video()
class YT_API:
def __init__(self,api_key):
self.api_key = api_key
def search_video(self):
url = f"https://www.googleapis.com/youtube/v3/search?maxResults=50&part=snippet&q={ui.searchEntry.get()}&key={self.api_key}"
counter = 0
json_url = requests.get(url)
j = json_url.json()
for i in range(49):
Label(ui.root,text=j["items"][counter]["snippet"]["title"]).place(x=300,y=100)
counter += 1
if __name__ == '__main__':
API_KEY = "<API_KEYIM>"
youtube = YT_API(API_KEY)
ui = Window()
ui.mainWindow()
mainloop()
arattığım kelimenin alt alta listeleyebilmesi için, kodlarda da görebileceğiniz üzere
url = f"https://www.googleapis.com/youtube/v3/search?maxResults=50&part=snippet&q={ui.searchEntry.get()}&key={self.api_key}"
counter = 0
json_url = requests.get(url)
j = json_url.json()
for i in range(49):
Label(ui.root,text=j["items"][counter]["snippet"]["title"]).place(x=300,y=100)
counter += 1
for döngüsünde olabileceğini düşündüğüm için böyle bir döngüye aldım. Fakat gel gelelimki üstteki resim gibi yalnızca bir değer döndürüyor.(Değerler youtubede arattığımız kelimenin videolarda ki başlıklarda geçen kelimeler, yani bir şarkı ismi girdiğimde o isimdeki tüm video başlıkları)
print
ile yapınca çıktı olarak alıyorum fakat, arayüzde bunu başaramadım
Çıktı:
Nora & Chris X Drenchill - Remedy (Official Video)
Nora & Chris, Drenchill - Remedy (Lyrics)
Alesso - REMEDY (Official Music Video)
Remedy
Ali Gatie - Remedy [Official Lyrics Video]
Agoria feat. NOEMIE - Remedy (Manoo Remix)
the remedy for a broken heart (why am I so in love)
The Black Crowes - Remedy
Alesso - REMEDY (Lyrics)
Rilès - REMEDY (Prod. Rilès)
Maroon 5 - Remedy ft. Stevie Nicks (Official Lyric Video)
Nora & Chris & Drenchill - Remedy
Seether - Remedy
Remedy - Machel Montano | Official Lyric Video | Soca 2015
Adele- Remedy (Lyrics)
Remedy - Adele (Lyrics)
Adele Remedy Lyrics
Nora & Chris X Drenchill - Remedy (Türkçe Çeviri)(Lyrics)
Agoria - Remedy (feat Noémie)
Remedy - Lexsil Ft Otile Brown (Official Music VIdeo) sms skiza 7301559 to 811
Jason Mraz - The Remedy (I Won't Worry) [Official Video]
Jah Vinci - Remedy {Remedy Riddim} Gaza - March 2010 - HCR
Nora & Chris, Drenchill - Remedy (Bass Boosted)
Remedy
Little Boots - Remedy (Video )
Remedy - Feeding the Stone (Official video)
창모 (CHANGMO) - REMEDY (Feat. 청하 (CHUNG HA)) MV
Zedd feat. Foxes - Clarity (Lyrics)
Dimension - Remedy (ft. TS Graye)
Remedy
Professor Green - Remedy ft. Ruth Anne
Surfaces - Remedy (Official Audio)
Carda - Remedy (Tunesquad Remix)
Puscifer "The Remedy" (Official Video)
The Remedy Jason Mraz Lyrics
Ali Gatie - Remedy (Lyrics / Lyric Video)
William Black - Remedy (Lyrics) ft. Annie Schindel
Victoria Kimani - Remedy (Official Video)
REMEDY, O PIOR JOGADOR DE FIFA 20 ULTIMATE TEAM!
Max Payne - 20 Year Anniversary
REMEDY, O PIOR JOGADOR DE FIFA 19 ULTIMATE TEAM!
Os MELHORES VÍDEOS DE SEMPRE do Remedy
Zedd - Clarity ft. Foxes (Official Music Video)
Grim YG - Remedy (Official Video)
Jason Mraz -The Remedy(I Won't Worry) (live)
XXXTENTACION - The remedy for a broken heart (Türkçe Çeviri)
Jamel - Remedy feat. Rops1 (Official Video)
ROCKET LEAGUE É VIDA!
Remedy
Yardımlarınızı, çözüm önerilerinizi bekliyorum
Teşekkür ederim.