• בלוג
  • פיתוח ממשק גרפי ב PyQt - תקציר קוד שהוצג במפגש

פיתוח ממשק גרפי ב PyQt - תקציר קוד שהוצג במפגש

22/06/2017

פוסט זה כולל טיפ קצר לעבודה יעילה עם Python. אם אתם רוצים ללמוד פייתון יותר לעומק אני ממליץ על קורס Python כאן באתר.
הקורס כולל עשרות שיעורי וידאו והמון תרגול מעשי וילמד אתכם Python בצורה מקצועית מההתחלה ועד הנושאים המתקדמים.

קוראים קבועים של הבלוג זוכרים שסיפרתי בתחילת השבוע על מפגש פיתוח וירטואלי שאני רוצה לקיים בנושא פיתוח ממשק משתמש גרפי ליישומי Python. המפגש אכן התקיים כמתוכנן ביום רביעי (היה כיף. אמשיך לעדכן על מפגשים נוספים). זה הקוד שכתבנו.

1. ממשק גרפי למשחק סודוקו

המשימה שלנו היתה לבנות ממשק משתמש גרפי למשחק סודוקו עם כפתור לפתרון המשחק. לצורך כך השתמשנו בספריות: PyQt ו dlxsudoku.

בעבודה עם PyQt ראינו שאפשר להשתמש ב Designer כדי לכתוב ממשקי משתמש מורכבים, אבל לא התעמקנו באיך ה Designer עובד ובמקום שיתפתי עם הקבוצה ממשק שכבר כתבתי ב Designer והמרתי לפייתון. הקוד נראה כך אבל צריך לזכור שהוא נוצר אוטומטית דרך ה Designer בצורה גרפית:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'grid.ui'
#
# Created by: PyQt5 UI code generator 5.8.2
#
# 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(705, 737)
        MainWindow.setStyleSheet("QLineEdit {\n"
"    font-size: 22px;\n"
"    background: transparent;\n"
"    selection-background-color: transparent;\n"
"    border: 1px solid #777;\n"
"}\n"
"\n"
"QLineEdit:focus {\n"
"    text-align: center;\n"
"    font-size: 22px;\n"
"    background: transparent;\n"
"    selection-background-color: transparent;\n"
"    border: 0;\n"
"}")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout.addWidget(self.pushButton)
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout.addWidget(self.pushButton_2)
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName("pushButton_3")
        self.horizontalLayout.addWidget(self.pushButton_3)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setObjectName("lineEdit")
        self.gridLayout.addWidget(self.lineEdit, 0, 0, 1, 1)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.gridLayout.addWidget(self.lineEdit_2, 0, 1, 1, 1)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.gridLayout.addWidget(self.lineEdit_3, 0, 2, 1, 1)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_5.sizePolicy().hasHeightForWidth())
        self.lineEdit_5.setSizePolicy(sizePolicy)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.gridLayout.addWidget(self.lineEdit_5, 0, 3, 1, 1)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_6.sizePolicy().hasHeightForWidth())
        self.lineEdit_6.setSizePolicy(sizePolicy)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.gridLayout.addWidget(self.lineEdit_6, 0, 4, 1, 1)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
        self.lineEdit_4.setSizePolicy(sizePolicy)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.gridLayout.addWidget(self.lineEdit_4, 0, 5, 1, 1)
        self.lineEdit_8 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_8.sizePolicy().hasHeightForWidth())
        self.lineEdit_8.setSizePolicy(sizePolicy)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.gridLayout.addWidget(self.lineEdit_8, 0, 6, 1, 1)
        self.lineEdit_9 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_9.sizePolicy().hasHeightForWidth())
        self.lineEdit_9.setSizePolicy(sizePolicy)
        self.lineEdit_9.setObjectName("lineEdit_9")
        self.gridLayout.addWidget(self.lineEdit_9, 0, 7, 1, 1)
        self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_7.sizePolicy().hasHeightForWidth())
        self.lineEdit_7.setSizePolicy(sizePolicy)
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.gridLayout.addWidget(self.lineEdit_7, 0, 8, 1, 1)
        self.lineEdit_13 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_13.sizePolicy().hasHeightForWidth())
        self.lineEdit_13.setSizePolicy(sizePolicy)
        self.lineEdit_13.setObjectName("lineEdit_13")
        self.gridLayout.addWidget(self.lineEdit_13, 1, 0, 1, 1)
        self.lineEdit_14 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_14.sizePolicy().hasHeightForWidth())
        self.lineEdit_14.setSizePolicy(sizePolicy)
        self.lineEdit_14.setText("")
        self.lineEdit_14.setObjectName("lineEdit_14")
        self.gridLayout.addWidget(self.lineEdit_14, 1, 1, 1, 1)
        self.lineEdit_11 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_11.sizePolicy().hasHeightForWidth())
        self.lineEdit_11.setSizePolicy(sizePolicy)
        self.lineEdit_11.setText("")
        self.lineEdit_11.setObjectName("lineEdit_11")
        self.gridLayout.addWidget(self.lineEdit_11, 1, 2, 1, 1)
        self.lineEdit_15 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_15.sizePolicy().hasHeightForWidth())
        self.lineEdit_15.setSizePolicy(sizePolicy)
        self.lineEdit_15.setText("")
        self.lineEdit_15.setObjectName("lineEdit_15")
        self.gridLayout.addWidget(self.lineEdit_15, 1, 3, 1, 1)
        self.lineEdit_18 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_18.sizePolicy().hasHeightForWidth())
        self.lineEdit_18.setSizePolicy(sizePolicy)
        self.lineEdit_18.setObjectName("lineEdit_18")
        self.gridLayout.addWidget(self.lineEdit_18, 1, 4, 1, 1)
        self.lineEdit_17 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_17.sizePolicy().hasHeightForWidth())
        self.lineEdit_17.setSizePolicy(sizePolicy)
        self.lineEdit_17.setObjectName("lineEdit_17")
        self.gridLayout.addWidget(self.lineEdit_17, 1, 5, 1, 1)
        self.lineEdit_12 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_12.sizePolicy().hasHeightForWidth())
        self.lineEdit_12.setSizePolicy(sizePolicy)
        self.lineEdit_12.setObjectName("lineEdit_12")
        self.gridLayout.addWidget(self.lineEdit_12, 1, 6, 1, 1)
        self.lineEdit_16 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_16.sizePolicy().hasHeightForWidth())
        self.lineEdit_16.setSizePolicy(sizePolicy)
        self.lineEdit_16.setObjectName("lineEdit_16")
        self.gridLayout.addWidget(self.lineEdit_16, 1, 7, 1, 1)
        self.lineEdit_10 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_10.sizePolicy().hasHeightForWidth())
        self.lineEdit_10.setSizePolicy(sizePolicy)
        self.lineEdit_10.setObjectName("lineEdit_10")
        self.gridLayout.addWidget(self.lineEdit_10, 1, 8, 1, 1)
        self.lineEdit_22 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_22.sizePolicy().hasHeightForWidth())
        self.lineEdit_22.setSizePolicy(sizePolicy)
        self.lineEdit_22.setObjectName("lineEdit_22")
        self.gridLayout.addWidget(self.lineEdit_22, 2, 0, 1, 1)
        self.lineEdit_23 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_23.sizePolicy().hasHeightForWidth())
        self.lineEdit_23.setSizePolicy(sizePolicy)
        self.lineEdit_23.setText("")
        self.lineEdit_23.setObjectName("lineEdit_23")
        self.gridLayout.addWidget(self.lineEdit_23, 2, 1, 1, 1)
        self.lineEdit_20 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_20.sizePolicy().hasHeightForWidth())
        self.lineEdit_20.setSizePolicy(sizePolicy)
        self.lineEdit_20.setObjectName("lineEdit_20")
        self.gridLayout.addWidget(self.lineEdit_20, 2, 2, 1, 1)
        self.lineEdit_24 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_24.sizePolicy().hasHeightForWidth())
        self.lineEdit_24.setSizePolicy(sizePolicy)
        self.lineEdit_24.setObjectName("lineEdit_24")
        self.gridLayout.addWidget(self.lineEdit_24, 2, 3, 1, 1)
        self.lineEdit_27 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_27.sizePolicy().hasHeightForWidth())
        self.lineEdit_27.setSizePolicy(sizePolicy)
        self.lineEdit_27.setObjectName("lineEdit_27")
        self.gridLayout.addWidget(self.lineEdit_27, 2, 4, 1, 1)
        self.lineEdit_26 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_26.sizePolicy().hasHeightForWidth())
        self.lineEdit_26.setSizePolicy(sizePolicy)
        self.lineEdit_26.setObjectName("lineEdit_26")
        self.gridLayout.addWidget(self.lineEdit_26, 2, 5, 1, 1)
        self.lineEdit_21 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_21.sizePolicy().hasHeightForWidth())
        self.lineEdit_21.setSizePolicy(sizePolicy)
        self.lineEdit_21.setObjectName("lineEdit_21")
        self.gridLayout.addWidget(self.lineEdit_21, 2, 6, 1, 1)
        self.lineEdit_25 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_25.sizePolicy().hasHeightForWidth())
        self.lineEdit_25.setSizePolicy(sizePolicy)
        self.lineEdit_25.setObjectName("lineEdit_25")
        self.gridLayout.addWidget(self.lineEdit_25, 2, 7, 1, 1)
        self.lineEdit_19 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_19.sizePolicy().hasHeightForWidth())
        self.lineEdit_19.setSizePolicy(sizePolicy)
        self.lineEdit_19.setObjectName("lineEdit_19")
        self.gridLayout.addWidget(self.lineEdit_19, 2, 8, 1, 1)
        self.lineEdit_35 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_35.sizePolicy().hasHeightForWidth())
        self.lineEdit_35.setSizePolicy(sizePolicy)
        self.lineEdit_35.setObjectName("lineEdit_35")
        self.gridLayout.addWidget(self.lineEdit_35, 3, 0, 1, 1)
        self.lineEdit_47 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_47.sizePolicy().hasHeightForWidth())
        self.lineEdit_47.setSizePolicy(sizePolicy)
        self.lineEdit_47.setObjectName("lineEdit_47")
        self.gridLayout.addWidget(self.lineEdit_47, 3, 1, 1, 1)
        self.lineEdit_31 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_31.sizePolicy().hasHeightForWidth())
        self.lineEdit_31.setSizePolicy(sizePolicy)
        self.lineEdit_31.setObjectName("lineEdit_31")
        self.gridLayout.addWidget(self.lineEdit_31, 3, 2, 1, 1)
        self.lineEdit_45 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_45.sizePolicy().hasHeightForWidth())
        self.lineEdit_45.setSizePolicy(sizePolicy)
        self.lineEdit_45.setObjectName("lineEdit_45")
        self.gridLayout.addWidget(self.lineEdit_45, 3, 3, 1, 1)
        self.lineEdit_36 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_36.sizePolicy().hasHeightForWidth())
        self.lineEdit_36.setSizePolicy(sizePolicy)
        self.lineEdit_36.setObjectName("lineEdit_36")
        self.gridLayout.addWidget(self.lineEdit_36, 3, 4, 1, 1)
        self.lineEdit_48 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_48.sizePolicy().hasHeightForWidth())
        self.lineEdit_48.setSizePolicy(sizePolicy)
        self.lineEdit_48.setObjectName("lineEdit_48")
        self.gridLayout.addWidget(self.lineEdit_48, 3, 5, 1, 1)
        self.lineEdit_51 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_51.sizePolicy().hasHeightForWidth())
        self.lineEdit_51.setSizePolicy(sizePolicy)
        self.lineEdit_51.setObjectName("lineEdit_51")
        self.gridLayout.addWidget(self.lineEdit_51, 3, 6, 1, 1)
        self.lineEdit_38 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_38.sizePolicy().hasHeightForWidth())
        self.lineEdit_38.setSizePolicy(sizePolicy)
        self.lineEdit_38.setObjectName("lineEdit_38")
        self.gridLayout.addWidget(self.lineEdit_38, 3, 7, 1, 1)
        self.lineEdit_52 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_52.sizePolicy().hasHeightForWidth())
        self.lineEdit_52.setSizePolicy(sizePolicy)
        self.lineEdit_52.setObjectName("lineEdit_52")
        self.gridLayout.addWidget(self.lineEdit_52, 3, 8, 1, 1)
        self.lineEdit_43 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_43.sizePolicy().hasHeightForWidth())
        self.lineEdit_43.setSizePolicy(sizePolicy)
        self.lineEdit_43.setObjectName("lineEdit_43")
        self.gridLayout.addWidget(self.lineEdit_43, 4, 0, 1, 1)
        self.lineEdit_37 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_37.sizePolicy().hasHeightForWidth())
        self.lineEdit_37.setSizePolicy(sizePolicy)
        self.lineEdit_37.setObjectName("lineEdit_37")
        self.gridLayout.addWidget(self.lineEdit_37, 4, 1, 1, 1)
        self.lineEdit_40 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_40.sizePolicy().hasHeightForWidth())
        self.lineEdit_40.setSizePolicy(sizePolicy)
        self.lineEdit_40.setObjectName("lineEdit_40")
        self.gridLayout.addWidget(self.lineEdit_40, 4, 2, 1, 1)
        self.lineEdit_28 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_28.sizePolicy().hasHeightForWidth())
        self.lineEdit_28.setSizePolicy(sizePolicy)
        self.lineEdit_28.setObjectName("lineEdit_28")
        self.gridLayout.addWidget(self.lineEdit_28, 4, 3, 1, 1)
        self.lineEdit_39 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_39.sizePolicy().hasHeightForWidth())
        self.lineEdit_39.setSizePolicy(sizePolicy)
        self.lineEdit_39.setObjectName("lineEdit_39")
        self.gridLayout.addWidget(self.lineEdit_39, 4, 4, 1, 1)
        self.lineEdit_49 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_49.sizePolicy().hasHeightForWidth())
        self.lineEdit_49.setSizePolicy(sizePolicy)
        self.lineEdit_49.setObjectName("lineEdit_49")
        self.gridLayout.addWidget(self.lineEdit_49, 4, 5, 1, 1)
        self.lineEdit_53 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_53.sizePolicy().hasHeightForWidth())
        self.lineEdit_53.setSizePolicy(sizePolicy)
        self.lineEdit_53.setObjectName("lineEdit_53")
        self.gridLayout.addWidget(self.lineEdit_53, 4, 6, 1, 1)
        self.lineEdit_42 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_42.sizePolicy().hasHeightForWidth())
        self.lineEdit_42.setSizePolicy(sizePolicy)
        self.lineEdit_42.setObjectName("lineEdit_42")
        self.gridLayout.addWidget(self.lineEdit_42, 4, 7, 1, 1)
        self.lineEdit_32 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_32.sizePolicy().hasHeightForWidth())
        self.lineEdit_32.setSizePolicy(sizePolicy)
        self.lineEdit_32.setObjectName("lineEdit_32")
        self.gridLayout.addWidget(self.lineEdit_32, 4, 8, 1, 1)
        self.lineEdit_33 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_33.sizePolicy().hasHeightForWidth())
        self.lineEdit_33.setSizePolicy(sizePolicy)
        self.lineEdit_33.setObjectName("lineEdit_33")
        self.gridLayout.addWidget(self.lineEdit_33, 5, 0, 1, 1)
        self.lineEdit_50 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_50.sizePolicy().hasHeightForWidth())
        self.lineEdit_50.setSizePolicy(sizePolicy)
        self.lineEdit_50.setObjectName("lineEdit_50")
        self.gridLayout.addWidget(self.lineEdit_50, 5, 1, 1, 1)
        self.lineEdit_44 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_44.sizePolicy().hasHeightForWidth())
        self.lineEdit_44.setSizePolicy(sizePolicy)
        self.lineEdit_44.setObjectName("lineEdit_44")
        self.gridLayout.addWidget(self.lineEdit_44, 5, 2, 1, 1)
        self.lineEdit_29 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_29.sizePolicy().hasHeightForWidth())
        self.lineEdit_29.setSizePolicy(sizePolicy)
        self.lineEdit_29.setObjectName("lineEdit_29")
        self.gridLayout.addWidget(self.lineEdit_29, 5, 3, 1, 1)
        self.lineEdit_54 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_54.sizePolicy().hasHeightForWidth())
        self.lineEdit_54.setSizePolicy(sizePolicy)
        self.lineEdit_54.setObjectName("lineEdit_54")
        self.gridLayout.addWidget(self.lineEdit_54, 5, 4, 1, 1)
        self.lineEdit_30 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_30.sizePolicy().hasHeightForWidth())
        self.lineEdit_30.setSizePolicy(sizePolicy)
        self.lineEdit_30.setObjectName("lineEdit_30")
        self.gridLayout.addWidget(self.lineEdit_30, 5, 5, 1, 1)
        self.lineEdit_34 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_34.sizePolicy().hasHeightForWidth())
        self.lineEdit_34.setSizePolicy(sizePolicy)
        self.lineEdit_34.setObjectName("lineEdit_34")
        self.gridLayout.addWidget(self.lineEdit_34, 5, 6, 1, 1)
        self.lineEdit_41 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_41.sizePolicy().hasHeightForWidth())
        self.lineEdit_41.setSizePolicy(sizePolicy)
        self.lineEdit_41.setObjectName("lineEdit_41")
        self.gridLayout.addWidget(self.lineEdit_41, 5, 7, 1, 1)
        self.lineEdit_46 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_46.sizePolicy().hasHeightForWidth())
        self.lineEdit_46.setSizePolicy(sizePolicy)
        self.lineEdit_46.setObjectName("lineEdit_46")
        self.gridLayout.addWidget(self.lineEdit_46, 5, 8, 1, 1)
        self.lineEdit_62 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_62.sizePolicy().hasHeightForWidth())
        self.lineEdit_62.setSizePolicy(sizePolicy)
        self.lineEdit_62.setObjectName("lineEdit_62")
        self.gridLayout.addWidget(self.lineEdit_62, 6, 0, 1, 1)
        self.lineEdit_74 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_74.sizePolicy().hasHeightForWidth())
        self.lineEdit_74.setSizePolicy(sizePolicy)
        self.lineEdit_74.setObjectName("lineEdit_74")
        self.gridLayout.addWidget(self.lineEdit_74, 6, 1, 1, 1)
        self.lineEdit_58 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_58.sizePolicy().hasHeightForWidth())
        self.lineEdit_58.setSizePolicy(sizePolicy)
        self.lineEdit_58.setObjectName("lineEdit_58")
        self.gridLayout.addWidget(self.lineEdit_58, 6, 2, 1, 1)
        self.lineEdit_72 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_72.sizePolicy().hasHeightForWidth())
        self.lineEdit_72.setSizePolicy(sizePolicy)
        self.lineEdit_72.setObjectName("lineEdit_72")
        self.gridLayout.addWidget(self.lineEdit_72, 6, 3, 1, 1)
        self.lineEdit_63 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_63.sizePolicy().hasHeightForWidth())
        self.lineEdit_63.setSizePolicy(sizePolicy)
        self.lineEdit_63.setObjectName("lineEdit_63")
        self.gridLayout.addWidget(self.lineEdit_63, 6, 4, 1, 1)
        self.lineEdit_75 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_75.sizePolicy().hasHeightForWidth())
        self.lineEdit_75.setSizePolicy(sizePolicy)
        self.lineEdit_75.setObjectName("lineEdit_75")
        self.gridLayout.addWidget(self.lineEdit_75, 6, 5, 1, 1)
        self.lineEdit_78 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_78.sizePolicy().hasHeightForWidth())
        self.lineEdit_78.setSizePolicy(sizePolicy)
        self.lineEdit_78.setObjectName("lineEdit_78")
        self.gridLayout.addWidget(self.lineEdit_78, 6, 6, 1, 1)
        self.lineEdit_65 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_65.sizePolicy().hasHeightForWidth())
        self.lineEdit_65.setSizePolicy(sizePolicy)
        self.lineEdit_65.setObjectName("lineEdit_65")
        self.gridLayout.addWidget(self.lineEdit_65, 6, 7, 1, 1)
        self.lineEdit_79 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_79.sizePolicy().hasHeightForWidth())
        self.lineEdit_79.setSizePolicy(sizePolicy)
        self.lineEdit_79.setObjectName("lineEdit_79")
        self.gridLayout.addWidget(self.lineEdit_79, 6, 8, 1, 1)
        self.lineEdit_70 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_70.sizePolicy().hasHeightForWidth())
        self.lineEdit_70.setSizePolicy(sizePolicy)
        self.lineEdit_70.setObjectName("lineEdit_70")
        self.gridLayout.addWidget(self.lineEdit_70, 7, 0, 1, 1)
        self.lineEdit_64 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_64.sizePolicy().hasHeightForWidth())
        self.lineEdit_64.setSizePolicy(sizePolicy)
        self.lineEdit_64.setObjectName("lineEdit_64")
        self.gridLayout.addWidget(self.lineEdit_64, 7, 1, 1, 1)
        self.lineEdit_67 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_67.sizePolicy().hasHeightForWidth())
        self.lineEdit_67.setSizePolicy(sizePolicy)
        self.lineEdit_67.setObjectName("lineEdit_67")
        self.gridLayout.addWidget(self.lineEdit_67, 7, 2, 1, 1)
        self.lineEdit_55 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_55.sizePolicy().hasHeightForWidth())
        self.lineEdit_55.setSizePolicy(sizePolicy)
        self.lineEdit_55.setObjectName("lineEdit_55")
        self.gridLayout.addWidget(self.lineEdit_55, 7, 3, 1, 1)
        self.lineEdit_66 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_66.sizePolicy().hasHeightForWidth())
        self.lineEdit_66.setSizePolicy(sizePolicy)
        self.lineEdit_66.setObjectName("lineEdit_66")
        self.gridLayout.addWidget(self.lineEdit_66, 7, 4, 1, 1)
        self.lineEdit_76 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_76.sizePolicy().hasHeightForWidth())
        self.lineEdit_76.setSizePolicy(sizePolicy)
        self.lineEdit_76.setObjectName("lineEdit_76")
        self.gridLayout.addWidget(self.lineEdit_76, 7, 5, 1, 1)
        self.lineEdit_80 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_80.sizePolicy().hasHeightForWidth())
        self.lineEdit_80.setSizePolicy(sizePolicy)
        self.lineEdit_80.setObjectName("lineEdit_80")
        self.gridLayout.addWidget(self.lineEdit_80, 7, 6, 1, 1)
        self.lineEdit_69 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_69.sizePolicy().hasHeightForWidth())
        self.lineEdit_69.setSizePolicy(sizePolicy)
        self.lineEdit_69.setObjectName("lineEdit_69")
        self.gridLayout.addWidget(self.lineEdit_69, 7, 7, 1, 1)
        self.lineEdit_59 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_59.sizePolicy().hasHeightForWidth())
        self.lineEdit_59.setSizePolicy(sizePolicy)
        self.lineEdit_59.setObjectName("lineEdit_59")
        self.gridLayout.addWidget(self.lineEdit_59, 7, 8, 1, 1)
        self.lineEdit_60 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_60.sizePolicy().hasHeightForWidth())
        self.lineEdit_60.setSizePolicy(sizePolicy)
        self.lineEdit_60.setObjectName("lineEdit_60")
        self.gridLayout.addWidget(self.lineEdit_60, 8, 0, 1, 1)
        self.lineEdit_77 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_77.sizePolicy().hasHeightForWidth())
        self.lineEdit_77.setSizePolicy(sizePolicy)
        self.lineEdit_77.setObjectName("lineEdit_77")
        self.gridLayout.addWidget(self.lineEdit_77, 8, 1, 1, 1)
        self.lineEdit_71 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_71.sizePolicy().hasHeightForWidth())
        self.lineEdit_71.setSizePolicy(sizePolicy)
        self.lineEdit_71.setObjectName("lineEdit_71")
        self.gridLayout.addWidget(self.lineEdit_71, 8, 2, 1, 1)
        self.lineEdit_56 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_56.sizePolicy().hasHeightForWidth())
        self.lineEdit_56.setSizePolicy(sizePolicy)
        self.lineEdit_56.setObjectName("lineEdit_56")
        self.gridLayout.addWidget(self.lineEdit_56, 8, 3, 1, 1)
        self.lineEdit_81 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_81.sizePolicy().hasHeightForWidth())
        self.lineEdit_81.setSizePolicy(sizePolicy)
        self.lineEdit_81.setObjectName("lineEdit_81")
        self.gridLayout.addWidget(self.lineEdit_81, 8, 4, 1, 1)
        self.lineEdit_57 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_57.sizePolicy().hasHeightForWidth())
        self.lineEdit_57.setSizePolicy(sizePolicy)
        self.lineEdit_57.setObjectName("lineEdit_57")
        self.gridLayout.addWidget(self.lineEdit_57, 8, 5, 1, 1)
        self.lineEdit_61 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_61.sizePolicy().hasHeightForWidth())
        self.lineEdit_61.setSizePolicy(sizePolicy)
        self.lineEdit_61.setObjectName("lineEdit_61")
        self.gridLayout.addWidget(self.lineEdit_61, 8, 6, 1, 1)
        self.lineEdit_68 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_68.sizePolicy().hasHeightForWidth())
        self.lineEdit_68.setSizePolicy(sizePolicy)
        self.lineEdit_68.setObjectName("lineEdit_68")
        self.gridLayout.addWidget(self.lineEdit_68, 8, 7, 1, 1)
        self.lineEdit_73 = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lineEdit_73.sizePolicy().hasHeightForWidth())
        self.lineEdit_73.setSizePolicy(sizePolicy)
        self.lineEdit_73.setObjectName("lineEdit_73")
        self.gridLayout.addWidget(self.lineEdit_73, 8, 8, 1, 1)
        self.verticalLayout.addLayout(self.gridLayout)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 705, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "Next Move"))
        self.pushButton_2.setText(_translate("MainWindow", "Auto Play"))
        self.pushButton_3.setText(_translate("MainWindow", "Clear"))

הקוד כולל שלושה כפתורים והמון תיבות טקסט כדי לשקף לוח משחק סודוקו של 9 על 9.

2. חיבור קוד הממשק לקוד שלנו

בעבודה עם PyQt אנחנו לא נוגעים בקוד שמיוצר אוטומטית אלא משלבים אותו בקוד שלנו באמצעות import. בהנחה שלקובץ הקודם קראתם ui_grid.py התוכנית הבאה משלבת אותו בקוד שאפשר לעבוד אתו ומציגה את הממשק:

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
import ui_grid
from dlxsudoku import Sudoku

class MainWindow(QMainWindow):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.ui = ui_grid.Ui_MainWindow()
        self.ui.setupUi(self)

app = QApplication(sys.argv)
l = MainWindow()
l.show()

app.exec_()

3. הוספת קוד טיפול באירועים

בעת פיתוח הממשק הגרפי אנו בוחרים שמות לרכיבים השונים, למשל השם pushButton2 מייצג את הכפתור שכתוב עליו Auto Play. בשביל להוסיף קוד טיפול לכפתור נשתמש בפונקציה connect ונעביר לה שם של פונקציה במחלקה החדשה שבנינו.

כל הרכיבים שקיבלנו מהכלי הגרפי הם שדות של אוביקט ui שנשמר אצלנו במחלקה, ולכן השורה שיש להוסיף היא:

self.ui.pushButton2.clicked.connect(self.autoplay)

והקוד כולו נראה כך:

class MainWindow(QMainWindow):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.ui = ui_grid.Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.handle_click)

    def handle_click(self):
        print('Button Clicked!')

לכל אחד מהרכיבים ב Qt יש סיגנלים, המייצגים אירועים שקרו מרכיב זה. לכפתור לדוגמא יש סיגנל בשם clicked. כדי לטפל באירוע אנו מפעילים את connect של אחד הסיגנלים ומעבירים כפרמטר פונקציה שנרצה להפעיל.

4. סריקת תיבות הטקסט ובניית לוח המשחק כמחרוזת

הספריה dlxsudoku יודעת לפתור לוחות סודוקו שהיא מקבלת מתוך מחרוזת, ולכן כדי להשתמש בה נצטרך לקחת את המידע מלוח המשחק ולבנות ממנו מחרוזת. ב Qt הפונקציה findChildren מחזירה רשימה של פקדים מסוג מסוים, ולכן הפקודה הבאה מחזירה רשימה של כל תיבות הטקסט:

lineedits = self.ui.centralwidget.findChildren(QLineEdit)

בהמשך יש לסרוק את התיבות ולבנות מהן מחרוזת. כל תא שיש בו מספר יכתב כמו שהוא, ובמקום תא ריק או עם רווח יש לכתוב *. הקוד הבא מבצע את הסריקה ומכין את המחרוזת:

        sudoku_list = []

        for l in lineedits:
            try:
                val = int(l.text())
                sudoku_list.append(l.text())
            except:
                sudoku_list.append('*')

        sudoku_string = ''.join(sudoku_list)

5. חיבור לספריה הפותרת לוחות סודוקו

פתרון לוח הסודוקו דורש בסך הכל הפעלת פונקציה מתוך הספריה והקוד כולו נראה עכשיו כך:

from PyQt5.QtWidgets import *
import sys
import ui_grid
from dlxsudoku import Sudoku

class MainWindow(QMainWindow):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.ui = ui_grid.Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.handle_click)

    def handle_click(self):
        lineedits = self.ui.centralwidget.findChildren(QLineEdit)
        sudoku_list = []

        for l in lineedits:
            try:
                val = int(l.text())
                sudoku_list.append(l.text())
            except:
                sudoku_list.append('*')

        sudoku_string = ''.join(sudoku_list)
        s3 = Sudoku(sudoku_string)
        s3.solve()
        print(s3)


app = QApplication(sys.argv)
l = MainWindow()
l.show()

app.exec_()

6. רשמים ורעיונות להמשך

מפגש אונליין של שעה דורש מידה גבוהה של פוקוס כדי להיות אפקטיבי. במפגשים הבאים כדי לשפר את הפוקוס אני מתכנן לשלוח את כל החלק התיאורטי כוידאו וטקסט לקראת המפגש ועיקר העבודה במפגש תהיה הפיתוח עצמו. אני חושב שיש פה הרבה פוטנציאל לייצר סביבת למידה קצת שונה, בה אפשר לכתוב קוד שלא קשור לעבודה, לקבל עליו פידבק ולשאול שאלות.

בינתיים המפגשים עדיין לחברים בלבד אז תמשיכו לעקוב בבלוג לפרטים על המפגשים הבאים. בהמשך בטח אפתח לזה עמוד יותר מסודר כשדברים יתחילו לקבל צורה.