本文整理汇总了Python中view.View.title方法的典型用法代码示例。如果您正苦于以下问题:Python View.title方法的具体用法?Python View.title怎么用?Python View.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import title [as 别名]
class Controller(IController):
def __init__(self):
DBusGMainLoop(set_as_default=True)
self.__description__ = None
self.__pipelinestatus__ = False
self.__plugins__ = {}
self.__view__ = View(self, None)
self.__bus__ = dbus.SessionBus()
self.__bus__.add_signal_receiver(self.__dbus_process_registration__,
dbus_interface = 'org.freedesktop.Voxgenerator',
signal_name = 'dbus_plugin_registration')
self.__bus__.add_signal_receiver(self.__dbus_process_pipeline_status__,
dbus_interface = 'org.freedesktop.Voxgenerator',
signal_name = 'dbus_pipeline_play')
self.__view__.title('Voxgenerator control')
self.__initializecontroller__()
gobject.idle_add(self.__updateview__)
self.__loop__ = gobject.MainLoop()
self.__loop__.run()
def __updateview__(self):
try:
self.__view__.update()
except:
self.__loop__.quit()
return True
def __initializecontroller__(self):
self.__bus__ = dbus.SessionBus()
""" initialize pipeline status """
try:
pipe = self.__bus__.get_object("org.freedesktop.Voxgenerator.Pipeline",
"/org/freedesktop/Voxgenerator/Pipeline")
description = pipe.dbus_pipeline_request_description()
""" update plugin """
self.set_current_description(description)
""" update description """
self.__pipelinestatus__ = pipe.dbus_pipeline_request_status()
except:
self.__pipelinestatus__ = False
self.__view__.set_description(self.__description__)
self.__view__.set_pipeline_status(self.__pipelinestatus__)
def __update_pipeline_status__(self):
if self.__pipelinestatus__ == False:
try:
pipe = self.__bus__.get_object("org.freedesktop.Voxgenerator.Pipeline",
"/org/freedesktop/Voxgenerator/Pipeline")
pipe.dbus_pipeline_request_stop()
except:
self.__view__.set_pipeline_status(False)
else:
try:
pipe = self.__bus__.get_object("org.freedesktop.Voxgenerator.Pipeline",
"/org/freedesktop/Voxgenerator/Pipeline")
pipe.dbus_pipeline_request_stop()
except:
print "No need to stop the pipeline !"
if self.__description__ is not None and os.path.isfile(self.__description__):
os.system("run_voxgenerator " + self.__description__ + " &")
else:
self.__view__.show_error("Before trying to start the pipeline, you should choose a valid pipeline xml file!")
self.__view__.set_pipeline_status(False)
def __update_plugins_list__(self):
if self.__description__ is not None and os.path.isfile(self.__description__):
pipeline_tree = etree.parse(self.__description__)
root = pipeline_tree.xpath("/pipelines")
includes = root[0].findall("include")
self.__plugins__.clear()
for f in includes:
plugin_xml = f.get("file")
if os.path.isfile(plugin_xml):
plugin_tree = etree.parse(plugin_xml)
plugins = plugin_tree.xpath("/plugins/plugin")
for plugin in plugins:
name = plugin.get("name")
if not self.__plugins__.has_key(name):
self.__plugins__[name] = False
def __update_plugin_status__(self):
for name in self.__plugins__:
try:
proxy = self.__bus__.get_object("org.freedesktop.Voxgenerator." + name,
"/org/freedesktop/Voxgenerator/" + name)
#.........这里部分代码省略.........
示例2: Controller
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import title [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
#.........这里部分代码省略.........