本文整理汇总了Python中efl.elementary.entry.Entry.markup_filter_append方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.markup_filter_append方法的具体用法?Python Entry.markup_filter_append怎么用?Python Entry.markup_filter_append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类efl.elementary.entry.Entry
的用法示例。
在下文中一共展示了Entry.markup_filter_append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: elm_input_events_clicked
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import markup_filter_append [as 别名]
def elm_input_events_clicked(obj, item=None):
win = StandardWindow("inputevents", "Input Events Test", autodel=True)
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
box = Box(win, size_hint_weight=EXPAND_BOTH)
win.resize_object_add(box)
box.show()
entry = Entry(win, scrollable=True, size_hint_align=FILL_BOTH,
size_hint_weight=(1.0, 0.2))
entry.text = (
"This example will show how Elementary input events are handled. "
"Typing in this entry will log in the entry box below all events "
"caught by event handlers set to this Entry widget and its parent, "
"the Window widget. Key up events are checked for in the callback "
"and won't propagate to a parent widget."
)
entry.show()
log_entry = Entry(win, editable=False, scrollable=True, focus_allow=False,
size_hint_align=FILL_BOTH, size_hint_weight=(1.0, 0.8))
log_entry.callback_changed_add(changed_cb)
log_entry.show()
btn = Button(win, text="Clear log", focus_allow=False)
btn.callback_clicked_add(lambda x: setattr(log_entry, "entry", ""))
btn.show()
box.pack_end(entry)
box.pack_end(log_entry)
box.pack_end(btn)
entry.elm_event_callback_add(events_cb, log_entry)
entry.markup_filter_append(filter_cb)
win.elm_event_callback_add(events_cb, log_entry)
win.resize(640, 480)
win.show()
entry.focus = True
示例2: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import markup_filter_append [as 别名]
class Interface(object):
def __init__( self ):
self.mainWindow = StandardWindow("epad", "Untitled - ePad", size=(600, 400))
self.mainWindow.callback_delete_request_add(self.closeChecks)
self.mainWindow.elm_event_callback_add(self.eventsCb)
icon = Icon(self.mainWindow)
icon.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
icon.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL)
icon.standard_set('accessories-text-editor') # assumes image icon is in local dir, may need to change later
icon.show()
self.mainWindow.icon_object_set(icon.object_get())
self.mainBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
self.mainBox.show()
self.mainTb = Toolbar(self.mainWindow, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0))
self.mainTb.menu_parent = self.mainWindow
self.mainTb.item_append("document-new", "New", self.newPress)
self.mainTb.item_append("document-open", "Open", self.openPress)
self.mainTb.item_append("document-save", "Save", self.savePress)
self.mainTb.item_append("document-save-as", "Save As", self.saveAsPress)
# -- Edit Dropdown Menu --
tb_it = self.mainTb.item_append("edit", "Edit")
tb_it.menu = True
menu = tb_it.menu
menu.item_add(None, "Copy", "edit-copy", self.copyPress)
menu.item_add(None, "Paste", "edit-paste", self.pastePress)
menu.item_add(None, "Cut", "edit-cut", self.cutPress)
menu.item_separator_add()
menu.item_add(None, "Select All", "edit-select-all", self.selectAllPress)
# -----------------------
# self.mainTb.item_append("settings", "Options", self.optionsPress)
self.mainTb.item_append("dialog-information", "About", self.aboutPress)
self.mainEn = Entry(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
self.mainEn.callback_changed_user_add(self.textEdited)
self.mainEn.scrollable_set(True) # creates scrollbars rather than enlarge window
self.mainEn.line_wrap_set(False) # does not allow line wrap (can be changed by user)
self.mainEn.autosave_set(False) # set to false to reduce disk I/O
self.mainEn.elm_event_callback_add(self.eventsCb)
self.mainEn.markup_filter_append(self.textFilter)
self.mainEn.show()
self.mainTb.show()
self.mainBox.pack_end(self.mainTb)
self.mainBox.pack_end(self.mainEn)
#Build our file selector for saving/loading files
self.fileBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
self.fileBox.show()
self.fileLabel = Label(self.mainWindow, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
self.fileLabel.text = ""
self.fileLabel.show()
self.fileSelector = Fileselector(self.mainWindow, is_save=False, expandable=False, folder_only=False,
path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
self.fileSelector.callback_done_add(self.fileSelected)
#self.fileSelector.callback_selected_add(fs_cb_selected, win)
#self.fileSelector.callback_directory_open_add(fs_cb_directory_open, win)
self.fileSelector.show()
self.fileBox.pack_end(self.fileLabel)
self.fileBox.pack_end(self.fileSelector)
# the flip object has the file selector on one side and the GUI on the other
self.flip = Flip(self.mainWindow, size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
self.flip.part_content_set("front", self.mainBox)
self.flip.part_content_set("back", self.fileBox)
self.mainWindow.resize_object_add(self.flip)
self.flip.show()
self.isSaved = True
self.isNewFile = False
self.confirmPopup = None
def newPress( self, obj, it ):
self.newFile()
it.selected_set(False)
def openPress( self, obj, it ):
self.openFile()
it.selected_set(False)
def savePress( self, obj, it ):
self.saveFile()
it.selected_set(False)
def saveAsPress( self, obj, it ):
self.saveAs()
it.selected_set(False)
def optionsPress( self, obj, it ):
it.selected_set(False)
#.........这里部分代码省略.........
示例3: Calculator
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import markup_filter_append [as 别名]
class Calculator(object):
def __init__(self):
"""Creates the window and its contents.
:attribute memory: The first operand.
:attribute operand: The operand to join the both values.
:attribute field: The input/display field.
:attribute table: Formatting table holding the buttons.
"""
# Create mathematical attributes.
self.memory = ''
self.operand = None
self.display_is_result = False
# Create the main window.
self.window = StandardWindow("eCalculate", "eCalculate", autodel=True, size=(300, 300))
# Create box that holds all GUI elements.
box = Box(self.window, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
self.window.resize_object_add(box)
box.show()
# Create Input field.
self.field = Entry(self.window, single_line=True,
size_hint_weight=EXPAND_HORIZONTAL,
size_hint_align=FILL_HORIZONTAL)
self.field.markup_filter_append(self.filter_markup)
box.pack_end(self.field)
self.field.show()
# Create table holding the buttons.
self.table = Table(self.window, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
box.pack_end(self.table)
self.table.show()
# Create buttons.
self.add_button(x=0, y=2, text='1', char='1')
self.add_button(x=1, y=2, text='2', char='2')
self.add_button(x=2, y=2, text='3', char='3')
self.add_button(x=0, y=1, text='4', char='4')
self.add_button(x=1, y=1, text='5', char='5')
self.add_button(x=2, y=1, text='6', char='6')
self.add_button(x=0, y=0, text='7', char='7')
self.add_button(x=1, y=0, text='8', char='8')
self.add_button(x=2, y=0, text='9', char='9')
self.add_button(x=0, y=3, text='0', char='0')
self.add_button(x=4, y=0, text='÷', char='/')
self.add_button(x=4, y=1, text='×', char='*')
self.add_button(x=4, y=2, text='−', char='-')
self.add_button(x=4, y=3, text='+', char='+')
self.add_button(x=2, y=3, text='=', char='=')
self.add_button(x=1, y=3, text='.', char='.')
# Finally show the window.
self.window.show()
def add_button(self, x, y, text, char):
"""Add a button to the user interface.
:param x: The horizontal position in the UI-table.
:param y: The vertical position in the UI-table.
:param text: The button label.
:param action: String what the button should do, resolved into
a function in self.do_action().
:param char: Character that is passed along with the action.
"""
button = Button(self.window, text=text,
size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
button.callback_clicked_add(self.enter_char, char=char)
self.table.pack(button, x, y, 1, 1)
button.show()
def enter_char(self, caller, char):
"""Adds a character to the input field. Called if a button
is pressed.
:param caller: The clicked button.
:param char: The character that should be added to the field.
"""
self.field.entry_append(char)
def calculate(self):
"""Do the calculation. This function does not check if the
values are valid.
"""
result = self.CALC_ACTIONS[self.operand](float(self.memory), float(self.field.text))
self.field.text = re.sub('\.0$', '', str(result))
self.memory = ''
def filter_markup(self, caller, char, _):
"""Filter the entry field of not allowed characters, check
that only one point is in the value, do calculations and set
the operand. Called whenever text is inserted either throught
the keyboard or by pressing buttons.
:param caller: The calling object (always self.field).
:param char: The character entered.
:param _: I do not know ;-) (Passed automatically, always None?).
"""
if not ((not char in '1234567890.+-*/=') or \
(char == '.' and ('.' in caller.text or caller.text == ''))):
if char == '=' and self.memory and caller.text:
self.calculate()
self.display_is_result = True
elif char in '1234567890.':
if not self.display_is_result:
#.........这里部分代码省略.........