本文整理汇总了Python中gtk.Widget方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.Widget方法的具体用法?Python gtk.Widget怎么用?Python gtk.Widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.Widget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cb_expose_event
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def _cb_expose_event(self, widget, event):
"""
This method is called when an instance of Chart receives
the gtk expose_event.
@type widget: gtk.Widget
@param widget: The widget that received the event.
@type event: gtk.Event
@param event: The event.
"""
self.context = widget.window.cairo_create()
self.context.rectangle(event.area.x, event.area.y, \
event.area.width, event.area.height)
self.context.clip()
self.draw(self.context)
return False
示例2: signal_buttonPressEvent
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def signal_buttonPressEvent(self, widget, eventButton, unused_data):
if eventButton.type == GDK._2BUTTON_PRESS:
if self.parent.canvas.visages.has_key(self.explorer.id):
visage = self.parent.canvas.visages[self.explorer.id]
else:
visage = self.explorer.newVisage(self.parent.rootGroup,
self.parent.canvas)
(x, y, w, h) = self.get_allocation()
wx, wy = self.parent.canvas.c2w(x, y)
x1, y1, x2, y2 = self.parent.get_bounds()
v_x1, v_y1, v_x2, v_y2 = visage.get_bounds()
visage.move(x2 - v_x1, wy + y1 - v_y1)
#### Widget-specific subclasses of Explorer, Visage, and Attribute
# Instance
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def __init__(self, dheight=300, dwidth=20):
self._dheight = dheight
self._dwidth = dwidth
gtk.Widget.__init__(self)
self._layout = self.create_pango_layout("")
示例4: onKeyPressExtend
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def onKeyPressExtend(self, event):
'''
Key press callback with plenty of shell goodness, like history,
autocompletions, etc.
@param widget: Widget that key press occured in.
@type widget: gtk.Widget
@param event: Event object.
@type event: gtk.gdk.Event
@return: True if event should not trickle.
@rtype: boolean
'''
if event.state & gtk.gdk.CONTROL_MASK and event.keyval == 99:
self.interrupt = True
self._processLine()
return True
elif event.keyval == gtk.keysyms.Return:
self._processLine()
return True
elif event.keyval == gtk.keysyms.Up:
self.changeLine(self.historyBack())
return True
elif event.keyval == gtk.keysyms.Down:
self.changeLine(self.historyForward())
return True
elif event.keyval == gtk.keysyms.Tab:
if not self.getCurrentLine().strip():
return False
completed, possibilities = self.complete(self.getCurrentLine())
if len(possibilities) > 1:
slice = self.getCurrentLine()
self.write('\n')
for symbol in possibilities:
self.write(symbol+'\n')
self.showPrompt(self.prompt)
self.changeLine(completed or slice)
return True
示例5: newAttributeWidget
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def newAttributeWidget(self, group):
"""Make a new attribute item for my object.
Returns a gtk.Widget.
"""
klass = spelunkerClassTable.get(self.explorerClass, None)
if (not klass) or (klass[1] is None):
log.msg("%s not in table, using generic" % self.explorerClass)
klass = GenericAttributeWidget
else:
klass = klass[1]
return klass(self, group)
示例6: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def __init__(self, explorer, parent):
"""A new AttributeWidget describing an explorer.
"""
self.parent = parent
self.explorer = explorer
self.identifier = explorer.identifier
self.id = explorer.id
widgetObj = self._makeWidgetObject()
gtk.Widget.__init__(self, _obj=widgetObj)
self.set_name("AttributeValue")
self.connect("destroy", self.signal_destroy, None)
self.connect("button-press-event", self.signal_buttonPressEvent,
None)
示例7: get_toplevel_window
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def get_toplevel_window(widget):
"""
Return the toplevel window (`gtk.Window`) for the specified widget
(`gtk.Widget`). If the widget has no toplevel window, return None.
"""
toplevel_widget = widget.get_toplevel()
if toplevel_widget.flags() & gtk.TOPLEVEL:
return toplevel_widget
else:
return None
示例8: onKeyPress
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Widget [as 别名]
def onKeyPress(self, widget, event):
'''
Key press callback used for correcting behavior for console-like
interfaces. For example 'home' should go to prompt, not to begining of
line.
@param widget: Widget that key press accored in.
@type widget: gtk.Widget
@param event: Event object
@type event: gtk.gdk.Event
@return: Return True if event should not trickle.
@rtype: boolean
'''
insert_mark = self.text_buffer.get_insert()
insert_iter = self.text_buffer.get_iter_at_mark(insert_mark)
selection_mark = self.text_buffer.get_selection_bound()
selection_iter = self.text_buffer.get_iter_at_mark(selection_mark)
start_iter = self.text_buffer.get_iter_at_mark(self.line_start)
if event.keyval == gtk.keysyms.Home:
if event.state & gtk.gdk.CONTROL_MASK or event.state & gtk.gdk.MOD1_MASK:
pass
elif event.state & gtk.gdk.SHIFT_MASK:
self.text_buffer.move_mark(insert_mark, start_iter)
return True
else:
self.text_buffer.place_cursor(start_iter)
return True
elif event.keyval == gtk.keysyms.Left:
insert_iter.backward_cursor_position()
if not insert_iter.editable(True):
return True
elif not event.string:
pass
elif start_iter.compare(insert_iter) <= 0 and \
start_iter.compare(selection_iter) <= 0:
pass
elif start_iter.compare(insert_iter) > 0 and \
start_iter.compare(selection_iter) > 0:
self.text_buffer.place_cursor(start_iter)
elif insert_iter.compare(selection_iter) < 0:
self.text_buffer.move_mark(insert_mark, start_iter)
elif insert_iter.compare(selection_iter) > 0:
self.text_buffer.move_mark(selection_mark, start_iter)
return self.onKeyPressExtend(event)