本文整理汇总了Python中gi.repository.Gtk.SeparatorToolItem方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.SeparatorToolItem方法的具体用法?Python Gtk.SeparatorToolItem怎么用?Python Gtk.SeparatorToolItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.SeparatorToolItem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_toolbar
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def _init_toolbar(self):
self.set_style(Gtk.ToolbarStyle.ICONS)
basedir = os.path.join(rcParams['datapath'],'images')
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.insert( Gtk.SeparatorToolItem(), -1 )
continue
fname = os.path.join(basedir, image_file + '.png')
image = Gtk.Image()
image.set_from_file(fname)
tbutton = Gtk.ToolButton()
tbutton.set_label(text)
tbutton.set_icon_widget(image)
self.insert(tbutton, -1)
tbutton.connect('clicked', getattr(self, callback))
tbutton.set_tooltip_text(tooltip_text)
toolitem = Gtk.SeparatorToolItem()
self.insert(toolitem, -1)
toolitem.set_draw(False)
toolitem.set_expand(True)
toolitem = Gtk.ToolItem()
self.insert(toolitem, -1)
self.message = Gtk.Label()
toolitem.add(self.message)
self.show_all()
示例2: _init_toolbar
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def _init_toolbar(self):
self.set_style(Gtk.ToolbarStyle.ICONS)
basedir = os.path.join(rcParams['datapath'], 'images')
self._gtk_ids = {}
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
self.insert(Gtk.SeparatorToolItem(), -1)
continue
fname = os.path.join(basedir, image_file + '.png')
image = Gtk.Image()
image.set_from_file(fname)
self._gtk_ids[text] = tbutton = Gtk.ToolButton()
tbutton.set_label(text)
tbutton.set_icon_widget(image)
self.insert(tbutton, -1)
tbutton.connect('clicked', getattr(self, callback))
tbutton.set_tooltip_text(tooltip_text)
toolitem = Gtk.SeparatorToolItem()
self.insert(toolitem, -1)
toolitem.set_draw(False)
toolitem.set_expand(True)
toolitem = Gtk.ToolItem()
self.insert(toolitem, -1)
self.message = Gtk.Label()
toolitem.add(self.message)
self.show_all()
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def __init__(self):
self.geoclue = Geoclue.DiscoverLocation()
self.geoclue.connect(self.location_changed)
self.plugin_path = os.path.dirname(os.path.abspath(__file__))
self.glade_file = os.path.join(self.plugin_path, "geolocalized.ui")
# the preference menu for the plugin
self.menu_item = Gtk.MenuItem("Geolocalized-tasks Preferences")
self.PROXIMITY_FACTOR = 5 # 5 km
self.LOCATION_DETERMINATION_METHOD = []
# "network", "gps", "cellphone"
for provider in self.geoclue.get_available_providers():
status = self.geoclue.provider_status(provider['object'])
if provider['name'].lower() == "hostip":
if status in ["available", "acquiring"]:
self.LOCATION_DETERMINATION_METHOD.append("network")
elif provider['name'].lower() in ["gpsd", "gypsy"]:
if status in ["available", "acquiring"]:
self.LOCATION_DETERMINATION_METHOD.append("gps")
elif provider['name'].lower() == "gsmloc":
if status in ["available", "acquiring"]:
self.LOCATION_DETERMINATION_METHOD.append("cellphone")
self.location_filter = []
self.task_separator = Gtk.SeparatorToolItem()
示例4: onTaskOpened
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def onTaskOpened(self, plugin_api):
image_geolocalization_path = os.path.join(self.plugin_path,
"icons/hicolor/24x24/\
geolocalization.png")
pixbuf_geolocalization = GdkPixbuf.Pixbuf.new_from_file_at_size(
image_geolocalization_path, 24, 24)
# create the image and associate the pixbuf
icon_geolocalization = Gtk.Image()
icon_geolocalization.set_from_pixbuf(pixbuf_geolocalization)
icon_geolocalization.show()
# toolbar button for the location_view
btn_location_view = Gtk.ToggleToolButton()
btn_location_view.set_icon_widget(icon_geolocalization)
btn_location_view.set_label("Location View")
self.task_separator = plugin_api.add_task_toolbar_item(
Gtk.SeparatorToolItem())
btn_set_location = Gtk.ToolButton()
btn_set_location.set_icon_widget(icon_geolocalization)
btn_set_location.set_label("Set/View location")
btn_set_location.connect('clicked', self.set_task_location, plugin_api)
self.btn_set_location = plugin_api.add_task_toolbar_item(
btn_set_location)
示例5: create_toolbar
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def create_toolbar(self):
'''This function creates a toolbar which is displayed next to the table'''
toolbar = Gtk.Toolbar()
toolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
toolbar.set_style(Gtk.ToolbarStyle.ICONS)
toolbar.set_border_width(1)
for pos, stock, handler, data, tooltip in (
(0, Gtk.STOCK_ADD, self.on_add_row, None, _('Add row')), # T: tooltip on mouse hover
(1, Gtk.STOCK_DELETE, self.on_delete_row, None, _('Remove row')), # T: tooltip on mouse hover
(2, Gtk.STOCK_COPY, self.on_clone_row, None, _('Clone row')), # T: tooltip on mouse hover
(3, None, None, None, None),
(4, Gtk.STOCK_GO_UP, self.on_move_row, -1, _('Row up')), # T: tooltip on mouse hover
(5, Gtk.STOCK_GO_DOWN, self.on_move_row, 1, _('Row down')), # T: tooltip on mouse hover
(6, None, None, None, None),
(7, Gtk.STOCK_PREFERENCES, self.on_change_columns, None, _('Change columns')), # T: tooltip on mouse hover
(8, None, None, None, None),
(9, Gtk.STOCK_HELP, self.on_open_help, None, _('Open help')), # T: tooltip on mouse hover
):
if stock is None:
toolbar.insert(Gtk.SeparatorToolItem(), pos)
else:
button = Gtk.ToolButton(stock)
if data:
button.connect('clicked', handler, data)
else:
button.connect('clicked', handler)
button.set_tooltip_text(tooltip)
toolbar.insert(button, pos)
toolbar.set_size_request(300, -1)
toolbar.set_icon_size(Gtk.IconSize.MENU)
return toolbar
示例6: _create_toolitems
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def _create_toolitems(self):
iconSize = Gtk.IconSize.SMALL_TOOLBAR
for text, tooltip_text, image_num, callback, callback_arg, scroll \
in self.toolitems:
if text is None:
self.insert( Gtk.SeparatorToolItem(), -1 )
continue
image = Gtk.Image()
image.set_from_stock(image_num, iconSize)
tbutton = Gtk.ToolButton()
tbutton.set_label(text)
tbutton.set_icon_widget(image)
self.insert(tbutton, -1)
if callback_arg:
tbutton.connect('clicked', getattr(self, callback),
callback_arg)
else:
tbutton.connect('clicked', getattr(self, callback))
if scroll:
tbutton.connect('scroll_event', getattr(self, callback))
tbutton.set_tooltip_text(tooltip_text)
# Axes toolitem, is empty at start, update() adds a menu if >=2 axes
self.axes_toolitem = Gtk.ToolItem()
self.insert(self.axes_toolitem, 0)
self.axes_toolitem.set_tooltip_text(
'Select axes that controls affect')
align = Gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
self.axes_toolitem.add(align)
self.menubutton = Gtk.Button ("Axes")
align.add (self.menubutton)
def position_menu (menu):
"""Function for positioning a popup menu.
Place menu below the menu button, but ensure it does not go off
the bottom of the screen.
The default is to popup menu at current mouse position
"""
x0, y0 = self.window.get_origin()
x1, y1, m = self.window.get_pointer()
x2, y2 = self.menubutton.get_pointer()
sc_h = self.get_screen().get_height()
w, h = menu.size_request()
x = x0 + x1 - x2
y = y0 + y1 - y2 + self.menubutton.allocation.height
y = min(y, sc_h - h)
return x, y, True
def button_clicked (button, data=None):
self.axismenu.popup (None, None, position_menu, 0,
Gtk.get_current_event_time())
self.menubutton.connect ("clicked", button_clicked)
示例7: create
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import SeparatorToolItem [as 别名]
def create(toolbar):
'''Set of instructions to create the search widget in a toolbar.'''
# Search components
toolbar.search_combo_tb = Gtk.ToolItem()
toolbar.search_combo_align = Gtk.Alignment.new(0, 0.5, 0, 0)
store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
toolbar.search_combo = Gtk.ComboBox.new_with_model(store)
rendererText = Gtk.CellRendererText()
rendererPix = Gtk.CellRendererPixbuf()
toolbar.search_combo.pack_start(rendererPix, False)
toolbar.search_combo.pack_start(rendererText, True)
toolbar.search_combo.add_attribute(rendererPix, 'pixbuf', 0)
toolbar.search_combo.add_attribute(rendererText, 'text', 1)
options = {
'String':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_string_16.png')),
'String no case':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_string_no_case_16.png')),
'Hexadecimal':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_hexadecimal_16.png')),
'Regexp':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_regexp_16.png'))
}
for option in options.keys():
store.append([options[option], option])
toolbar.search_combo.set_active(0)
toolbar.search_combo_align.add(toolbar.search_combo)
toolbar.search_combo_tb.add(toolbar.search_combo_align)
toolbar.main_tb.insert(toolbar.search_combo_tb, -1)
# Separator
toolbar.sep = Gtk.SeparatorToolItem()
toolbar.sep.set_draw(False)
toolbar.main_tb.insert(toolbar.sep, -1)
toolbar.search_entry_tb = Gtk.ToolItem()
toolbar.search_entry = Gtk.Entry()
toolbar.search_entry.set_max_length(100)
toolbar.search_entry.set_text('Text to search')
toolbar.search_entry.set_icon_from_stock(1, Gtk.STOCK_FIND)
toolbar.search_entry.set_icon_tooltip_text(1, 'Search')
toolbar.search_entry.connect("activate", toolbar.search)
toolbar.search_entry.connect("icon-press", toolbar.search)
toolbar.search_entry.connect('focus-in-event', toolbar._clean, 'in')
toolbar.search_entry.connect('focus-out-event', toolbar._clean, 'out')
toolbar.search_entry_tb.add(toolbar.search_entry)
# We use the AccelGroup object from the main window.
my_accel = Gtk.accel_groups_from_object(toolbar.main.window)[0]
key, mod = Gtk.accelerator_parse('<Control>F')
toolbar.search_entry.set_tooltip_text('Control-F to search')
toolbar.search_entry.add_accelerator('grab-focus', my_accel, key, mod, Gtk.AccelFlags.MASK)
toolbar.main_tb.insert(toolbar.search_entry_tb, -1)