MultiTask Application

main.py

from ApplicationGUI import *
import time

# -------------------------------------------------------
# Application Init
MainWindow = loadWindow('MainWindow.ui')
# MainWindow.setWindowTitle("MultiTask Application version: 0.0.1")     # Set Window Title
# MainWindow.setMinimumSize(850, 550)                                   # Set minimum window size; Width=850, Height=550

# -------------------------------------------------------
# Tasks functions definitions
# def taskClockUpdate(Window, clock_time):
#     ClockUpdate(Window, clock_time)

def taskClockUpdate():
    # ts = time.strftime("%H:%M:%S")
    # ClockUpdate(MainWindow, ts)
    # ClockUpdate(MainWindow, str(int(time.time())))
    ClockUpdate(MainWindow, time.strftime("%H:%M:%S"))

# -------------------------------------------------------
# Events functions definitions
# If you use this function, remove or comment out the function with the same name from the file 'ApplicationGUI.py'
# def Event_ClickButton():
#     MainWindow.findChild(QLabel, "label").setText("00:00:00")

# -------------------------------------------------------
# Events functions assignment (with args)
# MainWindow.findChild(QPushButton, "pushButton").clicked.connect(Event_ClickButton)
MainWindow.findChild(QPushButton, "pushButton").clicked.connect(lambda: Event_ClickButton(MainWindow))

# -------------------------------------------------------
# Tasks Initialization
timer_clock = QTimer()
# timer_clock.timeout.connect(lambda: taskClockUpdate(MainWindow, time.strftime("%H:%M:%S")))
# timer_clock.timeout.connect(lambda: ClockUpdate(MainWindow, time.strftime("%H:%M:%S")))
timer_clock.timeout.connect(taskClockUpdate)
timer_clock.start(1000)

# -------------------------------------------------------
# Run Application
ApplicationRun(MainWindow)

ApplicationGUI.py

# -------------------------------------------------------
# Import QtDesigner Components
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QFile, QTimer
from PySide6.QtWidgets import QLabel, QPushButton

# -------------------------------------------------------
# Init Application
MainApplication = QApplication([])

# -------------------------------------------------------
# Load UI from file
def loadWindow(windowFile):
    file = QFile(windowFile)
    file.open(QFile.ReadOnly)
    loader = QUiLoader()
    res = loader.load(file)
    # res = QUiLoader().load(file)
    file.close()
    return res

# -------------------------------------------------------
# QtDesigner Components and functions
def ClockUpdate(Window, clock_time):
    # ClockLabel = Window.findChild(QLabel, "label")
    # ClockLabel.setText(clock_time)
    Window.findChild(QLabel, "label").setText(clock_time)

# -------------------------------------------------------
# Events functions
def Event_ClickButton(Window):
    Window.findChild(QLabel, "label").setText("00:00:00")

# -------------------------------------------------------
# Start Application
def ApplicationRun(Window):
    global MainApplication
    Window.show()
    MainApplication.exec()

MainWindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>850</width>
    <height>550</height>
   </rect>
  </property>
  <property name="minimumSize">
   <size>
    <width>0</width>
    <height>0</height>
   </size>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QVBoxLayout" name="verticalLayout">
    <property name="spacing">
     <number>3</number>
    </property>
    <property name="leftMargin">
     <number>1</number>
    </property>
    <property name="topMargin">
     <number>1</number>
    </property>
    <property name="rightMargin">
     <number>1</number>
    </property>
    <property name="bottomMargin">
     <number>1</number>
    </property>
    <item>
     <widget class="QWidget" name="widget_2" native="true">
      <property name="minimumSize">
       <size>
        <width>0</width>
        <height>80</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
        <width>16777215</width>
        <height>80</height>
       </size>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout_2">
       <property name="leftMargin">
        <number>1</number>
       </property>
       <property name="topMargin">
        <number>1</number>
       </property>
       <property name="rightMargin">
        <number>1</number>
       </property>
       <property name="bottomMargin">
        <number>1</number>
       </property>
       <item>
        <widget class="QFrame" name="frame">
         <property name="frameShape">
          <enum>QFrame::Shape::StyledPanel</enum>
         </property>
         <property name="frameShadow">
          <enum>QFrame::Shadow::Raised</enum>
         </property>
         <widget class="QPushButton" name="pushButton">
          <property name="geometry">
           <rect>
            <x>10</x>
            <y>40</y>
            <width>81</width>
            <height>23</height>
           </rect>
          </property>
          <property name="text">
           <string>OK</string>
          </property>
         </widget>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item>
     <widget class="QWidget" name="widget_3" native="true"/>
    </item>
    <item>
     <widget class="QWidget" name="widget" native="true">
      <property name="minimumSize">
       <size>
        <width>0</width>
        <height>32</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
        <width>16777215</width>
        <height>32</height>
       </size>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout">
       <property name="leftMargin">
        <number>3</number>
       </property>
       <property name="topMargin">
        <number>3</number>
       </property>
       <property name="rightMargin">
        <number>3</number>
       </property>
       <property name="bottomMargin">
        <number>3</number>
       </property>
       <item>
        <spacer name="horizontalSpacer">
         <property name="orientation">
          <enum>Qt::Orientation::Horizontal</enum>
         </property>
         <property name="sizeHint" stdset="0">
          <size>
           <width>782</width>
           <height>20</height>
          </size>
         </property>
        </spacer>
       </item>
       <item>
        <widget class="QLabel" name="label">
         <property name="text">
          <string>00:00:00</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>