我有这个代码:
def on_btn_login_clicked(self, widget):
email = self.log_email.get_text()
passw = self.log_pass.get_text()
self.lbl_status.set_text("Connecting ...")
params = urllib.urlencode({'@log_email': email, '@log_pass': passw, '@action': 'login', '@module': 'user'})
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("website.com")
self.lbl_status.set_text("Logging in ...")
conn.request("POST", "/ajax.php", params, headers)
response = conn.getresponse()
print response.status
self.lbl_status.set_text("")
data = response.read()
print data
conn.close()
在self.lbl_status
请求完成之前不会更改,因此由于最后一个set_text
功能,它不会显示任何内容。
为什么会发生这种情况,以及如何避免/解决这种情况?