title: Python & Pyqt5 : Create Button After a File Exist
body: <p>I'm trying to build a simple application using Pyqt5. My purpose is, when I click <code>Listen</code> button, open my another exe (built from another platform) and checks every second that <code>a.txt</code> exists or not. If exists; I want to create a new button on current interface.</p>
  
  <p>Now, when I click Listen button, I can open my other exe (I will use <code>notepad</code> in here for minimal example) and my application starts always checking the <code>a.txt</code> exists. After few seconds, I'm creating <code>a.txt</code> from another script. My problem is; new button does not appear. But if I close empty notepad, new button appears.</p>
  
  <p>My script for simple interface:</p>
  
  <pre><code>from PyQt5 import QtCore, QtWidgets
  import sys
  import time
  import subprocess
  import os
  
  class ListenWindow(QtWidgets.QWidget):
      def __init__(self, parent=None):
          super(ListenWindow, self).__init__(parent)
          self.setWindowTitle("Listen")
  
          self.button_login = QtWidgets.QPushButton('Listen', self)
          font3 = self.button_login.font()  # lineedit current font
          font3.setPointSize(10)  # change it's size
          self.button_login.setFont(font3)
          self.button_login.setFixedSize(200, 50)
          self.button_login.clicked.connect(self.startToListen)
  
          self.v_box1 = QtWidgets.QVBoxLayout(self)
          self.v_box1.addWidget(self.button_login)
  
          self.h_box1 = QtWidgets.QHBoxLayout(self)
          self.v_box1.addLayout(self.h_box1)
  
      def startToListen(self):
          FNULL = open(os.devnull, 'w')
          args = "notepad"
          subprocess.call(args, stdout=FNULL, stderr=FNULL, shell=False)
  
          while not os.path.exists('C:/Users/Wicaledon/PycharmProjects/abc/a.txt'):
              time.sleep(1)
  
          if os.path.isfile('C:/Users/Wicaledon/PycharmProjects/abc/a.txt'):
              self.buttonSeq = QtWidgets.QPushButton('Start Sequence', self)
              font8 = self.buttonSeq.font()  # lineedit current font
              font8.setPointSize(10)  # change it's size
              self.buttonSeq.setFont(font8)
              self.buttonSeq.setFixedSize(200, 50)
              self.h_box1.addWidget(self.buttonSeq, 0, QtCore.Qt.AlignCenter)
          else:
              raise ValueError("%s isn't a file!" % 'C:/Users/Wicaledon/PycharmProjects/abc/a.txt')
  
  if __name__ == '__main__':
      app = QtWidgets.QApplication(sys.argv)
      window = ListenWindow()
      window.setWindowTitle('Login')
      window.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>My script for creating <code>a.txt</code> file:</p>
  
  <pre><code>f=open("a.txt", "a+")
  for i in range(2):
       f.write("Appended line %d\r\n" % (i+1))
  f.close()
  </code></pre>
  
  <p>Where is my fault? Can you help me?</p>