How To Make Progress Bar in PYQT5 Move At The Same Time As Function Being Called?

I have tried everything to make a progress bar I created in PYQT5 move at the same time a function from another file called untitled3.gl_dump is called. However, the progress bar freezes each time the function is called through a click of a button.

Here is my code so far

import sys
import time
import untitled3
from untitled3 import gl_dump
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets,QtGui
from PyQt5.QtWidgets import QDialog, QApplication,QMainWindow, QWidget, QHBoxLayout, QProgressBar,QVBoxLayout,QPushButton
from PyQt5.QtCore import QThread, pyqtSignal, QObject, pyqtSlot, QCoreApplication



class Worker(QObject):
    finished = pyqtSignal()
    intReady = pyqtSignal(int)
    
   

    @pyqtSlot()
    def proc_counter(self):
      for i in range(1, 101):
            time.sleep(0.5)
            
            self.intReady.emit(i)
           
        self.finished.emit()
            
    
class PopUpProgressB(QWidget):

    def __init__(self):
        super().__init__()
        self.pbar = QProgressBar(self)
        #self.pbar.setRange(0,0)
        self.pbar.setGeometry(30, 40, 500, 75)
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.pbar)
        self.setLayout(self.layout)
        self.setGeometry(300, 300, 550, 100)
        self.setWindowTitle('Progress Bar')

        self.obj = Worker()
        self.thread = QThread()
        self.obj.intReady.connect(self.on_count_changed)
        
        self.obj.moveToThread(self.thread)
     
        self.obj.finished.connect(self.thread.quit)
        self.obj.finished.connect(self.hide)  # To hide the progress bar after the progress is completed
        self.thread.started.connect(self.obj.proc_counter)
       

    def start_progress(self):
        # To restart the progress every time
        self.show()
        self.thread.start()

    def on_count_changed(self, value):
        self.pbar.setValue(value)
        
    

class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow,self).__init__()
        loadUi("app_interface.ui",self)
        self.pushButton.clicked.connect(self.gotoScreen2)
        self.screen2=Screen2()
       
        
        
    def gotoScreen2(self):
        screen2=Screen2()
        widget.addWidget(screen2)
        widget.setCurrentWidget(screen2)
        
        
class Screen2(QDialog):
    def __init__(self):
        super(Screen2,self).__init__()
        loadUi("GL_Dump_Curr.ui",self)
        self.pushButton_2.clicked.connect(self.gotoScreen1)
        self.popup=PopUpProgressB()
        self.main_window_button=self.pushButton
        self.btn=self.pushButton
        self.main_window_button.clicked.connect(self.popup.start_progress)
        self.btn.clicked.connect(untitled3.gl_dump)
               
        
    def gotoScreen1(self):
        mainwindow=MainWindow()
        widget.addWidget(mainwindow)
        widget.setCurrentWidget(mainwindow)
        
       
if __name__ == '__main__':    
    
    app = QApplication(sys.argv)
    QApplication.processEvents()
    widget=QtWidgets.QStackedWidget()
    mainwindow=MainWindow()
    widget.addWidget(mainwindow)
    widget.setFixedHeight(300)
    widget.setFixedHeight(400)
    widget.show()

try:
    sys.exit(app.exec_())
    
except:
    print("Exiting")

for the untitled3 file the function I am using is below

import xlwings as xw
import win32com.client as win32
import time
from datetime import datetime
month=datetime.now().strftime('%B')
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Visible = True
excel.DisplayAlerts = False
destination=rf"C:UsersRaphaelCDesktopImportant EmailsWIP Special WorkingsFY2024{month}"

def gl_dump():
    data_file = rf"C:UsersRaphaelCDesktopImportant EmailsWIP Special WorkingsFY2024{month}gl transaction download-cc1.xlsx"
    template_file=rf"C:UsersRaphaelCDesktopImportant EmailsWIP Special WorkingsFY2024{month}GL Dump - {month}.xlsx"
    wb_template = excel.Workbooks.Open(template_file)
    wb_data = excel.Workbooks.Open(data_file)
    wb_template.Sheets("GL Data Jan").Range("A2:W5000").Clear()
    wb_data.Sheets("Sheet1").Range("A2:W5000").Copy()
    wb_template.Sheets("GL Data Jan").Paste(wb_template.Sheets("GL Data Jan").Range('A2'))
    #excel.Selection.Copy(Destination=wb_template.Worksheets("GL Data Jan").Range("A2"))
    #wb_template.Worksheets("GL Data Jan").Range("A2:W5000").AutoFilter(20)
    wb_template.RefreshAll()
    time.sleep(5)
    wb_template.Save()
    wb_template.Close(True)
    wb_data.Close(True)
    excel.Application.Quit()
    return None

This is what the interface looks like

New contributor

Raph Car is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật