本文整理汇总了Python中view.View.protocol方法的典型用法代码示例。如果您正苦于以下问题:Python View.protocol方法的具体用法?Python View.protocol怎么用?Python View.protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.protocol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import protocol [as 别名]
class Controller():
def __init__(self):
self.logger = logging.getLogger('main.controller.Controller')
self.view = View()
self.view.protocol('WM_DELETE_WINDOW', self.close_app)
self.queue_view = QueueView()
self.queue_view.hide()
self.query_status = {}
self._error = False
self.view.btn_run.config(command=self.export_query_results)
self.view.btn_sql.config(command=self.export_sql_statement)
self.view.btn_reset.config(command=self.reset_view)
self.view.btn_output.config(command=self.open_output_folder)
self.view.btn_queue_window.config(command=self.show_queue_window)
self.view.btn_clean_up.config(command=self.clean_up_output_folder)
# add custom icons
icon_path = find_data_file('app.ico')
self.view.iconbitmap(icon_path)
self.queue_view.iconbitmap(icon_path)
self.view['bg'] = 'dark slate grey'
self.view.title('Claim Explorer')
center_window(self.view, width_expand=4, height_expand=100
, x_offset=0, y_offset=-100)
self.view.resizable(0, 0)
self.view.bind('<Return>', self.export_query_results)
self.queue = Queue(10) # cap at 10 threads
# self.threads = []
self.monitoring_queries = True
self.refresh_query_status()
self.view.mainloop(0)
def close_app(self):
self.logger.info('Closing application...')
try:
self.monitoring_queries = False
# self.queue.join()
self.logger.debug('Items remaining in queue: '
+ str(self.queue.qsize()))
self.queue_view.close()
self.view.destroy()
sys.exit(0)
except Exception as e:
self.logger.error(str(e))
sys.exit(1)
@property
def error(self):
if not self._error:
self.view.status.set('Ready...')
return self._error
@error.setter
def error(self, message):
"""
Args:
message: str
"""
if message is not None \
and message != 'Ready...' \
and len(message) > 0:
self.logger.error(message)
self.view.status.set(message)
self._error = True
def check_connection(self, tbl, pw):
con = Connection(table=tbl, password=pw)
con.open()
if con.status is not None:
self.error = con.status
return False
con.close()
return True
def export_to_csv_callback(self, task):
self.logger.info(task.result())
result = task.result()
for key, val in result.items():
self.query_status[key] = val
self.queue_view.set_data(self.query_status)
def callback(self, name, start, finish, result):
self.logger.info(name + ' returned ' + str(result))
self.query_status[name] = (start, finish, result)
def export_query_results(self):
self.logger.debug('Validating query parameters')
if not self.validate_query_parameters():
return False
if not self.check_for_password():
return False
#.........这里部分代码省略.........