How to connect PyQt signal to external function
<p>How does one connect a pyqt button signal in one file, to a function in another python file? I've tried various things, but nothing seems to work.
This is the first file:</p>

<pre><code>from PyQt4 import QtGui
from PyQt4.QtGui import QMainWindow
from MainUIFile import Ui_Main
from pythonfile import myOutsideFunction
class MainWindow(QMainWindow,Ui_file):
    def __init__(self):
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.btn.clicked.connect(myOutsideFunction())
</code></pre>

<p>The second file that is called by the first:</p>

<pre><code>def myOutsideFunction(self):
    # Do some stuff here
</code></pre>

<p>How would I go about doing this?</p>

<p>What is the importance of connecting to a function outside of your code?  Could you not just do something like this:</p>

<pre><code>def myOutsideFunction(a,b,c,d):
    #process variables/objects a,b,c,d as you wish
    return answer

from PyQt4 import QtGui
from PyQt4.QtGui import QMainWindow
from MainUIFile import Ui_Main
from pythonfile import myOutsideFunction
class MainWindow(QMainWindow,Ui_file):
    def __init__(self):
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.btn.clicked.connect(self.pressed_the_button())
        #initialize your variables/objects for your outside function if need be

    def pressed_the_button(self):
        answer_from_outside_function = myOutsideFunction(self.a,self.b,self.c,self.d)
        # run whatever you need to here...
</code></pre>

python windows file pyqt