本文整理汇总了Python中gi.repository.Gtk.IconView方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.IconView方法的具体用法?Python Gtk.IconView怎么用?Python Gtk.IconView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.IconView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_ui
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def init_ui(self):
self.iconview = Gtk.IconView(model=self.liststore)
self.iconview.set_pixbuf_column(PIXBUF_COL)
self.iconview.set_text_column(NAME_COL)
self.iconview.set_tooltip_column(TOOLTIP_COL)
self.iconview.set_item_width(84)
self.iconview.set_selection_mode(Gtk.SelectionMode.MULTIPLE)
self.iconview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
DRAG_TARGET_LIST, DRAG_ACTION)
self.iconview.connect('drag-data-get', self.on_drag_data_get)
self.iconview.enable_model_drag_dest(DROP_TARGET_LIST, DRAG_ACTION)
self.iconview.connect('drag-data-received', self.on_drag_data_received)
self.iconview.connect('item-activated', self.on_iconview_item_activated)
self.iconview.connect('button-press-event',
self.on_iconview_button_pressed)
self.add(self.iconview)
self.get_vadjustment().connect('value-changed', self.on_scrolled)
self.liststore.set_sort_func(NAME_COL, gutil.tree_model_natsort)
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def __init__(self):
Gtk.IconView.__init__(self)
# Add style class
style_context = self.get_style_context()
style_context.add_class("WidgetChooser")
self.set_text_column(0)
self.set_pixbuf_column(1)
self.set_item_width(130)
self.set_columns(1)
self.model = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str)
self.set_model(self.model)
# Enable DnD
self.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY)
self.connect("drag-data-get", self.on_drag_data_get)
self.connect("drag-begin", self.on_drag_begin)
self.connect("drag-end", self.on_drag_end)
self.drag_source_set_target_list(None)
self.drag_source_add_text_targets()
self.drag = False
self.connect('focus-out-event', self.on_focus_out)
示例3: __build_window
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def __build_window(self):
"""Build up the widget"""
self.set_type_hint(Gdk.WindowTypeHint.POPUP_MENU)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.add(vbox)
# icon list
scld_win = Gtk.ScrolledWindow()
scld_win.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
scld_win.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
vbox.pack_start(scld_win, True, True, 0)
self.symbol_iv = Gtk.IconView()
self.symbol_iv.set_pixbuf_column(0)
self.symbol_iv.set_columns(7)
self.symbol_iv.set_item_width(32)
# IconView size:
# --------------
# it seems that with the above parameters, a row width is about:
# item_count * (32px (item) + 6px (dflt padding) + 2px (spacing?)) \
# + 2*6px (dflt widget margin)
# The same goes for row height, but being right for this value is less
# important due to the vertical scrollbar.
# The IcVw size should fit the width of 7 cols and height of ~4 lines.
SIZE_REQUEST = (40 * 7 + 12, 38 * 4)
self.symbol_iv.set_size_request(*SIZE_REQUEST)
scld_win.set_size_request(*SIZE_REQUEST)
scld_win.add(self.symbol_iv)
# icon remove button
self.remove_bt = Gtk.Button()
self.remove_bt.set_label(_("Remove selected icon"))
vbox.pack_start(self.remove_bt, False, False, 0)
# set the callbacks
self.symbol_iv.connect("selection-changed", self.on_selection_changed)
self.remove_bt.connect("clicked", self.on_remove_bt_clicked)
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def __init__(self):
View.__init__(self)
Gtk.IconView.__init__(self)
self.props.item_orientation = Gtk.Orientation.HORIZONTAL
self.set_columns(len(self.states))
self.set_margin(0)
self.set_item_width(23)
self.set_spacing(0)
self.set_row_spacing(0)
self.set_column_spacing(0)
liststore = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
self.set_model(liststore)
self.set_markup_column(0)
self.set_tooltip_column(1)
for shorthand, state_class, icon in self.states:
liststore.append(['<span font_desc="{font} {size}" color="{color}">{icon}</span> {text}'.format(
font=constants.ICON_FONT_FONTAWESOME,
size=constants.FONT_SIZE_BIG,
color=global_gui_config.colors['BUTTON_TEXT_COLOR'],
icon=icon,
text=shorthand
), "Add/Drag and Drop " + state_class.__name__])
self['state_icon_view'] = self
self.top = 'state_icon_view'
示例5: _on_activated
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def _on_activated(self, iconview, path):
"""Select and show image when thumbnail was activated.
Args:
iconview: Gtk.IconView that emitted the signal.
path: Gtk.TreePath of the activated thumbnail.
"""
self.toggle(True)
count = path.get_indices()[0] + 1
self._app["eventhandler"].num_clear()
self._app["eventhandler"].set_num_str(count)
self._app["image"].move_pos()
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import IconView [as 别名]
def __init__(self, parent, plugin, pageview):
Dialog.__init__(
self,
parent,
_('Insert Symbol'), # T: Dialog title
button=_('_Insert'), # T: Button label
defaultwindowsize=(350, 400)
)
self.plugin = plugin
self.pageview = pageview
if not plugin.symbols:
plugin.load_file()
self.textentry = InputEntry()
self.vbox.pack_start(self.textentry, False, True, 0)
model = Gtk.ListStore(str, str) # text, shortcut
self.iconview = Gtk.IconView(model)
self.iconview.set_text_column(0)
self.iconview.set_column_spacing(0)
self.iconview.set_row_spacing(0)
self.iconview.set_property('has-tooltip', True)
self.iconview.set_property('activate-on-single-click', True)
self.iconview.connect('query-tooltip', self.on_query_tooltip)
self.iconview.connect('item-activated', self.on_activated)
swindow = ScrolledWindow(self.iconview)
self.vbox.pack_start(swindow, True, True, 0)
button = Gtk.Button.new_with_mnemonic(_('_Edit')) # T: Button label
button.connect('clicked', self.on_edit)
self.action_area.add(button)
self.action_area.reorder_child(button, 0)
self.load_symbols()