Data Science Jupyter Notebooks
11K subscribers
269 photos
31 videos
9 files
726 links
Explore the world of Data Science through Jupyter Notebooks—insights, tutorials, and tools to boost your data journey. Code, analyze, and visualize smarter with every post.
Download Telegram
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QDate
import database as db

class PharmacyApp(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Pharmacy Management System")
self.setGeometry(100, 100, 1200, 700)
db.setup_database()

self.tabs = QTabWidget()
self.setCentralWidget(self.tabs)

self.pos_tab = QWidget()
self.inventory_tab = QWidget()

self.tabs.addTab(self.pos_tab, "Point of Sale")
self.tabs.addTab(self.inventory_tab, "Inventory Management")

self.setup_inventory_ui()
# self.setup_pos_ui() will be done in the next step

self.load_inventory_data()

def setup_inventory_ui(self):
layout = QVBoxLayout()
self.inventory_table = QTableWidget()
self.inventory_table.setColumnCount(6)
self.inventory_table.setHorizontalHeaderLabels(['ID', 'Name', 'Barcode', 'Quantity', 'Price', 'Expiry Date'])
layout.addWidget(self.inventory_table)

form = QFormLayout()
self.drug_name = QLineEdit()
self.drug_barcode = QLineEdit()
self.drug_qty = QSpinBox()
self.drug_qty.setRange(0, 9999)
self.drug_price = QLineEdit()
self.drug_expiry = QDateEdit(QDate.currentDate().addYears(1))
self.drug_expiry.setDisplayFormat("yyyy-MM-dd")

form.addRow("Name:", self.drug_name)
form.addRow("Barcode:", self.drug_barcode)
form.addRow("Quantity:", self.drug_qty)
form.addRow("Price:", self.drug_price)
form.addRow("Expiry Date:", self.drug_expiry)
add_btn = QPushButton("Add Drug to Inventory")
add_btn.clicked.connect(self.add_drug_to_db)

layout.addLayout(form)
layout.addWidget(add_btn)
self.inventory_tab.setLayout(layout)

def load_inventory_data(self):
drugs = db.get_all_drugs()
self.inventory_table.setRowCount(len(drugs))
for row, drug in enumerate(drugs):
for col, data in enumerate(drug):
self.inventory_table.setItem(row, col, QTableWidgetItem(str(data)))

def add_drug_to_db(self):
name = self.drug_name.text()
barcode = self.drug_barcode.text()
qty = self.drug_qty.value()
price = float(self.drug_price.text())
expiry = self.drug_expiry.date().toString("yyyy-MM-dd")

if not all([name, barcode, qty > 0, price > 0]):
QMessageBox.warning(self, "Input Error", "Please fill all fields correctly.")
return

if db.add_drug(name, barcode, qty, price, expiry):
self.load_inventory_data()
else:
QMessageBox.warning(self, "Database Error", "A drug with this barcode already exists.")

# Main execution block at the end of the file
if __name__ == '__main__':
app = QApplication(sys.argv)
window = PharmacyApp()
window.show()
sys.exit(app.exec_())

# Hashtags: #PyQt5 #GUI #CRUD #Inventory


---

#Step 3: Point of Sale (POS) UI and Barcode Handling

Now, let's build the user interface for the sales tab. This will include an input for the barcode, a table for the current sale items (the "cart"), and buttons to finalize or clear the sale. A physical barcode scanner typically emulates a keyboard, entering the numbers and pressing "Enter". We will simulate this with the returnPressed signal on a QLineEdit.

Add these methods to the PharmacyApp class:
🔥 Trending Repository: nocobase

📝 Description: NocoBase is the most extensible AI-powered no-code/low-code platform for building business applications and enterprise solutions.

🔗 Repository URL: https://github.com/nocobase/nocobase

🌐 Website: https://www.nocobase.com

📖 Readme: https://github.com/nocobase/nocobase#readme

📊 Statistics:
🌟 Stars: 17.7K stars
👀 Watchers: 147
🍴 Forks: 2K forks

💻 Programming Languages: TypeScript - JavaScript - Smarty - Shell - Dockerfile - Less

🏷️ Related Topics:
#internal_tools #crud #crm #admin_dashboard #self_hosted #web_application #project_management #salesforce #developer_tools #airtable #workflows #low_code #no_code #app_builder #internal_tool #nocode #low_code_development_platform #no_code_platform #low_code_platform #low_code_framework


==================================
🧠 By: https://t.iss.one/DataScienceM