本文整理汇总了Python中gi.repository.Gtk.main_level方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.main_level方法的具体用法?Python Gtk.main_level怎么用?Python Gtk.main_level使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.main_level方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: quit
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def quit(self):
"""Gracefully shut down application."""
try:
self._pa_mgr.close()
except AttributeError:
pass
if Gtk.main_level() > 0:
try:
self._preferences.response(0)
except AttributeError:
pass
try:
self._about_win.close()
except AttributeError:
pass
Gtk.main_quit()
else:
sys.exit(1)
示例2: mainloop
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def mainloop(self):
if Gtk.main_level() == 0:
Gtk.main()
示例3: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def destroy(self, *args):
if _debug: print 'FigureManagerGTK3.%s' % fn_name()
self.vbox.destroy()
self.window.destroy()
self.canvas.destroy()
if self.toolbar:
self.toolbar.destroy()
self.__dict__.clear() #Is this needed? Other backends don't have it.
if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
Gtk.main_level() >= 1:
Gtk.main_quit()
示例4: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def destroy(self, *args):
self.vbox.destroy()
self.window.destroy()
self.canvas.destroy()
if self.toolbar:
self.toolbar.destroy()
if (Gcf.get_num_fig_managers() == 0 and
not matplotlib.is_interactive() and
Gtk.main_level() >= 1):
Gtk.main_quit()
示例5: mainloop
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def mainloop():
if Gtk.main_level() == 0:
Gtk.main()
示例6: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def destroy(self, *args):
if _debug: print('FigureManagerGTK3.%s' % fn_name())
self.vbox.destroy()
self.window.destroy()
self.canvas.destroy()
if self.toolbar:
self.toolbar.destroy()
if Gcf.get_num_fig_managers()==0 and \
not matplotlib.is_interactive() and \
Gtk.main_level() >= 1:
Gtk.main_quit()
示例7: stop_gtk
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def stop_gtk():
# shutdown twisted correctly
if reactor_required():
from twisted.internet import reactor
if reactor.running:
reactor.callFromThread(reactor.stop)
# Twisted can be imported without the reactor being used
# => check if GTK main loop is running
elif Gtk.main_level() > 0:
GLib.idle_add(Gtk.main_quit)
else:
GLib.idle_add(Gtk.main_quit)
# Run the GTK loop until no more events are being generated and thus the GUI is fully destroyed
wait_for_gui()
示例8: show
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def show(self):
self.window.show_all()
if gtk.main_level() == 0:
if self.pywebview_window.hidden:
self.window.hide()
gtk.main()
else:
glib.idle_add(self.window.show_all)
示例9: evaluate_js
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def evaluate_js(self, script):
def _evaluate_js():
callback = None if old_webkit else _callback
self.webview.run_javascript(script, None, callback, None)
def _callback(webview, task, data):
value = webview.run_javascript_finish(task)
if value:
self.js_results[unique_id]['result'] = value.get_js_value().to_string()
else:
self.js_results[unique_id]['result'] = None
result_semaphore.release()
unique_id = uuid1().hex
result_semaphore = Semaphore(0)
self.js_results[unique_id] = {'semaphore': result_semaphore, 'result': None}
if old_webkit:
script = 'document.title = JSON.stringify({{"type": "eval", "uid": "{0}", "result": {1}}})'.format(unique_id, script)
self.loaded.wait()
glib.idle_add(_evaluate_js)
result_semaphore.acquire()
if not gtk.main_level():
# Webview has been closed, don't proceed
return None
result = self.js_results[unique_id]['result']
result = None if result == 'undefined' or result == 'null' or result is None else result if result == '' else json.loads(result)
del self.js_results[unique_id]
return result
示例10: _on_destroy_window
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def _on_destroy_window(self, window):
self.remove_window(window)
if not self._windows:
from gi.repository import Gtk
logger.debug('Last toplevel destroyed, quit')
if Gtk.main_level() > 0:
Gtk.main_quit()
示例11: _setup_signal_handling
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def _setup_signal_handling(self):
def handle_sigterm(signal, frame):
from gi.repository import Gtk
logger.info('Got SIGTERM, quit')
if Gtk.main_level() > 0:
Gtk.main_quit()
signal.signal(signal.SIGTERM, handle_sigterm)
示例12: quit
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def quit(self):
'''Menu action for quit.
@emits: quit
'''
if Gtk.main_level() > 0:
Gtk.main_quit()
# We expect the application to call "destroy" on all windows once
# it is bumped out of the main loop
示例13: do_quit
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import main_level [as 别名]
def do_quit(self):
'''Quit zim.'''
if Gtk.main_level() > 0:
Gtk.main_quit()