Rehber Python Kütüphaneler #1

Bu konuyu okuyanlar

Emnn

Jet Sesi, Özgürlüğün Sesidir!
Katılım
3 Mayıs 2021
Mesajlar
2,203
Çözümler
8
Reaksiyon puanı
1,815
Puanları
113
Herkese Merhaba

Pythonda bazı kütüphaneler hakkında bilgi vereceğim umarım işinize yarar


1- PyQt5 (Arayüz kütüphanesi)

PyPI adresi : PyQt5

Python:
"""from PyQt5 import QtWidgets
import sys
uygulama=QtWidgets.QApplication(sys.argv)
pencere=QtWidgets.QWidget()
pencere.show()
uygulama.exec()"""

#Basit Bir Pencere Oluşumu 2
"""from PyQt5.QtWidgets import *
import sys
uygulama = QApplication(sys.argv)
pencere = QWidget()
pencere.show()
uygulama.exec()"""

#Basit Bir Pencere Oluşumu 3
"""from PyQt5.QtWidgets import *
import sys
class YeniPencere(QWidget):
    def __init__(self):
        QWidget.__init__(self)
uygulama = QApplication(sys.argv)
pencere = YeniPencere()
pencere.show()
uygulama.exec_()"""

#Basit Bir Pencere Oluşturma 4
"""from PyQt5.QtWidgets import *
import sys
class YeniPencere(QMainWindow):
    def __init__(self):
        super().__init__()
uygulama = QApplication(sys.argv)
pencere = YeniPencere()
pencere.show()
uygulama.exec_()"""

#Pencere Boyutlarını Ayarlamak
"""from PyQt5.QtWidgets import *
import sys
class Pencere(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(750,500)
uygulama = QApplication(sys.argv)
pencere = Pencere()
pencere.show()
uygulama.exec_()"""

#Pencerenin Nerede Oluşacağını Belirlemek Ve Pencereye Ad Vermek
"""from PyQt5.QtWidgets import *
import sys
class asıl_pencere(QWidget) :
    def __init__(self) :
        QWidget.__init__(self)
        self.resize(750,500)
        self.move(300,100)
        self.setWindowTitle("Pencere Denemeleri")
uygulama=QApplication(sys.argv)
pencere=asıl_pencere()
pencere.show()
uygulama.exec()"""     

#Pencere İçine Yazı Yazma
"""from PyQt5.QtWidgets import *
import sys
class asıl_pencere(QWidget) :
    def __init__(self) :
        QWidget.__init__(self)
        self.resize(750,500)
        self.move(300,100)
        yazı=QLabel("Programlamaya Hoşgeldiniz ",self)
uygulama=QApplication(sys.argv)       
pencere=asıl_pencere()
pencere.show()
uygulama.exec()"""

#Pencere İçine Tek Satırlık Yazı Alanı Açma
"""from PyQt5.QtWidgets import *
import sys
class asıl_pencere(QWidget) :
    def __init__(self) :
        QWidget.__init__(self)
        self.resize(750,500)
        self.move(300,100)
        yazı=QLineEdit(self)
uygulama=QApplication(sys.argv)
pencere=asıl_pencere()
pencere.show()
uygulama.exec()"""       

#Buton Ekleme Ve İşlev Atama
"""from PyQt5.QtWidgets import *
import sys
class asıl_pencere(QWidget) :
    def __init__(self) :
        QWidget.__init__(self)
        self.resize(750,500)
        self.setWindowTitle("Deneme 1")
        buton=QPushButton(self)
        buton.setText("Tıklayınız !")
        buton.clicked.connect(self.close)
uygulama=QApplication(sys.argv)
pencere=asıl_pencere()
pencere.show()       
uygulama.exec()"""

#Combobox Yapımı
"""from PyQt5.QtWidgets import *
import sys
class asıl_pencere(QWidget) :
    def __init__(self) :
        QWidget.__init__(self)
        self.resize(750,500)
        self.setWindowTitle("Deneme 1")
        self.combobox1=QComboBox(self)
        self.combobox1.addItem("Seçenek 1")
        self.combobox1.addItems(["Seçenek 2","Seçenek 3","Seçenek 4"])
uygulama=QApplication(sys.argv)
pencere=asıl_pencere()
pencere.show()
uygulama.exec()"""

2-Tkinter (Arayüz kütüphanesi)

Pythonda "Tkinter" yüklü olarak gelir harici olarak ek toollar kurulabilir

Python:
#Çalışma 1
"""import tkinter as tk
pencere=tk.Tk()
pencere.title("Programlama Oyunu")
pencere.geometry("600x500")
yazı=tk.Label(text="...Hoşgeldiniz...")
yazı.pack()
yazı2=tk.Button(text="Düğme 1")
yazı2.pack()
yazı3=tk.Button(text="Düğme 2")
yazı3.pack()
yazı4=tk.Button(text="Düğme 3")
yazı4.pack()
yazı5=tk.Button(text="Düğme 4")
yazı5.pack()
pencere.mainloop()"""


#Çalışma 2
"""def deneme () :
    ad=input("Adınızı Giriniz : ")
    import tkinter as tk
    pencere=tk.Tk()
    pencere.title("Deneme")
    pencere.geometry("300x200")
    yazı1=tk.Label(text=ad)
    yazı1.pack()
    pencere.mainloop()
deneme()"""


#Çalışma 3
"""def deneme () :
    import tkinter as tk
    pencere=tk.Tk()
    pencere.title("Mekan Robotu")
    pencere.geometry("300x200")
    yazı=tk.Label(text="Mekana Maalesef Giremezsiniz...",fg="black")
    yazı.pack()
    pencere.mainloop()
    
def deneme2 () :
    import tkinter as tk
    pencere=tk.Tk()
    pencere.title("Mekan Robotu")
    pencere.geometry("300x200")
    yazı=tk.Label(text="Mekana Girebilirsiniz ...",fg="red")
    yazı.pack()
    pencere.mainloop()
    
    
yaş=int(input("Yaşınıız Giriniz ?"))
if yaş>=18 :
    deneme2()
else :
    deneme()"""


#Çalışma 4
"""from tkinter import *
pencere=Tk()
pencere.geometry("500x400")
pencere.title(" DENEME ")
yazı=Label(text="Merhaba Adınızı Giriniz :")
giriş=Entry(pencere,fg="red")
düğme=Button(text="Giriş Yap",fg="white",bg="Black")
yazı.pack()
giriş.pack()
düğme.pack()
pencere.mainloop()"""


#Çalışma 5
"""from tkinter import *
pencere=Tk()
pencere.geometry("500x400")
pencere.title(" DENEME ")
yazı=Label(text="Merhaba Adınızı Giriniz :")
giriş=Entry(pencere,fg="red")
düğme=Button(text="Giriş Yap",fg="white",bg="Black",command=pencere.quit)
yazı2=Label(text="Şifrenizi Giriniz :")
giriş2=Entry(pencere,fg="red",show="*")
yazı.pack()
giriş.pack()
yazı2.pack()
giriş2.pack()
düğme.pack(side=BOTTOM)
pencere.mainloop()"""


#Çalışma 6
"""from tkinter import *
pencere=Tk()
pencere.title("DENEME 1")
pencere.geometry("500x400")
pencere.resizable(width=FALSE, height=FALSE)
isim=Label(text="GMAİL GİRİNİZ : ",font="Times 10 italic")
isim1=Entry()
şifre=Label(text="ŞİFRENİZİ GİRİNİZ : ",font="Times 10 italic")
şifre1=Entry(show="*")
düğme=Button(text="GİRİŞ YAP",fg="red",bg="Black",font="Times 10 italic")
isim.pack()
isim1.pack()
şifre.pack()
şifre1.pack()
düğme.pack(side=BOTTOM)
pencere.mainloop()"""


#Çalışma 7
"""from tkinter import *
pencere=Tk()
pencere.title("DENEME 1")
pencere.geometry("500x375")
def uyarı():
    var=messagebox.showinfo("Uyarı" , "Çıkış Yapmak Üzeresiniz ")
      
yazı=Label(text="ADINIZI GİRİNİZ :",font="times 10 roman",fg="black")
giriş=Entry()
yazı2=Label(text="ŞİFRENİZİ GİRİNİZ :",font="times 10 roman",fg="Black")
giriş2=Entry(show="*")
düğme1=Button(text="GİRİŞ YAP",font="times 10 roman",fg="Black",bg="gray",width="20",command=pencere.quit)
düğme2=Button(text="ÇIKIŞ YAP",font="times 10 roman",fg="Black",bg="gray",width="20",command=uyarı)
yazı.pack()
giriş.pack()
yazı2.pack()
giriş2.pack()
düğme2.pack(side=BOTTOM)
düğme1.pack(side=BOTTOM)
pencere.mainloop()"""


#Çalışma 8
"""from tkinter import *
pencere=Tk()
pencere.title("DENEME")
pencere.geometry("300x300")
pencere.resizable(width=FALSE,height=FALSE)
yazı=Label(text="Yaşınızı  Giriniz : ",font="times 15 italic")
giriş=Entry(font="times 15 italic")
def yaş () :
    yaş1=int(giriş.get())
    if yaş1 <= 18 :
        x = "Giremezsiniz"
    else :
        x = "Girebilirsiniz"
    yazı=Label(text=x,font="times 15 italic")
    yazı.pack()
        
düğme=Button(command=yaş,text="Enter",font="times 15 roman")   
 
yazı.pack()
giriş.pack()
düğme.pack(side=BOTTOM) 
pencere.mainloop()"""


#♦Çalışma 9
"""from tkinter import *
pencere=Tk()
pencere.title("Mekan Robotu")
pencere.geometry("400x300")
pencere.resizable(width=FALSE,height=FALSE)
yazı=Label(text="Yaşınızı  Giriniz : ",font="times 13 italic")
giriş=Entry(font="times 13 italic")
yazı2=Label(text="Ehliyetiniz Varmı (E/H) :",font="times 13 italic")
giriş2=Entry(font="Times 13 italic")
def bilgi () :
    yaş1=int(giriş.get())
    ehliyet=giriş2.get()
    if yaş1 >= 18 :
        if ehliyet=="E" or ehliyet=="e"  :
            x = "İki Durumda Onaylandığı İçin Girebilirsiniz"
        else :
            x = "Ehliyetiniz OLmadığı İçin Giremezsiniz"   
    else :
        x = "Yaşınız Kurtarmadığı İçin Giremezsiniz "
    yazı=Label(text=x,font="times 13 italic")
    yazı.pack()
        
düğme=Button(command=bilgi,text="Onayla",font="times 13 roman")   
 
yazı.pack()
giriş.pack()
yazı2.pack()
giriş2.pack()
düğme.pack(side=BOTTOM) 
pencere.mainloop()"""


#Çalışma 10
"""from tkinter import *
pencere=Tk()
pencere.title("Deneme ")
pencere.geometry("500x350")
pencere.resizable(width=FALSE,height=FALSE)
yazı=Label(text="Merhaba Adınızı Giriniz : ",font="verdana 13 italic")
giriş=Entry(font="verdana 13 italic")
yazı2=Label(text="Şifrenizi Giriniz : ",font="Verdana 13 italic")
giriş2=Entry(font="times 13 italic",show="*")
def bilgi () :
    ad=giriş.get()
    şifre=int(giriş2.get())
    if ad=="Emin" :
        if şifre==12345 :
            x = "Giriş Yapılıyor "
        else :
            x = "Şifre Yanlış"
    elif ad=="Emin2" :
        if şifre==1234 :
            x = "Giriş Yapılıyor"
        else :
            x = "Şifre Yanlış"
    else :
        x = "Kayıtlı Olmayan Bir Hesaptan Giriş Yapmaya Çalıştınız"       
    yazı=Label(text=x,font="verdana 13 italic")
    yazı.pack()
düğme=Button(command=bilgi,text="Onayla",font="verdana 13 italic")
düğme2=Button(text="Çıkış Yap",command=pencere.destroy,font="verdana 13 italic")
yazı.pack()
giriş.pack()
yazı2.pack()
giriş2.pack()
düğme2.pack(side=BOTTOM)
düğme.pack(side=BOTTOM)
pencere.mainloop()"""


#Çalışma 11
"""from tkinter import *
pencere=Tk()
pencere.title("Deneme ")
pencere.geometry("750x500")
pencere.resizable(width=FALSE,height=FALSE)
deneme=Frame(bg="gray")
deneme.place(relx=0.1,rely=0.1,relwidth=0.75,relheight=0.1)
deneme1=Frame(bg="gray")
deneme1.place(relx=0.1,rely=0.21,relwidth=0.30,relheight=0.5)
deneme2=Frame(bg="gray")
deneme2.place(relx=0.42,rely=0.21,relwidth=0.43,relheight=0.5)
pencere.mainloop()"""


#Çalışma 12
"""from tkinter import *
pencere=Tk()
pencere.title("Deneme 1")
pencere.geometry("750x500")
pencere.resizable(width=FALSE,height=FALSE)
üst_frame=Frame(bg="#add8e6")
üst_frame.place(relx=0.1,rely=0.1,relwidth=0.75,relheight=0.12)
sol_alt_frame=Frame(bg="#add8e6")
sol_alt_frame.place(relx=0.1,rely=0.23,relwidth=0.40,relheight=0.50)
sağ_alt_frame=Frame(bg="#add8e6")
sağ_alt_frame.place(relx=.51,rely=0.23,relwidth=0.34,relheight=0.50)
#Üst Frame
üst_yazı=Label(üst_frame,text="Hesap Makinesi ",font="Verdana 20 italic",bg="#add8e6")
üst_yazı.pack(pady=0.10,padx=0.10)
#Sol Alt Frame
bir_sayı=Label(sol_alt_frame,text="Birinci Sayıyı Giriniz :",bg="#add8e6",font="Verdana 12 italic")
bir_sayı.pack(pady=0.1,padx=0.1,anchor=N)
bir_giriş=Entry(sol_alt_frame,bg="#add8e6",font="Verdana 12 italic")
bir_giriş.pack(pady=0.1,padx=0.1,anchor=N)
işlem=Label(sol_alt_frame,text="İşlemi Seçiniz :",bg="#add8e6",font="Verdana 12 italic")
işlem.pack(padx=0.1,pady=0.1,anchor=N)
asıl_işlem=Entry(sol_alt_frame,bg="#add8e6",font="Verdana 12 italic")
asıl_işlem.pack(padx=0.1,pady=0.1,anchor=N)
iki_sayı=Label(sol_alt_frame,text="İkinci Sayıyı Giriniz : ",font="Verdana 12 italic",bg="#add8e6")
iki_sayı.pack(padx=0.1,pady=0.1,anchor=N)
iki_giriş=Entry(sol_alt_frame,bg="#add8e6",font="Verdana 12 italic")
iki_giriş.pack(padx=0.1,pady=0.1,anchor=N)
def kod () :
    
    i=asıl_işlem.get()
    bir=int(bir_giriş.get())
    iki=int(iki_giriş.get())
    if i=="+" :
        x = bir+iki
    elif i=="-" :
        x = bir-iki
    elif i=="*" :
        x = bir*iki
    elif i=="/" :
        x = bir/iki
    sonuç=Label(sağ_alt_frame,text=x,bg="#add8e6",font="Verdana 12 italic")
    sonuç.pack(padx=0.5,pady=0.5,anchor=N)
        
hesap=Button(sol_alt_frame,text="İşlemi Yap",bg="#add8e6",font="Verdana 12 italic",command=kod)
hesap.pack(side=BOTTOM)
#Sağ Alt Frame
sonuç_yazı=Label(sağ_alt_frame,text="İşlemlerin Sonucu : ",fg="black",bg="#add8e6",font="Verdana 15 italic")
sonuç_yazı.pack()
çıkış=Button(sağ_alt_frame,text="Hesap Makinesinden Çık",bg="#add8e6",font="Verdana 12 italic",command=pencere.destroy)
çıkış.pack(side=BOTTOM)
pencere.mainloop()"""

3-PyGame (Oyun kütüphanesi)

PyPI adresi : PyGame


Python:
#Pencere oluşturma
"""import pygame
import sys
pygame.init()
pencere = pygame.display.set_mode((200,200), pygame.SWSURFACE)
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.flip()"""

#Pencere Başlığı
"""import pygame
import sys
pygame.init()
pencere = pygame.display.set_mode((200,200), pygame.SWSURFACE)
pygame.display.set_caption("Oyunumuzun Adı")
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.flip()"""   

#Pencere İkonu Ayarlama
"""import pygame
import sys
pygame.init()
pencere = pygame.display.set_mode((200,200), pygame.SWSURFACE)
pygame.display.set_icon(pygame.image.load("PyGame//resim.png"))
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
    pygame.display.flip()"""

Basit Bir Örnek : pin Pon Oyunu

4-playsound (Ses kütüphanesi)

PyPI adresi : PlaySound


Python:
# Kütüphanemizi ekliyoruz
from playsound import playsound
#Dosya yolunu verip şarkıyı çaldırıyoruz
playsound('/şarkı/şarkı1.mp3')

5-Colorama (Terminal renklendirme kütüphanesi)

PyPI adresi : Colorama

Python:
# Kütüphanemizi ekliyoruz
from colorama import *
# Kullanım için init() fonksiyonunu çağırıyoruz
init()
# Yazı rengini kırmızı yaptık
print(Fore.RED)
# Yazı rengini sarı yaptık
print(Fore.YELLOW)
# Yazı rengini açıkmavi yaptık
print(Fore.CYAN)

# Yazımızın arka plan rengini yeşil yaptık
print(Back.GREEN)
# Yazımızın arka plan rengini mavi yaptık
print(Back.BLUE)

# Yaptığımız tüm değişiklikleride sıfırlamak istersek
print(Style.RESET_ALL)
 
Üst