2017-07-22 55 views
0
def run(self, path): 
    subprocess.call(['pythonw', path]) 

def login(self): 
    members = {'sample': 'sample'} 
    username = self.username.text() 
    password = self.password.text() 

    if username in members: 
     enteredPass = members.get(username) 
     if password == enteredPass: 
      self.run('inventory.py') 
      #app.instance().quit() 
      sys.exit() 
     else: 
      self.username.clear() 
      self.password.clear() 
      print("Invalid username and password.") 
    else: 
     self.username.clear() 
     self.password.clear() 
     print("Invalid username and password.") 

我想在用戶輸入正確的登錄詳細信息後關閉登錄窗口。該窗口嘗試關閉但凍結並且無響應。如何在pyQt4中打開另一個窗口(.py文件)後正確關閉窗口/小部件

This is what happens.

我的問題是我怎麼能關閉登錄形式,而不會引起它是反應遲鈍? (如果我的代碼示例是從那裏你可以瞭解這個問題缺乏的,請告訴我,謝謝!)

Unresponsive. I want it closed after the user enters the correct log in details.

+0

什麼是inventory.py? – eyllanesc

+0

inventory.py是另一個gui窗口,只有登錄成功才能訪問。 – lloydyu24

+1

試試我的答案。 – eyllanesc

回答

1

調用函數等待返回代碼,這樣強制關閉該啓動過程新應用程序會生成該行爲。您應該使用Popen而不是call

subprocess.Popen(['pythonw', path]) 
+0

它的工作!謝謝! @eyllanesc – lloydyu24

相關問題