<jupyter_start><jupyter_text>Checkbox<jupyter_code>from PyQt5 import QtCore, QtGui, QtWidgets
 
 
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(413, 306)
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_2 = QtWidgets.QLabel(Dialog)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.checkBoxPizza = QtWidgets.QCheckBox(Dialog)
        self.checkBoxPizza.setObjectName("checkBoxPizza")
        self.checkBoxPizza.stateChanged.connect(self.checked_item)
 
        self.verticalLayout_2.addWidget(self.checkBoxPizza)
        self.checkBoxSalad = QtWidgets.QCheckBox(Dialog)
        self.checkBoxSalad.setObjectName("checkBoxSalad")
        self.verticalLayout_2.addWidget(self.checkBoxSalad)
        self.checkBoxSalad.stateChanged.connect(self.checked_item)
 
        self.checkBoxSausage = QtWidgets.QCheckBox(Dialog)
        self.checkBoxSausage.setObjectName("checkBoxSausage")
        self.verticalLayout_2.addWidget(self.checkBoxSausage)
        self.horizontalLayout.addLayout(self.verticalLayout_2)
        
        #added newly after conversion for connecting signal to slot
        self.checkBoxSausage.stateChanged.connect(self.checked_item)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.labelResult = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.labelResult.setFont(font)
        self.labelResult.setText("")
        self.labelResult.setObjectName("labelResult")
        self.verticalLayout.addWidget(self.labelResult)
        self.verticalLayout_3.addLayout(self.verticalLayout)
 
        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
 
    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "PyQt5 QCheckBoxes"))
        self.label.setText(_translate("Dialog", "Regular Tuna Price : 20"))
        self.label_2.setText(_translate("Dialog", "Select Extra"))
        self.checkBoxPizza.setText(_translate("Dialog", "Pizza : 3"))
        self.checkBoxSalad.setText(_translate("Dialog", "Salad : 4"))
        self.checkBoxSausage.setText(_translate("Dialog", "Sausage : 5"))
 
 
 
    #this is method is added after conversion 
    def checked_item(self):
        price = 20
 
        if self.checkBoxPizza.isChecked():
            price = price + 3
 
        if self.checkBoxSalad.isChecked():
            price = price + 4
 
        if self.checkBoxSausage.isChecked():
            price = price + 5
 
 
        self.labelResult.setText("Total Price Is : {} ".format(price))
 
 
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
from PyQt5.QtWidgets import QApplication,QDialog,QHBoxLayout, QVBoxLayout, QLabel, QCheckBox
import sys
from PyQt5.QtGui import QIcon, QIcon, QFont
from PyQt5.QtCore import QSize
 
 
 
 
class Window(QDialog):
    def __init__(self):
        super().__init__()
 
 
        #window title, icon and geometry
        self.setGeometry(200,200, 400,200)
        self.setWindowTitle("PyQt5 CheckBox")
        self.setWindowIcon(QIcon('python.png'))
 
        self.create_checkbox()
 
 
    def create_checkbox(self):
 
        #this is our hboxlayout
        hbox = QHBoxLayout()
 
        #these are checkboxes
        self.check1 = QCheckBox("Football")
        self.check1.setIcon(QIcon('football.png'))
        self.check1.setIconSize(QSize(40,40))
        self.check1.setFont(QFont("Sanserif", 13))
        self.check1.toggled.connect(self.item_selected)
        hbox.addWidget(self.check1)
 
        self.check2 = QCheckBox("Cricket")
        self.check2.setIcon(QIcon('cricket.png'))
        self.check2.setIconSize(QSize(40, 40))
        self.check2.setFont(QFont("Sanserif", 13))
        self.check2.toggled.connect(self.item_selected)
        hbox.addWidget(self.check2)
 
        self.check3 = QCheckBox("Tennis")
        self.check3.setIcon(QIcon('tennis.png'))
        self.check3.setIconSize(QSize(40, 40))
        self.check3.setFont(QFont("Sanserif", 13))
        self.check3.toggled.connect(self.item_selected)
        hbox.addWidget(self.check3)
 
 
        #this is the vboxlayout
        vbox = QVBoxLayout()
 
        #we have created a label in here
        self.label = QLabel("Hello")
        self.label.setFont(QFont("Sanserif", 15))
 
        #add the label in the vbox layout
        vbox.addWidget(self.label)
 
        #add the hbox layout in the vbox layout
        vbox.addLayout(hbox)
 
 
        #set the layout for the main window
        self.setLayout(vbox)
 
 
    def item_selected(self):
        value = ""
 
        #check for the check box value
        if self.check1.isChecked():
            value = self.check1.text()
 
        if self.check2.isChecked():
            value = self.check2.text()
 
 
        if self.check3.isChecked():
            value = self.check3.text()
 
 
        self.label.setText("You have selected : " + value)
 
 
 
 
 
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())<jupyter_output><empty_output><jupyter_text>Spinbox<jupyter_code>from PyQt5.QtWidgets import QApplication, QDialog, QHBoxLayout, QSpinBox, QLabel, QLineEdit
import sys
from PyQt5.QtGui import QIcon
 
class Window(QDialog):
    def __init__(self):
        super().__init__()
 
 
        #our window requirements like icon,title
        self.setGeometry(200,200,400,300)
        self.setWindowTitle("PyQt5 SpinBox")
        self.setWindowIcon(QIcon("python.png"))
 
        self.create_spinbox()
 
 
    def create_spinbox(self):
 
        #cretae hboxlayout
        hbox = QHBoxLayout()
 
        #in here we have created our label
        label = QLabel("Laptop Price : ")
 
        #this is our linedit
        self.lineEdit = QLineEdit()
 
        #we need to create the object of QSpinBox class
        self.spinbox = QSpinBox()
 
        #we have connected valueChanged signal
        self.spinbox.valueChanged.connect(self.spin_selected)
        self.totalResult = QLineEdit()
 
 
        #add widgets to your hbox layout
        hbox.addWidget(label)
        hbox.addWidget(self.lineEdit)
        hbox.addWidget(self.spinbox)
        hbox.addWidget(self.totalResult)
 
 
        self.setLayout(hbox)
 
 
    def spin_selected(self):
        if self.lineEdit.text() != 0:
            price = int(self.lineEdit.text())
            totalPrice = self.spinbox.value() * price
 
            self.totalResult.setText(str(totalPrice))
 
 
        else:
            print("Wrong value")
 
 
App = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(App.exec())
from PyQt5.QtWidgets import QApplication, QDialog, QLineEdit,\
    QDoubleSpinBox
from PyQt5 import uic
 
class UI(QDialog):
    def __init__(self):
        super().__init__()
 
        #loading the ui file with uic module 
        uic.loadUi("doublespin.ui", self)
 
        #finding child in the ui file
 
        self.linePrice = self.findChild(QLineEdit, "lineEditPrice")
        self.doublespin = self.findChild(QDoubleSpinBox, "doubleSpinBox")
        self.doublespin.valueChanged.connect(self.spin_selected)
        
        self.lineResult = self.findChild(QLineEdit, "lineEditTotal")
 
 
 
    def spin_selected(self):
        if self.linePrice.text() != 0:
            price = int(self.linePrice.text())
            totalPrice = self.doublespin.value() * price
 
            self.lineResult.setText(str(totalPrice))
 
 
 
app = QApplication([])
window = UI()
window.show()
app.exec_()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10655164373979949, 'fraction_numerical': 0.014105852179995337, 'mean_word_length': 2.717071057192374, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '499640', 'license': 'Unlicense', 'n_tokens_mistral': 2832, 'n_tokens_neox': 2618, 'n_words': 453, 'path': 'Day 2.ipynb', 'repo_name': 'Tarun-yadav777/pyQT5_code_snippet', 'size': '8578'}