本文整理汇总了Python中gtk.main_iteration方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.main_iteration方法的具体用法?Python gtk.main_iteration怎么用?Python gtk.main_iteration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.main_iteration方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def __init__(self, useGtk=True):
self._simtag = None
self._reads = set()
self._writes = set()
self._sources = {}
posixbase.PosixReactorBase.__init__(self)
# pre 2.3.91 the glib iteration and mainloop functions didn't release
# global interpreter lock, thus breaking thread and signal support.
if getattr(gobject, "pygtk_version", ()) >= (2, 3, 91) and not useGtk:
self.context = gobject.main_context_default()
self.__pending = self.context.pending
self.__iteration = self.context.iteration
self.loop = gobject.MainLoop()
self.__crash = self.loop.quit
self.__run = self.loop.run
else:
import gtk
self.__pending = gtk.events_pending
self.__iteration = gtk.main_iteration
self.__crash = _our_mainquit
self.__run = gtk.main
示例2: handle_gui_in_export
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def handle_gui_in_export(run_mode, image, layer, output_filepath, window):
should_manipulate_window = run_mode == gimpenums.RUN_INTERACTIVE
if should_manipulate_window:
window_position = window.get_position()
window.hide()
while gtk.events_pending():
gtk.main_iteration()
try:
yield
finally:
if should_manipulate_window:
window.move(*window_position)
window.show()
while gtk.events_pending():
gtk.main_iteration()
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def __init__(self, layer_tree, settings):
self._layer_tree = layer_tree
self._settings = settings
self._image = self._layer_tree.image
self._layer_exporter = None
self._settings.load([pg.config.SESSION_SOURCE])
self._init_gui()
pg.gui.set_gui_excepthook_parent(self._dialog)
gtk.main_iteration()
self.show()
self.export_layers()
示例4: update_view_timeout
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def update_view_timeout(self):
#print "view: update_view_timeout called at real time ", time.time()
# while the simulator is busy, run the gtk event loop
while not self.simulation.lock.acquire(False):
while gtk.events_pending():
gtk.main_iteration()
pause_messages = self.simulation.pause_messages
self.simulation.pause_messages = []
try:
self.update_view()
self.simulation.target_time = ns.core.Simulator.Now ().GetSeconds () + self.sample_period
#print "view: target time set to %f" % self.simulation.target_time
finally:
self.simulation.lock.release()
if pause_messages:
#print pause_messages
dialog = gtk.MessageDialog(parent=self.window, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK,
message_format='\n'.join(pause_messages))
dialog.connect("response", lambda d, r: d.destroy())
dialog.show()
self.play_button.set_active(False)
# if we're paused, stop the update timer
if not self.play_button.get_active():
self._update_timeout_id = None
return False
#print "view: self.simulation.go.set()"
self.simulation.go.set()
#print "view: done."
return True
示例5: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def __init__(self, useGtk=True):
self.context = gobject.main_context_default()
self.loop = gobject.MainLoop()
posixbase.PosixReactorBase.__init__(self)
# pre 2.3.91 the glib iteration and mainloop functions didn't release
# global interpreter lock, thus breaking thread and signal support.
if (hasattr(gobject, "pygtk_version") and gobject.pygtk_version >= (2, 3, 91)
and not useGtk):
self.__pending = self.context.pending
self.__iteration = self.context.iteration
self.__crash = self.loop.quit
self.__run = self.loop.run
else:
import gtk
self.__pending = gtk.events_pending
self.__iteration = gtk.main_iteration
self.__crash = _our_mainquit
self.__run = gtk.main
# The input_add function in pygtk1 checks for objects with a
# 'fileno' method and, if present, uses the result of that method
# as the input source. The pygtk2 input_add does not do this. The
# function below replicates the pygtk1 functionality.
# In addition, pygtk maps gtk.input_add to _gobject.io_add_watch, and
# g_io_add_watch() takes different condition bitfields than
# gtk_input_add(). We use g_io_add_watch() here in case pygtk fixes this
# bug.
示例6: _finish_init_and_show
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def _finish_init_and_show(self):
while gtk.events_pending():
gtk.main_iteration()
self._dialog.vbox.show_all()
self._show_hide_more_settings()
self._dialog.set_focus(self._file_extension_entry)
self._button_export.grab_default()
# Place the cursor at the end of the text entry.
self._file_extension_entry.set_position(-1)
self._dialog.show()
示例7: _progress_set_value_and_show_dialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def _progress_set_value_and_show_dialog(self, fraction):
self._progress_bar.set_fraction(fraction)
# Without this workaround, the main dialog would not appear until the export
# of the second layer.
if not self._dialog.get_mapped():
self._dialog.show()
while gtk.events_pending():
gtk.main_iteration()
示例8: _progress_set_fraction
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def _progress_set_fraction(self, fraction):
self._progress_bar.set_fraction(fraction)
while gtk.events_pending():
gtk.main_iteration()
示例9: _get_drag_icon_pixbuf
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def _get_drag_icon_pixbuf(self, widget, scrolled_window):
if widget.get_window() is None:
return
if (scrolled_window is not None
and self._are_items_partially_hidden_because_of_visible_horizontal_scrollbar(
scrolled_window)):
return None
self._setup_widget_to_add_border_to_drag_icon(widget)
while gtk.events_pending():
gtk.main_iteration()
widget_allocation = widget.get_allocation()
pixbuf = gtk.gdk.Pixbuf(
gtk.gdk.COLORSPACE_RGB,
False,
8,
widget_allocation.width,
widget_allocation.height)
drag_icon_pixbuf = pixbuf.get_from_drawable(
widget.get_window(),
widget.get_colormap(),
0,
0,
0,
0,
widget_allocation.width,
widget_allocation.height)
self._restore_widget_after_creating_drag_icon(widget)
return drag_icon_pixbuf
示例10: closetab
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def closetab(self, widget, label):
"""Close a tab"""
tabnum = None
try:
nb = widget.notebook
except AttributeError:
err('TabLabel::closetab: called on non-Notebook: %s' % widget)
return
for i in xrange(0, nb.get_n_pages() + 1):
if label == nb.get_tab_label(nb.get_nth_page(i)):
tabnum = i
break
if tabnum is None:
err('TabLabel::closetab: %s not in %s. Bailing.' % (label, nb))
return
maker = Factory()
child = nb.get_nth_page(tabnum)
if maker.isinstance(child, 'Terminal'):
dbg('Notebook::closetab: child is a single Terminal')
child.close()
# FIXME: We only do this del and return here to avoid removing the
# page below, which child.close() implicitly does
del(label)
return
elif maker.isinstance(child, 'Container'):
dbg('Notebook::closetab: child is a Container')
dialog = self.construct_confirm_close(self.window, _('tab'))
result = dialog.run()
dialog.destroy()
if result == gtk.RESPONSE_ACCEPT:
containers = None
objects = None
containers, objects = enumerate_descendants(child)
while len(objects) > 0:
descendant = objects.pop()
descendant.close()
while gtk.events_pending():
gtk.main_iteration()
return
else:
dbg('Notebook::closetab: user cancelled request')
return
else:
err('Notebook::closetab: child is unknown type %s' % child)
return
nb.remove_page(tabnum)
del(label)
示例11: take_screenshots
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def take_screenshots(gui, dialog, settings):
pg.path.make_dirs(OUTPUT_DIRPATH)
settings["gui_session/current_directory"].set_value(OUTPUT_DIRPATH)
settings["gui/show_more_settings"].set_value(False)
decoration_offsets = move_dialog_to_corner(dialog, settings)
#HACK: Accessing private members
gui._name_preview.set_selected_items(set([
gui._name_preview._layer_exporter.layer_tree["main-background"].item.ID]))
dialog.set_focus(gui._name_preview.tree_view)
while gtk.events_pending():
gtk.main_iteration()
take_and_process_screenshot(
SCREENSHOTS_DIRPATH,
SCREENSHOT_DIALOG_BASIC_USAGE_FILENAME,
settings,
decoration_offsets)
settings["gui/show_more_settings"].set_value(True)
operations.clear(settings["main/procedures"])
operations.clear(settings["main/constraints"])
operations.add(
settings["main/procedures"],
builtin_procedures.BUILTIN_PROCEDURES["insert_background_layers"])
operations.reorder(
settings["main/procedures"], "insert_background_layers", 0)
settings["main/procedures/added/use_layer_size/enabled"].set_value(False)
operations.add(
settings["main/constraints"],
builtin_constraints.BUILTIN_CONSTRAINTS["only_layers_without_tags"])
while gtk.events_pending():
gtk.main_iteration()
#HACK: Accessing private members
gui._name_preview.set_selected_items(set([
gui._name_preview._layer_exporter.layer_tree["bottom-frame"].item.ID]))
while gtk.events_pending():
gtk.main_iteration()
take_and_process_screenshot(
SCREENSHOTS_DIRPATH,
SCREENSHOT_DIALOG_CUSTOMIZING_EXPORT_FILENAME,
settings,
decoration_offsets)
gtk.main_quit()
示例12: on_terminal_keypress
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import main_iteration [as 别名]
def on_terminal_keypress(self, widget, event, *args):
if shortcuts.has_key(get_key_name(event)):
cmd = shortcuts[get_key_name(event)]
if type(cmd) == list:
#comandos predefinidos
if cmd == _COPY:
self.terminal_copy(widget)
elif cmd == _PASTE:
self.terminal_paste(widget)
elif cmd == _COPY_ALL:
self.terminal_copy_all(widget)
elif cmd == _SAVE:
self.show_save_buffer(widget)
elif cmd == _FIND:
self.get_widget('txtSearch').select_region(0, -1)
self.get_widget('txtSearch').grab_focus()
elif cmd == _FIND_NEXT:
if hasattr(self, 'search'):
self.find_word()
elif cmd == _CLEAR:
widget.reset(True, True)
elif cmd == _FIND_BACK:
if hasattr(self, 'search'):
self.find_word(backwards=True)
elif cmd == _CONSOLE_PREV:
widget.get_parent().get_parent().prev_page()
elif cmd == _CONSOLE_NEXT:
widget.get_parent().get_parent().next_page()
elif cmd == _CONSOLE_CLOSE:
wid = widget.get_parent()
page = widget.get_parent().get_parent().page_num(wid)
if page != -1:
widget.get_parent().get_parent().remove_page(page)
wid.destroy()
elif cmd == _CONSOLE_RECONNECT:
if not hasattr(widget, "command"):
widget.fork_command(SHELL)
else:
widget.fork_command(widget.command[0], widget.command[1])
while gtk.events_pending():
gtk.main_iteration(False)
#esperar 2 seg antes de enviar el pass para dar tiempo a que se levante expect y prevenir que se muestre el pass
if widget.command[2]!=None and widget.command[2]!='':
gobject.timeout_add(2000, self.send_data, widget, widget.command[2])
widget.get_parent().get_parent().get_tab_label(widget.get_parent()).mark_tab_as_active()
return True
elif cmd == _CONNECT:
self.on_btnConnect_clicked(None)
elif cmd[0][0:8] == "console_":
page = int(cmd[0][8:]) - 1
widget.get_parent().get_parent().set_current_page(page)
else:
#comandos del usuario
widget.feed_child(cmd)
return True
return False