PyQt5 İle Yeni pencere açmak

from gerekli import *

def app():

    benim_uyg = QApplication(sys.argv)

    w = QWidget()

    v_box = QVBoxLayout

    #=======================================

    w.setWindowTitle("Enes Kaplan")

    w.setWindowIcon(QIcon('resources\icon.png'))  

    #               Arka Planı gri yapma --------------------------------------

    w.setStyleSheet("background-color: rgb(11, 11, 11);")

    #En fazla Genişletilebilen Alan

    w.setMaximumWidth(720)

    w.setMaximumHeight(640)

    #En az Genişletilebilen Alan

    w.setMinimumWidth(720)

    w.setMinimumHeight(640)

    #=========================================

    w.setWindowFlags(QtCore.Qt.FramelessWindowHint) # başlık çubuğunu yok eder.

    #w.setWindowFlags(QtCore.Qt.FramelessWindowHint) # Hareket ettirmeyi etkinleştirir

    #w.setWindowFlags(QtCore.Qt.CustomizeWindowHint)

    Qte = QtCore.Qt

    #==============================================================================

#==============üst çubuk================

    cubuk = QtWidgets.QLabel(w)

    cubuk.setGeometry(0,0,1050,50)

    cubuk.setStyleSheet("""

    background: #262626;

    

    """)

    

    cubuk.move(0,0)

    #------------------------------------------  

    

#==============Giriş Yap Butonu================

    buton1 = QtWidgets.QPushButton(w)

    buton1.setText("Giriş Yap")

    buton1.setStyleSheet(

        """

        background-color: #191a1c;

        border-style: outset;

        border-width: 5px;

        border-radius: 15px;

        border-color: #4b5357;

        font:  22px;

        min-width: 10em;

        padding: 6px;

        color: #8db8d7;

        """,

        )

    

    hiz = 0.5

    buton1.move(210,410)

    def giris():

        print("Giriş Butonu")

        ac()

    def ac(QMainWindow):

        widget = QWidget() #Penceremiz bir widget olduğundan QWidget sınıfını örnekledik. 

        yeni_pencere = ekle() #Yeni açılacak olan penceremizi örnekledik. Bu sayede kullanıma hazır hale geldi. 

        yeni_pencere.show() #Oluşturduğumuz pencereyi ekrana gösterdik.

                        

    buton1.clicked.connect(ac)

    buton1.setToolTip('<b>Giriş</b> Yapmak İçin Tıkla!')

    #QToolTip.setFont(QFont('SansSerif', 10))

#==============Kayıt Ol Butonu================

    Button = QtWidgets.QPushButton(w)

    Button.setText("Kayıt Ol")

    Button.setStyleSheet(

        """

        background-color: #191a1c;

        border-style: outset;

        border-width: 5px;

        border-radius: 15px;

        border-color: #4b5357;

        font:  22px;

        min-width: 10em;

        padding: 6px;

        color: #8db8d7;

        """,

        )  

    hiz = 0.5

    Button.move(210,500)

    def kayit():

        print("Kayıt Ol Butonu")

    butonn = QHBoxLayout()

    butonn.addWidget(Button)

    Button.clicked.connect(kayit)

    Button.setToolTip('<b>Kayıt</b> Olmak İçin Tıkla!')

#==============Çıkış Butonu================

    buton1 = QtWidgets.QPushButton(w)

    buton1.setText("X")

    butonhiz = QHBoxLayout()

    buton1.setStyleSheet(

        """

        background-color: #191a1c;

        border-style: outset;

        border-width: 5px;

        border-radius: 15px;

        border-color: #4b5357;

        font:  22px;

        min-width: 1em;

        padding: 6px;

        color: #8db8d7;

        """,

        )

    hiz = 0.5

    buton1.move(670,0)

    def cikis():

        print("Çıkış Butonu")

        quit()

    butonhiz.addWidget(buton1)

    butonhiz.setAlignment(Qte.AlignRight | Qte.AlignTop)

    buton1.clicked.connect(cikis)

    buton1.setToolTip('Çıkış')

        

#==============Küçült Butonu================

    buton1 = QtWidgets.QPushButton(w)

    buton1.setText("━")

    buton1.setStyleSheet(

        """

        background-color: #191a1c;

        border-style: outset;

        border-width: 5px;

        border-radius: 15px;

        border-color: #4b5357;

        font:  22px;

        min-width: 1em;

        padding: 6px;

        color: #8db8d7;

        """,

        )

    hiz = 0.5

    buton1.setToolTip('Pencereyi Küçült')

    buton1.move(620,0)

    def kucult(self):

        print("Küçültme Butonu")

        

        w.showMinimized()

    buton1.clicked.connect(kucult)  

#==============Logo================

    logo = QtWidgets.QLabel(w)

    logo2 = QtWidgets.QLabel(w)

    logo.setStyleSheet("color: white;background-color: rgba(0,0,0,0%);")

    logo2.setStyleSheet("""

    background-color: rgba(0,0,0,0%);

    """)

    logo.setAlignment(Qte.AlignHCenter)

    logo2.setAlignment(Qte.AlignHCenter)

    logo.move(200,100)

    logo2.move(200,100)

    pix1 = QtGui.QPixmap("resources\Background_2.png")

    pix2 = QtGui.QPixmap("resources\human.png")

    logo.setPixmap(pix1.scaled(300,300, Qte.KeepAspectRatio))

    logo2.setPixmap(pix2.scaled(300,300, Qte.KeepAspectRatio))

#==============Başlık================

    logo = QtWidgets.QLabel(w)

    baslik = "|Enes Kaplan Giriş Sistemi"

    logo.setText(baslik)

    logo.setStyleSheet("""

    color: #bac4ff;

    font: 22px;

    background-color: rgba(0,0,0,0%);

    """)

    logo.move(50,12)

 

#==============İcon================

    icon = QtWidgets.QLabel(w)

    icon.setStyleSheet("""

    background-color: rgba(0,0,0,0%);

    border-style: outset;

    border-width: 3px;

    border-radius: 15px;

    border-color: #4b5357;

    font:  22px;

    min-width: 1em;

    padding: 6px;

    color: #8db8d7;

    """)

    pixmap = QtGui.QPixmap("resources\icon.png")

    icon.setPixmap(pixmap.scaled(32,32))

    icon.setToolTip(baslik)

    icon.move(0,0)

#------------------------------------------

    w.show()

    sys.exit(benim_uyg.exec_())

        

app()
>     > Böyle bir arayüz yaptım ancak kayıt ol butonuna basınca nasıl yeni pencere açarım?
>     > 
>     > > Kayıt ol butonunun adı buton1
1 Beğeni

Yeni bir pencere mi açmak istiyorsun yoksa var olan pencerede farklı bir ekrana mı geçmek istiyorsun? Yani pencere içinde mi pencere açılsın yoksa harici bir pencere mi?

Bu arada ilk gönderin için tebrik ederim hoş geldin

1 Beğeni

Teşekkürler, şöyle projenin adı : pencere2 , pencere2 deki kayıt ol butonuna basınca pencere3 teki pencere açılsın ve pencere2 kapansın.

pencere 2 yi kapatmak için pencere 2 yi açan fonksiyonun daima açık kalmasını sağladığın değişkeni dış dünyaya döndürerek kayıt ol butonuna atayacağın fonksiyon yapısında önce pencere 2 nin kapanacağı kodu yazıp ardından sıfırdan bir pencere oluşturuyormuş gibi kayıt ol buton fonksiyonu altına yeni pencere oluşturma kodlarınızı yazarak bu işlemi denediniz mi?

Kısaca, buton3(): fonksiyonu içerisine önce pencere2 yi kapatan sonra pencere3 yani kayıt ekranı penceresini açan kodları yazmalısınız.

daha önceden denemiştim kapanınca ondan sonraki komutlar çalışmıyor yani, pencere açılmayacaktır. ilk pencereyi açıp sonra önceki pencereyi kapatma kodunu yapıncada zaten pencere çalışıyor hatasını veriyor. daha önceden denemiştim