
from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QGridLayout, QPlainTextEdit , QLineEdit, QWidget
import sys

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("IHM Zigbee")
        self.setGeometry(100,100,600,400)
        Firstlayout = QGridLayout()

        layoutTop = QHBoxLayout()
        layoutMidTop = QVBoxLayout()
        layoutMid = QHBoxLayout()
        layoutMidBot = QHBoxLayout()
        layoutBot = QHBoxLayout()

        ButtonOneClick = QPushButton("Click")
        ButtonOneClick.clicked.connect(self.SimpleClick)
        ButtonLongClick = QPushButton("LongClick")
        ButtonLongClick.clicked.connect(self.LongClick)
        ButtonDobbleClick = QPushButton("Dobble Click")
        ButtonDobbleClick.clicked.connect(self.DobbleClick)

        layoutTop.addWidget(ButtonOneClick)
        layoutTop.addWidget(ButtonDobbleClick)
        layoutTop.addWidget(ButtonLongClick)

        TempLabel = QLabel("Temperature")
        CountCLick = QLabel("ClickCounter")


        layoutMidTop.addWidget(TempLabel)
        layoutMidTop.addWidget(CountCLick)


        LineEdit = QLineEdit()
        LineEdit2 = QLineEdit()
        layoutMid.addWidget(LineEdit)
        layoutMid.addWidget(LineEdit2)

        ButtonConnect = QPushButton("ButtonConnect")
        ButtonConnect.clicked.connect(self.Connect)
        ButtonDisconnect = QPushButton("ButtonDisconnect")
        ButtonDisconnect.clicked.connect(self.Disconnect)

        layoutMidBot.addWidget(ButtonConnect)
        layoutMidBot.addWidget(ButtonDisconnect)

        TextArea = QPlainTextEdit()
        TextArea.appendPlainText("blablabla test \nTest saut de ligne")
        layoutBot.addWidget(TextArea)

        Firstlayout.addLayout(layoutTop, 0, 0)
        Firstlayout.addLayout(layoutMidTop, 1, 0)
        Firstlayout.addLayout(layoutMid,2,0)
        Firstlayout.addLayout(layoutMidBot,3,0)
        Firstlayout.addLayout(layoutBot,4,0)


        # Créer un widget pour la mise en page principale et lui assigner la mise en page
        widget = QWidget()
        widget.setLayout(Firstlayout)

        # Ajouter le widget à la fenêtre principale
        self.setCentralWidget(widget)
        
    def SimpleClick(self):
        pass

    def LongClick(self):
        pass

    def DobbleClick(self):
        pass

    def Connect(self):
        connection(1)
        pass

    def Disconnect(self):
        connection(0)
        pass
        
app = QApplication(sys.argv)

window = MainWindow()
window.show()

app.exec()


#https://stackoverflow.com/questions/24371274/how-to-dynamically-update-qtextedit   //À checker pour les updates du PlainText
