बहुत बढ़िया! ✅ Lesson 4 भी सफल है।
आपके screenshot में सबसे महत्वपूर्ण proof है:
Get Started button clicked!यानी:
Button Click
↓
clicked signal
↓
connect()
↓
button_clicked()
↓
Python code
↓
Terminal में messageअब हम अगला महत्वपूर्ण concept सीखेंगे।
🎓 Lesson 5 — Message Box बनाना
अभी button दबाने पर message Terminal में दिखाई देता है। लेकिन हमारे final School Fee Software में user को Terminal नहीं दिखेगा।
हम चाहते हैं कि button दबाने पर software के अंदर ही एक popup आए:
┌─────────────────────────────────────┐
│ Information │
├─────────────────────────────────────┤
│ │
│ Welcome to School Fee Management │
│ Software! │
│ │
│ [ OK ] │
└─────────────────────────────────────┘यही concept आगे error, confirmation और warning के लिए भी इस्तेमाल होगा।
Step 1 — QMessageBox Import करें
अपने import वाले हिस्से में:
QVBoxLayoutके साथ QMessageBox जोड़ें।
आपका import section ऐसा हो जाएगा:
from PySide6.QtWidgets import (
QApplication,
QMainWindow,
QWidget,
QLabel,
QPushButton,
QVBoxLayout,
QMessageBox
)Step 2 — Function बदलें
अभी आपका function कुछ ऐसा है:
def button_clicked():
print("Get Started button clicked!")इसे बदलकर करें:
def button_clicked():
QMessageBox.information(
window,
"Welcome",
"Welcome to School Fee Management Software!"
)ध्यान दें: अभी window function के नीचे बना हुआ है, लेकिन Python में function को बनाना और उसे बाद में चलाना अलग बातें हैं। इसलिए यहाँ यह ठीक काम करेगा क्योंकि function बाद में button click पर चलेगा, तब तक window बन चुका होगा।
🧠 इस code को समझिए
QMessageBox.information(इसका मतलब:
एक Information popup दिखाओ।
पहला parameter:
windowमतलब popup किस main window से संबंधित है।
दूसरा:
"Welcome"Popup का title।
तीसरा:
"Welcome to School Fee Management Software!"Popup के अंदर दिखाई देने वाला message।
Step 3 — Program Run करें
पहले पुरानी application बंद करें।
फिर:
python main.pyअब:
Get Started दबाएँ।
आपको popup दिखाई देना चाहिए।
💡 अब एक बहुत महत्वपूर्ण बात
हमारे final software में इसी QMessageBox का इस्तेमाल होगा।
Student Save होने पर:
Student saved successfully!Student Delete करने से पहले:
Are you sure you want to delete this student?
[ Yes ] [ No ]Payment Save होने पर:
Payment collected successfully!Error होने पर:
Error
Please enter payment amount.इसलिए आज का concept छोटा है, लेकिन आगे बहुत काम आएगा।
🎯 अगला Step
इसके बाद हम Lesson 6 — Input Field (QLineEdit) सीखेंगे।
वहाँ पहली बार user software में खुद information लिख पाएगा:
┌──────────────────────────────────────┐
│ Student Name │
│ [ Rahul Kumar ] │
│ │
│ [ Save Student ] │
└──────────────────────────────────────┘और फिर हम सीखेंगे:
Input → Button → Function → Data
यही आगे जाकर Student Form → SQLite Database बनेगा।
0 Comments
कमेंट केवल पोस्ट से रिलेटेड करें