def sync_get(name, interval=0.5): with Connection(BROKER_URI) as conn: publish(conn, name) while 1: rs = r.get(name) if rs and Backend.from_json(cPickle.loads(rs)).status == SUCCESS: break time.sleep(interval) item = Backend.get(name) return item.result
def GetPoint(self, address, API_KEY): dict_point = Backend().exec(address, API_KEY) point_loud = dict_point.get('住宅安寧') point_traffic = dict_point.get('交通安全') point_hygiene = dict_point.get('衛生') point_residence = dict_point.get('住宅安全') if point_residence == True: str_residence = "是" else: str_residence = "否" # 跨class取值:self.controller.get_page('ResultPage'),放到另一頁ResultPage # 這些按紐隨address變動,按下Enter後,才會在ResultPage建立有分數的按鈕。 button_index_loud = tk.Button(self.controller.get_page('Resultpage'), text=("%s" % point_loud), bg = '#112F41', fg = '#ED553B', font= ('Noto Sans CJK TC Bold', 40), width = 5, command=Hit_loud) button_index_loud.place(x = 630, y = 165, anchor = 'center') button_index_traffic = tk.Button(self.controller.get_page('Resultpage'), text=("%s" % point_traffic), bg = '#112F41', fg = '#ED553B', font= ('Noto Sans CJK TC Bold', 40), width = 5, command=Hit_traffic) button_index_traffic.place(x = 850, y = 165, anchor = 'center') button_index_hygiene = tk.Button(self.controller.get_page('Resultpage'), text=("%s" % point_hygiene), bg = '#112F41', fg = '#ED553B', font= ('Noto Sans CJK TC Bold', 40), width = 5, command=Hit_hygiene) button_index_hygiene.place(x = 630, y = 340, anchor = 'center') button_index_residence = tk.Button(self.controller.get_page('Resultpage'), text=("%s" % str_residence), bg = '#112F41', fg = '#ED553B', font= ('Noto Sans CJK TC Bold', 40), width = 5, command=Hit_residence) button_index_residence.place(x = 850, y = 340, anchor = 'center')