本文整理汇总了Python中gtk.events_pending方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.events_pending方法的具体用法?Python gtk.events_pending怎么用?Python gtk.events_pending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.events_pending方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rotate
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def rotate(self, widget, clockwise):
"""Rotate children in this window"""
self.set_pos_by_ratio = True
maker = Factory()
# collect all paned children in breadth-first order
paned = []
for child in self.get_children():
if maker.isinstance(child, 'Paned'):
paned.append(child)
for p in paned:
for child in p.get_children():
if child not in paned and maker.isinstance(child, 'Paned'):
paned.append(child)
# then propagate the rotation
for p in paned:
p.rotate(widget, clockwise)
self.show_all()
widget.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
示例2: on_button_press
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def on_button_press(self, widget, event):
"""Handle button presses on a Pane"""
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
if event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK:
recurse_up=True
else:
recurse_up=False
if event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
recurse_down=True
else:
recurse_down=False
# FIXME: These idle events are creating a lot of weird issues
for i in range(3):
while gtk.events_pending():
gtk.main_iteration_do(False)
self.do_redistribute(recurse_up, recurse_down)
return True
else:
return False
示例3: do_redistribute
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def do_redistribute(self, recurse_up=False, recurse_down=False):
"""Evenly divide available space between sibling panes"""
#1 Find highest ancestor of the same type => ha
highest_ancestor = self
while type(highest_ancestor.get_parent()) == type(highest_ancestor):
highest_ancestor = highest_ancestor.get_parent()
# (1b) If Super modifier, redistribute higher sections too
if recurse_up:
grandfather=highest_ancestor.get_parent()
if grandfather != self.get_toplevel():
grandfather.do_redistribute(recurse_up, recurse_down)
gobject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
while gtk.events_pending():
gtk.main_iteration_do(False)
gobject.idle_add(highest_ancestor._do_redistribute, recurse_up, recurse_down)
示例4: doIteration
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def doIteration(self, delay):
# flush some pending events, return if there was something to do
# don't use the usual "while gtk.events_pending(): mainiteration()"
# idiom because lots of IO (in particular test_tcp's
# ProperlyCloseFilesTestCase) can keep us from ever exiting.
log.msg(channel='system', event='iteration', reactor=self)
if gtk.events_pending():
gtk.mainiteration(0)
return
# nothing to do, must delay
if delay == 0:
return # shouldn't delay, so just return
self.doIterationTimer = gtk.timeout_add(int(delay * 1000),
self.doIterationTimeout)
# This will either wake up from IO or from a timeout.
gtk.mainiteration(1) # block
# note: with the .simulate timer below, delays > 0.1 will always be
# woken up by the .simulate timer
if self.doIterationTimer:
# if woken by IO, need to cancel the timer
gtk.timeout_remove(self.doIterationTimer)
self.doIterationTimer = None
示例5: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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
示例6: handle_gui_in_export
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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()
示例7: split_axis
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def split_axis(self, widget, vertical=True, cwd=None, sibling=None, widgetfirst=True):
"""Split the window"""
if self.get_property('term_zoomed') == True:
err("You can't split while a terminal is maximised/zoomed")
return
order = None
maker = Factory()
self.remove(widget)
if vertical:
container = maker.make('VPaned')
else:
container = maker.make('HPaned')
self.set_pos_by_ratio = True
if not sibling:
sibling = maker.make('Terminal')
sibling.set_cwd(cwd)
sibling.spawn_child()
if widget.group and self.config['split_to_group']:
sibling.set_group(None, widget.group)
if self.config['always_split_with_profile']:
sibling.force_set_profile(None, widget.get_profile())
self.add(container)
container.show_all()
order = [widget, sibling]
if widgetfirst is False:
order.reverse()
for term in order:
container.add(term)
container.show_all()
sibling.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.set_pos_by_ratio = False
示例8: split_axis
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def split_axis(self, widget, vertical=True, cwd=None, sibling=None,
widgetfirst=True):
"""Default axis splitter. This should be implemented by subclasses"""
order = None
self.remove(widget)
if vertical:
container = VPaned()
else:
container = HPaned()
self.get_toplevel().set_pos_by_ratio = True
if not sibling:
sibling = self.maker.make('terminal')
sibling.set_cwd(cwd)
sibling.spawn_child()
if widget.group and self.config['split_to_group']:
sibling.set_group(None, widget.group)
if self.config['always_split_with_profile']:
sibling.force_set_profile(None, widget.get_profile())
self.add(container)
self.show_all()
order = [widget, sibling]
if widgetfirst is False:
order.reverse()
for terminal in order:
container.add(terminal)
self.show_all()
sibling.grab_focus()
while gtk.events_pending():
gtk.main_iteration_do(False)
self.get_toplevel().set_pos_by_ratio = False
示例9: update_view_timeout
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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
示例10: keypress
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def keypress(self, widget, event=None):
if event.keyval == 65307:
if not gtk.events_pending():
self.window.iconify()
self.window.hide()
time.sleep(15)
self.window.show()
self.window.deiconify()
self.window.present()
return True
示例11: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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.
示例12: _finish_init_and_show
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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()
示例13: _progress_set_value_and_show_dialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [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()
示例14: _progress_set_fraction
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def _progress_set_fraction(self, fraction):
self._progress_bar.set_fraction(fraction)
while gtk.events_pending():
gtk.main_iteration()
示例15: _force_update
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import events_pending [as 别名]
def _force_update(self):
# This is necessary for the GTK progress bar to be updated properly.
# See http://faq.pygtk.org/index.py?req=show&file=faq23.020.htp
while gtk.events_pending():
gtk.main_iteration()