本文整理汇总了Python中gi.repository.Gtk.STOCK_CLEAR属性的典型用法代码示例。如果您正苦于以下问题:Python Gtk.STOCK_CLEAR属性的具体用法?Python Gtk.STOCK_CLEAR怎么用?Python Gtk.STOCK_CLEAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.STOCK_CLEAR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_icon_to_clear
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CLEAR [as 别名]
def set_icon_to_clear(self):
'''Adds a "clear" icon in the entry widget
This method calls L{set_icon()} with the right defaults for
a stock "Clear" icon. In addition it makes the icon insensitive
when there is no text in the entry. Clicking the icon will
clear the entry.
@returns: C{True} if successfull, C{False} if not supported
by Gtk version
'''
self.set_icon(Gtk.STOCK_CLEAR, self.clear, _('Clear'))
# T: tooltip for the inline icon to clear a text entry widget
def check_icon_sensitive(self):
text = self.get_text()
self.set_property('secondary-icon-sensitive', bool(text))
check_icon_sensitive(self)
self.connect('changed', check_icon_sensitive)
return True
示例2: init
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CLEAR [as 别名]
def init(self):
"""
Constructs the GUI, consisting of a text area, and
an Import and Clear buttons.
"""
from gi.repository import Gtk
# GUI setup:
self.set_tooltip(_("Enter text to import and then click\n"
"the Import button at bottom"))
# create
self.import_text = Gtk.TextView()
self.import_text.set_wrap_mode(Gtk.WrapMode.NONE)
self.import_text.set_editable(True)
import_button = Gtk.Button()
clear_button = Gtk.Button()
# layout
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.add(self.import_text)
buttonbox = Gtk.HButtonBox()
buttonbox.set_layout(Gtk.ButtonBoxStyle.SPREAD)
buttonbox.pack_start(clear_button, False, False, 0)
buttonbox.pack_start(import_button, False, False, 0)
vbox = Gtk.VBox()
vbox.pack_start(scrolled_window, True, True, 0)
vbox.pack_start(buttonbox, False, False, 0)
scrolled_window = self.gui.get_container_widget()
for widget in scrolled_window.get_children():
widget.destroy()
scrolled_window.add_with_viewport(vbox)
scrolled_window.get_children()[0].set_shadow_type(Gtk.ShadowType.NONE)
# bindings
actiongroup = Gtk.ActionGroup('GrampletImportActions')
actiongroup.add_actions([
('import', None, _("_Import"), '<Alt>i', None, self.run),
('clear', Gtk.STOCK_CLEAR, None, None, None, self.clear)])
import_button.set_related_action(actiongroup.get_action('import'))
clear_button.set_related_action(actiongroup.get_action('clear'))
# show
vbox.show_all()
示例3: _populate_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CLEAR [as 别名]
def _populate_menu(self, textview, menu):
opc = Gtk.ImageMenuItem((Gtk.STOCK_CLEAR))
opc.get_children()[0].set_label('Clear text')
menu.prepend(Gtk.SeparatorMenuItem())
menu.prepend(opc)
opc.connect("activate", self._clear, iter)
menu.show_all()
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CLEAR [as 别名]
def __init__(self, combo_box, main_window):
CustomComboBoxEntry.__init__(self, combo_box)
self.main_window = main_window
self.journal = main_window.journal
self.entry.set_icon_from_stock(1, Gtk.STOCK_CLEAR)
self.entry.connect("icon-press", lambda *args: self.set_active_text(""))
self.entry.connect("changed", self.on_entry_changed)
self.entry.connect("activate", self.on_entry_activated)
示例5: menu_edit_comment
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_CLEAR [as 别名]
def menu_edit_comment(self, widget=None, board=None, index=0):
"""
The method will create/update or delete a comment.
The popup window will receive an additional button if there is an existing comment.
"""
creation = True
if not board.children:
board.children.append("")
elif not isinstance(board.children[index], str):
board.children.insert(index, "")
else:
creation = False
buttons_list = () if creation else (Gtk.STOCK_CLEAR, Gtk.ResponseType.REJECT)
buttons_list = buttons_list + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
dialog = Gtk.Dialog(_("Add comment") if creation else _("Edit comment"),
mainwindow(),
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
buttons_list)
textedit = Gtk.TextView()
textedit.set_editable(True)
textedit.set_cursor_visible(True)
textedit.set_wrap_mode(Gtk.WrapMode.WORD)
textedit.set_accepts_tab(False)
textbuffer = textedit.get_buffer()
textbuffer.set_text(board.children[index])
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.add(textedit)
dialog.get_content_area().pack_start(sw, True, True, 0)
dialog.resize(300, 200)
dialog.show_all()
response = dialog.run()
dialog.destroy()
if response == Gtk.ResponseType.DELETE_EVENT: # Escape key implies Cancel
response = Gtk.ResponseType.CANCEL
(iter_first, iter_last) = textbuffer.get_bounds()
comment = '' if response == Gtk.ResponseType.REJECT else textbuffer.get_text(iter_first, iter_last, False)
if response != Gtk.ResponseType.CANCEL and board.children[index] != comment:
if len(comment) == 0:
del board.children[index]
else:
board.children[index] = comment
self.gamemodel.needsSave = True
self.update()