本文整理汇总了Python中gtk.EventBox方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.EventBox方法的具体用法?Python gtk.EventBox怎么用?Python gtk.EventBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.EventBox方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_box_hardware
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def add_box_hardware(self, title, text):
vboxframe = gtk.Frame()
vboxframe.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
vboxchild = gtk.Fixed()
vboxevent = gtk.EventBox()
vboxevent.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
vboxevent.add(vboxchild)
vboxframe.add(vboxevent)
vboxchildlabel1 = gtk.Label()
vboxchildlabel1.set_selectable(True)
vboxchildlabel1.set_markup("<b>" + title + "</b>")
vboxchild.put(vboxchildlabel1, 5, 5)
vboxchildlabel2 = gtk.Label()
vboxchildlabel2.set_selectable(True)
vboxchildlabel2.set_text('\n'.join(text) + "\n")
vboxchild.put(vboxchildlabel2, 5, 35)
self.wine.builder.get_object("hosttablehw").add(vboxframe)
self.wine.builder.get_object("hosttablehw").show_all()
示例2: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, text = ""):
""" Class initialiser"""
gtk.EventBox.__init__(self)
self.__gobject_init__()
self._entry_handler_id = []
self._label = gtk.Label(text)
self._custom = False
self.set_visible_window (False)
self.add (self._label)
self.connect ("button-press-event", self._on_click_text)
示例3: fill_custom_fields_table
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def fill_custom_fields_table(self, add=False):
pool_ref = self.xc_servers[self.selected_host].all['pool'].keys()[0]
self.vboxchildtext = {}
if "XenCenter.CustomFields" in self.xc_servers[self.selected_host].all['pool'][pool_ref]["gui_config"]:
for ch in self.builder.get_object("vboxcustomfields").get_children():
self.builder.get_object("vboxcustomfields").remove(ch)
dom = xml.dom.minidom.parseString(
self.xc_servers[self.selected_host].all['pool'][pool_ref]["gui_config"]["XenCenter.CustomFields"])
for node in dom.getElementsByTagName("CustomFieldDefinition"):
name = node.attributes.getNamedItem("name").value
if name not in self.vboxchildtext:
vboxframe = gtk.Frame()
vboxframe.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
vboxframe.set_size_request(500, 30)
vboxchild = gtk.Fixed()
vboxchild.set_size_request(500, 30)
vboxevent = gtk.EventBox()
vboxevent.add(vboxchild)
vboxchildlabel = gtk.Label()
vboxchildlabel.set_selectable(True)
vboxchildlabel.set_label(name)
vboxchild.put(vboxchildlabel, 5, 5)
self.vboxchildtext[name] = gtk.Entry()
self.vboxchildtext[name].set_size_request(200, 20)
vboxchild.put(self.vboxchildtext[name], 300, 5)
vboxevent.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
self.builder.get_object("vboxcustomfields").pack_start(vboxevent, False, False, 0)
self.builder.get_object("vboxcustomfields").show_all()
if add:
self.set_custom_fields_values()
示例4: _makeWidgetObject
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def _makeWidgetObject(self):
"""Make the GTK widget object that is me.
Called by __init__ to construct the GtkObject I wrap-- the ._o
member of a pygtk GtkObject. Isn't subclassing GtkObjects in
Python fun?
"""
ebox = gtk.EventBox()
label = gtk.Label(self.getTextForLabel())
label.set_alignment(0,0)
ebox.add(label)
return ebox._o
示例5: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, item_widget):
self._item_widget = item_widget
self._hbox = gtk.HBox(homogeneous=False)
self._hbox.set_spacing(self._HBOX_SPACING)
self._hbox_buttons = gtk.HBox(homogeneous=False)
self._hbox_buttons.set_spacing(self._HBOX_BUTTONS_SPACING)
self._event_box_buttons = gtk.EventBox()
self._event_box_buttons.add(self._hbox_buttons)
self._hbox.pack_start(self._item_widget, expand=True, fill=True)
self._hbox.pack_start(self._event_box_buttons, expand=False, fill=False)
self._event_box = gtk.EventBox()
self._event_box.add(self._hbox)
self._has_hbox_buttons_focus = False
self._button_remove = gtk.Button()
self._setup_item_button(self._button_remove, gtk.STOCK_CLOSE)
self._event_box.connect("enter-notify-event", self._on_event_box_enter_notify_event)
self._event_box.connect("leave-notify-event", self._on_event_box_leave_notify_event)
self._is_event_box_allocated_size = False
self._buttons_allocation = None
self._event_box.connect("size-allocate", self._on_event_box_size_allocate)
self._event_box_buttons.connect(
"size-allocate", self._on_event_box_buttons_size_allocate)
self._event_box.show_all()
self._hbox_buttons.set_no_show_all(True)
示例6: get_splash
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def get_splash():
splash = gtk.Window(gtk.WINDOW_TOPLEVEL)
splash.set_events(splash.get_events() | gtk.gdk.BUTTON_PRESS_MASK)
def f(widget, data=None):
splash.destroy()
splash.connect('button_press_event', f)
eb = gtk.EventBox()
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
image = gtk.Image()
image.show()
image.set_from_file(os.path.join(rpy2.__path__[0], "images", "rpy2_logo.png"))
splashVBox = gtk.VBox()
splashVBox.pack_start(image, True, True, 0)
splashVBox.pack_start(gtk.Label("A GTK+ toy user interface"),
True, True, 0)
eb.add(splashVBox)
splash.add(eb)
splash.realize()
splash.window.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)
# needed on Win32
splash.set_decorated (False)
splash.set_position (gtk.WIN_POS_CENTER)
return splash
示例7: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, title, owner_, widget_, popup_):
gtk.HBox.__init__(self, False, 0)
self.title = title
self.owner = owner_
self.eb = gtk.EventBox()
label = self.label = gtk.Label()
self.eb.connect('button-press-event', self.popupmenu, label)
label.set_alignment(0.0, 0.5)
label.set_text(title)
self.eb.add(label)
self.pack_start(self.eb)
label.show()
self.eb.show()
close_image = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
image_w, image_h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
self.widget=widget_
self.popup = popup_
close_btn = gtk.Button()
close_btn.set_relief(gtk.RELIEF_NONE)
close_btn.connect('clicked', self.on_close_tab, owner_)
close_btn.set_size_request(image_w+7, image_h+6)
close_btn.add(close_image)
style = close_btn.get_style();
self.eb2 = gtk.EventBox()
self.eb2.add(close_btn)
self.pack_start(self.eb2, False, False)
self.eb2.show()
close_btn.show_all()
self.is_active = True
self.show()
示例8: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, terminal):
"""Class initialiser"""
gtk.EventBox.__init__(self)
self.__gobject_init__()
self.terminator = Terminator()
self.terminal = terminal
self.config = self.terminal.config
self.label = EditableLabel()
self.label.connect('edit-done', self.on_edit_done)
self.ebox = gtk.EventBox()
grouphbox = gtk.HBox()
self.grouplabel = gtk.Label()
self.groupicon = gtk.Image()
self.bellicon = gtk.Image()
self.bellicon.set_no_show_all(True)
self.groupentry = gtk.Entry()
self.groupentry.set_no_show_all(True)
self.groupentry.connect('focus-out-event', self.groupentry_cancel)
self.groupentry.connect('activate', self.groupentry_activate)
self.groupentry.connect('key-press-event', self.groupentry_keypress)
groupsend_type = self.terminator.groupsend_type
if self.terminator.groupsend == groupsend_type['all']:
icon_name = 'all'
elif self.terminator.groupsend == groupsend_type['group']:
icon_name = 'group'
elif self.terminator.groupsend == groupsend_type['off']:
icon_name = 'off'
self.set_from_icon_name('_active_broadcast_%s' % icon_name,
gtk.ICON_SIZE_MENU)
grouphbox.pack_start(self.groupicon, False, True, 2)
grouphbox.pack_start(self.grouplabel, False, True, 2)
grouphbox.pack_start(self.groupentry, False, True, 2)
self.ebox.add(grouphbox)
self.ebox.show_all()
self.bellicon.set_from_icon_name('terminal-bell', gtk.ICON_SIZE_MENU)
hbox = gtk.HBox()
hbox.pack_start(self.ebox, False, True, 0)
hbox.pack_start(gtk.VSeparator(), False, True, 0)
hbox.pack_start(self.label, True, True)
hbox.pack_end(self.bellicon, False, False, 2)
self.add(hbox)
hbox.show_all()
self.set_no_show_all(True)
self.show()
self.connect('button-press-event', self.on_clicked)
示例9: on_drag_motion
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def on_drag_motion(self, widget, drag_context, x, y, _time, _data):
"""*shrug*"""
if not drag_context.targets == ['vte'] and \
(gtk.targets_include_text(drag_context.targets) or \
gtk.targets_include_uri(drag_context.targets)):
# copy text from another widget
return
srcwidget = drag_context.get_source_widget()
if(isinstance(srcwidget, gtk.EventBox) and
srcwidget == self.titlebar) or widget == srcwidget:
# on self
return
alloc = widget.allocation
rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height)
if self.config['use_theme_colors']:
color = self.vte.get_style().text[gtk.STATE_NORMAL]
else:
color = gtk.gdk.color_parse(self.config['foreground_color'])
pos = self.get_location(widget, x, y)
topleft = (0, 0)
topright = (alloc.width, 0)
topmiddle = (alloc.width/2, 0)
bottomleft = (0, alloc.height)
bottomright = (alloc.width, alloc.height)
bottommiddle = (alloc.width/2, alloc.height)
middleleft = (0, alloc.height/2)
middleright = (alloc.width, alloc.height/2)
#print "%f %f %d %d" %(coef1, coef2, b1,b2)
coord = ()
if pos == "right":
coord = (topright, topmiddle, bottommiddle, bottomright)
elif pos == "top":
coord = (topleft, topright, middleright , middleleft)
elif pos == "left":
coord = (topleft, topmiddle, bottommiddle, bottomleft)
elif pos == "bottom":
coord = (bottomleft, bottomright, middleright , middleleft)
#here, we define some widget internal values
widget._expose_data = { 'color': color, 'coord' : coord }
#redraw by forcing an event
connec = widget.connect_after('expose-event', self.on_expose_event)
widget.window.invalidate_rect(rect, True)
widget.window.process_updates(True)
#finaly reset the values
widget.disconnect(connec)
widget._expose_data = None
示例10: on_drag_data_received
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def on_drag_data_received(self, widget, drag_context, x, y, selection_data,
_info, _time, data):
"""Something has been dragged into the terminal. Handle it as either a
URL or another terminal."""
dbg('drag data received of type: %s' % selection_data.type)
if gtk.targets_include_text(drag_context.targets) or \
gtk.targets_include_uri(drag_context.targets):
# copy text to destination
txt = selection_data.data.strip(' ')
if txt[0:7] == 'file://':
txt = "'%s'" % urllib.unquote(txt[7:])
else:
txt = txt.split('\n')[0]
for term in self.terminator.get_target_terms(self):
term.feed(txt)
return
widgetsrc = data.terminator.terminals[int(selection_data.data)]
srcvte = drag_context.get_source_widget()
#check if computation requireds
if (isinstance(srcvte, gtk.EventBox) and
srcvte == self.titlebar) or srcvte == widget:
return
srchbox = widgetsrc
# The widget argument is actually a vte.Terminal(). Turn that into a
# terminatorlib Terminal()
maker = Factory()
while True:
widget = widget.get_parent()
if not widget:
# We've run out of widgets. Something is wrong.
err('Failed to find Terminal from vte')
return
if maker.isinstance(widget, 'Terminal'):
break
dsthbox = widget
dstpaned = dsthbox.get_parent()
srcpaned = srchbox.get_parent()
pos = self.get_location(widget, x, y)
srcpaned.remove(widgetsrc)
dstpaned.split_axis(dsthbox, pos in ['top', 'bottom'], None, widgetsrc, pos in ['bottom', 'right'])
srcpaned.hoover()
widgetsrc.ensure_visible_and_focussed()
示例11: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, width, height):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(0)
self.window.set_size_request(width, height + 30)
self.window.set_app_paintable(True)
self.screen = self.window.get_screen()
self.rgba = self.screen.get_rgba_colormap()
self.window.set_colormap(self.rgba)
self.window.connect('expose-event', self.expose)
self.vbox = gtk.VBox(False, 5)
self.hbox = gtk.HBox(False, 3)
self.bbox = gtk.HBox(True, 3)
self.entry = gtk.Entry()
self.entry.set_max_length(0)
self.entry.set_size_request(int(width/2), 25)
self.entry.connect("activate", self.enter_callback, self.entry)
self.spr = gtk.ToggleButton(label='spr')
self.spr.connect("toggled", self.on_button_toggled, 'spr')
self.ctrl = gtk.ToggleButton(label='ctrl')
self.ctrl.connect("toggled", self.on_button_toggled, 'ctrl')
self.alt = gtk.ToggleButton(label='alt')
self.alt.connect("toggled", self.on_button_toggled, 'alt')
self.enter = gtk.Button(label='Enter')
self.enter.connect("clicked", self.on_enter_clicked)
self.backspace = gtk.Button(label='Backspace')
self.backspace.connect("clicked", self.on_backspace_clicked)
self.shell = gtk.Button(label='R-Shell')
self.shell.connect("clicked", self.on_shell_clicked, self.entry)
self.hbox.add(self.entry)
self.bbox.add(self.spr)
self.bbox.add(self.ctrl)
self.bbox.add(self.alt)
self.bbox.add(self.enter)
self.bbox.add(self.backspace)
self.bbox.add(self.shell)
self.hbox.add(self.bbox)
self.halign = gtk.Alignment(1, 0, 1, 0)
self.halign.add(self.hbox)
self.allalign = gtk.Alignment(0, 0, 1, 1)
self.clickbox = gtk.EventBox()
self.clickbox.connect('button-press-event', self.on_click)
self.clickbox.set_visible_window(False)
self.allalign.add(self.clickbox)
self.vbox.pack_start(self.allalign, True, True, 0)
self.vbox.pack_end(self.halign, False, False, 0)
self.window.add(self.vbox)
self.window.show_all()
self.window.move(100, 100)
示例12: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, explorer, rootGroup, canvas):
"""Place a new Visage of an explorer in a canvas group.
I also need a 'canvas' reference is for certain coordinate
conversions, and pygnome doesn't give access to my GtkObject's
.canvas attribute. :(
"""
# Ugh. PyGtk/GtkObject/GnomeCanvas interfacing grits.
gnome.CanvasGroup.__init__(self,
_obj = rootGroup.add('group')._o)
self.propertyLabels = PairList()
reflect.accumulateClassList(self.__class__, 'propertyLabels',
self.propertyLabels)
self.groupLabels = PairList()
reflect.accumulateClassList(self.__class__, 'groupLabels',
self.groupLabels)
self.explorer = explorer
self.identifier = explorer.identifier
self.objectId = explorer.id
self.canvas = canvas
self.rootGroup = rootGroup
self.ebox = gtk.EventBox()
self.ebox.set_name("Visage")
self.frame = gtk.Frame(self.identifier)
self.container = gtk.VBox()
self.ebox.add(self.frame)
self.frame.add(self.container)
self.canvasWidget = self.add('widget', widget=self.ebox,
x=0, y=0, anchor=gtk.ANCHOR_NW,
size_pixels=0)
self.border = self.add('rect', x1=0, y1=0,
x2=1, y2=1,
fill_color=None,
outline_color=self.color['border'],
width_pixels=self.border_width)
self.subtable = {}
self._setup_table()
# TODO:
# Collapse me
# Movable/resizeable me
# Destroy me
# Set my detail level
self.frame.connect("size_allocate", self.signal_size_allocate,
None)
self.connect("destroy", self.signal_destroy, None)
self.connect("event", self.signal_event)
self.ebox.show_all()
# Our creator will call our fill_ methods when she has the goods.
示例13: _init_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def _init_gui(self):
self._dialog = gimpui.Dialog(
title="",
role=None,
parent=self._parent,
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
self._dialog.set_transient_for(self._parent)
self._dialog.set_title(self._title)
self._dialog.set_border_width(self._DIALOG_BORDER_WIDTH)
self._dialog.set_resizable(False)
self._dialog_icon = gtk.Image()
self._dialog_icon.set_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
self._dialog_text = gtk.Label("")
self._dialog_text.set_line_wrap(True)
self._dialog_text.set_use_markup(True)
self._dialog_text_event_box = gtk.EventBox()
self._dialog_text_event_box.add(self._dialog_text)
self._hbox_dialog_contents = gtk.HBox(homogeneous=False)
self._hbox_dialog_contents.set_spacing(self._DIALOG_HBOX_CONTENTS_SPACING)
self._hbox_dialog_contents.pack_start(self._dialog_icon, expand=False, fill=False)
self._hbox_dialog_contents.pack_start(
self._dialog_text_event_box, expand=False, fill=False)
self._checkbutton_apply_to_all = gtk.CheckButton(
label=_("_Apply action to all files"))
self._checkbutton_apply_to_all.set_use_underline(True)
self._dialog.vbox.set_spacing(self._DIALOG_VBOX_SPACING)
self._dialog.vbox.pack_start(self._hbox_dialog_contents, expand=False, fill=False)
self._dialog.vbox.pack_start(self._checkbutton_apply_to_all, expand=False, fill=False)
self._buttons = {}
for value, display_name in self.values_and_display_names:
self._buttons[value] = self._dialog.add_button(display_name, value)
self._dialog.action_area.set_spacing(self._DIALOG_ACTION_AREA_SPACING)
self._checkbutton_apply_to_all.connect(
"toggled", self._on_checkbutton_apply_to_all_toggled)
self._is_dialog_text_allocated_size = False
self._dialog_text_event_box.connect(
"size-allocate", self._on_dialog_text_event_box_size_allocate)
self._dialog.set_focus(self._buttons[self.default_value])
示例14: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import EventBox [as 别名]
def __init__(self, inifile, width, height):
gobject.GObject.__init__(self)
super(HazzyGremlin, self).__init__(inifile)
self.width = width
self.height = height
self.percent = 0
self.mouse_mode = None
self.zoom_in_pressed = False
self.zoom_out_pressed = False
self.set_display_units('in')
# Gremlin3D width = width - 40 to allow room for the controls
self.set_size_request(self.width - 40, self.height)
# Add gremlin back-plot
self.gremlin_view = gtk.HBox()
fixed = gtk.Fixed()
fixed.put(self, 0, 0)
self.gremlin_view.add(fixed)
self.connect('button_press_event', self.on_gremlin_clicked)
# Add touchscreen controls
gladefile = os.path.join(UIDIR, 'controls.glade')
self.builder = gtk.Builder()
self.builder.add_from_file(gladefile)
self.builder.connect_signals(self)
controls = self.builder.get_object('controls')
controls.set_size_request(40, self.height)
self.gremlin_view.add(controls)
# Add progress label
self.label = gtk.Label()
self.label.modify_font(pango.FontDescription('FreeSans 11'))
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('White'))
labelbox = gtk.EventBox()
labelbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('Black'))
labelbox.set_size_request(-1, 20)
labelbox.add(self.label)
fixed.put(labelbox, 0 , self.height - 20)
# def fileloading(self, current_line):
# self.progressbar.show()
# percent = current_line * 100 / self.line_count
# if self.percent != percent:
# self.percent = percent
# msg = "Generating preview {}%".format(self.percent)
# self.progressbar.set_text(msg)
# self.progressbar.set_fraction(self.percent / 100)
# log.debug(msg)
# self.emit('loading_progress', percent)