Online Computer Courses Classes and Training Program

हम Lesson 5 में सीखेंगे कि button दबाने पर सिर्फ Terminal में message दिखाने के बजाय एक proper popup/message box कैसे दिखाते हैं।

 


बहुत बढ़िया! ✅ 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 बनेगा।

अभी केवल QMessageBox वाला बदलाव करें और Get Started दबाकर popup का screenshot भेजें।

Post a Comment

0 Comments