
from PyQt6 import QtCore
from PyQt6.QtWidgets import QWidget

from UI.addloaclip import Ui_Addloacalip
from .LogerinTxt import app_logger


class localipset(Ui_Addloacalip, QWidget):
    localipset_signal = QtCore.pyqtSignal(str)

    def __init__(self, parent=None):
        super().__init__(parent)
        try:
            self.setupUi(self)
            self.pushButton.clicked.connect(self.btn)
            self.localip1 = None
            self.localip = None
        except Exception as e:
            app_logger.log_error(e)

    def start(self):
        self.show()
        self.lineEditIP.setText(self.localip)

    def btn(self):
        try:
            self.localip1 = self.lineEditIP.text()
            self.localipset_signal.emit(self.localip1)
            self.close()
        except Exception as e:
            app_logger.log_error(e)
