# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'Database.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import tkinter as Tk
from tkinter import filedialog, messagebox
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtCore import QObject, QThread, pyqtSignal

class Worker(QObject):

    finished = pyqtSignal()
    progress = pyqtSignal(int)

    def __init__(self):

        super().__init__()


    def DatenErfassen(self):

        self.finished.emit()
        pass


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(298, 175)
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(20, 110, 101, 51))
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        self.pushButton_2.setGeometry(QtCore.QRect(150, 110, 101, 51))
        self.pushButton_2.setObjectName("pushButton_2")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(20, 30, 261, 41))
        font = QtGui.QFont()
        font.setPointSize(15)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

        self.pushButton.clicked.connect(lambda: self.action_1())
        self.pushButton_2.clicked.connect(lambda: self.action_2())

    def action_1(self):

        try:

            self.label.setText("Database running")
            # Step 2: Create a QThread object
            self.thread = QThread()
            # Step 3: Create a worker object
            self.worker = Worker()
            # Step 4: Move worker to the thread
            self.worker.moveToThread(self.thread)
            # Step 5: Connect signals and slots
            self.thread.started.connect(self.worker.DatenErfassen)
            self.worker.finished.connect(self.thread.quit)
            self.worker.finished.connect(self.worker.deleteLater)

            self.thread.finished.connect(self.thread.deleteLater)
            # Step 6: Start the thread
            self.thread.start()

            self.pushButton.setEnabled(False)
            self.thread.finished.connect(
                lambda: self.pushButton.setEnabled(True)
            )

        except:
            self.label.setText('Etwas ist schief gelaufen')


    def action_2(self):

        try:

            self.label.setText("Database not running")

        except:
            pass



    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "Start"))
        self.pushButton_2.setText(_translate("Form", "Stop"))
        self.label.setText(_translate("Form", "Data capturing not running"))

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'Database.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import tkinter as Tk
from tkinter import filedialog, messagebox
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtCore import QObject, QThread, pyqtSignal

class Worker(QObject):

    finished = pyqtSignal()
    progress = pyqtSignal(int)

    def __init__(self):

        super().__init__()


    def DatenErfassen(self):

        self.finished.emit()
        pass


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(298, 175)
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(20, 110, 101, 51))
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        self.pushButton_2.setGeometry(QtCore.QRect(150, 110, 101, 51))
        self.pushButton_2.setObjectName("pushButton_2")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(20, 30, 261, 41))
        font = QtGui.QFont()
        font.setPointSize(15)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

        self.pushButton.clicked.connect(lambda: self.action_1())
        self.pushButton_2.clicked.connect(lambda: self.action_2())

    def action_1(self):

        try:

            self.label.setText("Database running")
            # Step 2: Create a QThread object
            self.thread = QThread()
            # Step 3: Create a worker object
            self.worker = Worker()
            # Step 4: Move worker to the thread
            self.worker.moveToThread(self.thread)
            # Step 5: Connect signals and slots
            self.thread.started.connect(self.worker.DatenErfassen)
            self.worker.finished.connect(self.thread.quit)
            self.worker.finished.connect(self.worker.deleteLater)

            self.thread.finished.connect(self.thread.deleteLater)
            # Step 6: Start the thread
            self.thread.start()

            self.pushButton.setEnabled(False)
            self.thread.finished.connect(
                lambda: self.pushButton.setEnabled(True)
            )

        except:
            self.label.setText('Etwas ist schief gelaufen')


    def action_2(self):

        try:

            self.label.setText("Database not running")

        except:
            pass



    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "Start"))
        self.pushButton_2.setText(_translate("Form", "Stop"))
        self.label.setText(_translate("Form", "Data capturing not running"))

# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'Database.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again.  Do not edit this file unless you know what you are doing. # Step 2: Create a QThread object # Step 3: Create a worker object # Step 4: Move worker to the thread # Step 5: Connect signals and slots # Step 6: Start the thread