title: How to share lineedit strings from a QWidget class to a worker thread
body: <p>Right now I have a GUI window that takes several lines of user inputs and plugs them into a function from another script that's imported. I need to add threading to this process because the function I am plugging the user inputs into can take a long time and cause the GUI to become unresponsive. This GUI has a main window and several other Windows which inherit from the QWidget class. Shown below are my imports and the code for my window which takes input.</p>
  <pre><code>from PyQt5 import QtWidgets as qtw
  from PyQt5 import QtCore as qtc
  from PyQt5.QtWidgets import QInputDialog, QFileDialog, QDialog
  from PyQt5 import QtGui
  from PyQt5.QtCore import Qt, QObject, QThread, pyqtSignal
  import geopandas as gpd
  from aw_widget import Ui_Areal_Weight
  from areal_weight import arealwt
  
  class aw(qtw.QWidget):    
      def __init__(self):
          super().__init__()
          self.ui = Ui_Areal_Weight()
          self.ui.setupUi(self)
          self.ui.aw_source_browse.clicked.connect(self.source_browser)
          self.ui.aw_target_browse.clicked.connect(self.target_browser)
          self.ui.aw_save_browse.clicked.connect(self.save_browser)
          self.ui.aw_run_prog.clicked.connect(self.run_aw)
          self.ui.aw_cancel_prog.clicked.connect(self.close_aw)
          title = &quot;Areal Weighting Method&quot;
          self.setWindowTitle(title)
      def source_browser(self):
          self.filename = QFileDialog.getOpenFileName()
          self.ui.aw_source_lineedit.setText(self.filename[0])  
      def target_browser(self):
          self.filename = QFileDialog.getOpenFileName()
          self.ui.aw_target_lineedit.setText(self.filename[0])    
      def save_browser(self):
          self.filename = QFileDialog.getSaveFileName()
          self.ui.aw_save_lineedit.setText(self.filename[0])              
      def run_aw(self):
          src = self.ui.aw_source_lineedit.text()
          target = self.ui.aw_target_lineedit.text()
          intp = self.ui.aw_intp_fields.text()
          intp = intp.split()
          suffix = self.ui.aw_output_suffix.text()
          save = self.ui.aw_save_lineedit.text()   
          try:
              src = gpd.read_file(src)
          except:
              qtw.QMessageBox.critical(self, 'Error', 'Invalid Source Shapefile')
              raise
          try:
              target = gpd.read_file(target)
          except:
              qtw.QMessageBox.critical(self, 'Error', 'Invalid Target Shapefile')
              raise            
          try:
              outp = arealwt(src, target, intp, suffix)
              outp.to_file(save)
              qtw.QMessageBox.information(self, 'Success', 'Areal Weighting Complete')
          except:
              qtw.QMessageBox.critical(self, 'Error', 'Interpolation Failed')
              raise                
      def close_aw(self):
          self.close()
      
  </code></pre>
  <p>GUI window:<br />
  <a href="https://i.stack.imgur.com/5Junr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Junr.png" alt="GUI window" /></a></p>
  <p>My first instinct is to move the contents of the run_aw() function to a worker thread outside of the aw class, but I am not sure of how I can share the strings from the lineedits in the GUI to the worker class so I can plug them into the arguments of my arealwt() function. Basically I want the user to fill out all of the fields, and then when they click run, the lineedit data is sent to a worker class and plugged into the arugments of the arealwt() function. In the QThread examples I have seen, the main function that takes a long time to process is moved to a worker thread, but I have not seen an example of this where the function has relied on information that a user entering into the GUI.</p>
  <p>My question is, how can I send the lineedit string data from my GUI window to a worker thread?</p>