Language:

Gönderen Konu: Python 3.5 ve PyQt5 Örnek Uygulama & Buton Baglamasi [ÖRNEK KOD]  (Okunma sayısı 1264 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

pisi_pisi

  • Ziyaretçi
asagidaki kod blogunda, Bakkaliye uygulamasinin ilk taslak tasarimini ve bu tasarimdaki bir objenin nasil baglandigini görebilirsiniz.


Kod: [Seç]
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'bakkaliye_gui.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 0, 781, 40))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.lineEdit = QtWidgets.QLineEdit(self.horizontalLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setObjectName("lineEdit")
        self.horizontalLayout.addWidget(self.lineEdit)
        self.pushButton = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout.addWidget(self.pushButton)
        self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(10, 40, 781, 121))
        self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.pushButton_2 = QtWidgets.QPushButton(self.horizontalLayoutWidget_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)label
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout_2.addWidget(self.pushButton_2)
        self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(10, 170, 171, 381))
        self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.listWidget = QtWidgets.QListWidget(self.horizontalLayoutWidget_3)
        self.listWidget.setObjectName("listWidget")
        self.horizontalLayout_3.addWidget(self.listWidget)
        self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(200, 170, 591, 381))
        self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4")
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.listWidget_2 = QtWidgets.QListWidget(self.horizontalLayoutWidget_4)
        self.listWidget_2.setObjectName("listWidget_2")
        self.horizontalLayout_4.addWidget(self.listWidget_2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 27))
        self.menubar.setObjectName("menubar")
        self.menuAyarlar = QtWidgets.QMenu(self.menubar)
        self.menuAyarlar.setObjectName("menuAyarlar")
        self.menuHakkinda = QtWidgets.QMenu(self.menubar)
        self.menuHakkinda.setObjectName("menuHakkinda")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionIndirme_Ayarlari = QtWidgets.QAction(MainWindow)
        self.actionIndirme_Ayarlari.setObjectName("actionIndirme_Ayarlari")
        self.actionIndirme_Ayarlari_2 = QtWidgets.QAction(MainWindow)
        self.actionIndirme_Ayarlari_2.setObjectName("actionIndirme_Ayarlari_2")
        self.actionDepo_Ayarlari = QtWidgets.QAction(MainWindow)
        self.actionDepo_Ayarlari.setObjectName("actionDepo_Ayarlari")
        self.actionBakkaliye = QtWidgets.QAction(MainWindow)
        self.actionBakkaliye.setObjectName("actionBakkaliye")
        self.actionG_ncelle = QtWidgets.QAction(MainWindow)
        self.actionG_ncelle.setObjectName("actionG_ncelle")
        self.menuAyarlar.addAction(self.actionIndirme_Ayarlari)
        self.menuAyarlar.addAction(self.actionIndirme_Ayarlari_2)
        self.menuAyarlar.addAction(self.actionDepo_Ayarlari)
        self.menuHakkinda.addAction(self.actionBakkaliye)
        self.menuHakkinda.addAction(self.actionG_ncelle)
        self.menubar.addAction(self.menuAyarlar.menuAction())
        self.menubar.addAction(self.menuHakkinda.menuAction())
        self.pushButton.clicked.connect(self.handleButton)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.lineEdit.setPlaceholderText(_translate("MainWindow", "Aranacak Kelime"))
        self.pushButton.setText(_translate("MainWindow", "PushButton"))
        self.pushButton_2.setText(_translate("MainWindow", "PushButton"))
        self.menuAyarlar.setTitle(_translate("MainWindow", "Ayar&lar"))
        self.menuHakkinda.setTitle(_translate("MainWindow", "&Hakkinda"))
        self.actionIndirme_Ayarlari.setText(_translate("MainWindow", "Listeleme Ayarlari"))
        self.actionIndirme_Ayarlari_2.setText(_translate("MainWindow", "Indirme Ayarlari"))
        self.actionDepo_Ayarlari.setText(_translate("MainWindow", "Depo Ayarlari"))
        self.actionBakkaliye.setText(_translate("MainWindow", "Bakkaliye"))
        self.actionG_ncelle.setText(_translate("MainWindow", "Güncelle"))
        label
    def handleButton(self):
        self.pushButton_2.setText('Button Clicked!')

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())


cengiz

  • Kıdemli

  • Çevrimdışı
  • ****

  • 271
  • Cinsiyet
    Bay

    Bay
  • Kişisel İleti
    Tek gerçek devrimdir.
    • Profili Görüntüle
Niye devam etmediniz iki yerde 43 v3 11 satır label kelimesi fazla idi sildim çalıştı arayüz tasarım güzel görünüyor.
alick

 

Yukarı Çık & Back to Up