LLM Python 11-2 PyQt6 (Assignment Deadline Calculation, Pizza Ordering App)

Published: 10 May 2024
on channel: MahlerLab
224
7

This lecture video was produced for on-campus classes. Assignments are not accepted.

It was created for on-campus use. ===
from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget, QDateEdit
from PyQt6.QtCore import QDate

def update_days_remaining():
today_date = todayDateEdit.date()
due_date = dueDateEdit.date()
days_remaining = today_date.daysTo(due_date)
resultLabel.setText(f" {days_remaining} days left")

app = Qapplication([])
layout = QGridLayout()
todayDateEdit = QDateEdit(QDate.currentDate())
todayDateEdit.setCalendarPopup(True)
todayDateEdit.dateChanged.connect(update_days_remaining) # Function when dateChanged event occurs Execute

layout.addWidget(QLabel("Today's Date:"), 0, 0) # Top left

layout.addWidget(todayDateEdit, 1, 0) # Below the label on the left

dueDateEdit = QDateEdit(Qdate.currentDate().addDays(7))

dueDateEdit.setCalendarPopup(True)

dueDateEdit.dateChanged.connect(update_days_remaining)

layout.addWidget(Qlabel("Submission Date:"), 0, 1) # Top right

layout.addWidget(dueDateEdit, 1, 1) # Below the label on the right

resultLabel = QLabel("Remaining days are displayed.")

layout.addWidget(resultLabel, 2, 0, 1, 2) # In the 2,0 column Widgets spanning 1 row and 2 columns

widget = QWidget()
widget.setLayout(layout)

window = QMainWindow()
window.setWindowTitle("Date Calculator")
window.setCentralWidget(widget)
window.show()
app.exec()
===
from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QComboBox, QRadioButton, QWidget, QButtonGroup, QListWidget

def update_price():
size_index = sizeList.currentIndex().row()
topping_index = toppingGroup.checkedId()
order_type = orderTypeCombo.currentText()
size_prices = [2, 1.5, 1]
topping_prices = [12000, 14000, 16000]

price = int(size_prices[size_index] * topping_prices[topping_index])

if order_type == "Delivery":

price += 5000

priceLabel.setText(f"Total order amount: {price:,} won")

app = QApplication([])

layout = QVBoxLayout()

layout.addWidget(QLabel('Size:'))

sizeList = QListWidget()

sizeList.addItems(['Large', 'Medium', 'Small'])

sizeList.currentItemChanged.connect(update_price) # Connect to update function

layout.addWidget(sizeList)

layout.addWidget(QLabel('Topping:'))

toppingGroup = QButtonGroup()

toppings = ['Pepperoni', 'Supreme', 'Bulgogi']
for i, topping in enumerate(toppings):
button = QRadioButton(topping)
layout.addWidget(button)
toppingGroup.addButton(button, i) # Assign an ID to each button
if i == 0:
button.setChecked(True) #Default selection
toppingGroup.buttonClicked.connect(update_price) # Connect to update function

layout.addWidget(QLabel('Order Type:'))
orderTypeCombo = QComboBox()
orderTypeCombo.addItems(['Delivery', 'Packaging'])
orderTypeCombo.currentIndexChanged.connect(update_price) # Connect to update function
layout.addWidget(orderTypeCombo)

priceLabel = QLabel("Total order amount:")
layout.addWidget(priceLabel)

widget = QWidget()
widget.setLayout(layout)
window = QMainWindow()
window.setWindowTitle("Inje Pizza")
window.setCentralWidget(widget)
window.show()
app.exec()


On this page of the site you can watch the video online LLM Python 11-2 PyQt6 (Assignment Deadline Calculation, Pizza Ordering App) with a duration of hours minute second in good quality, which was uploaded by the user MahlerLab 10 May 2024, share the link with friends and acquaintances, this video has already been watched 224 times on youtube and it was liked by 7 viewers. Enjoy your viewing!