当前位置: 首页>>代码示例>>Python>>正文


Python Entry.entry_append方法代码示例

本文整理汇总了Python中efl.elementary.entry.Entry.entry_append方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.entry_append方法的具体用法?Python Entry.entry_append怎么用?Python Entry.entry_append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在efl.elementary.entry.Entry的用法示例。


在下文中一共展示了Entry.entry_append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EmbeddedTerminal

# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import entry_append [as 别名]
class EmbeddedTerminal(Box):
    def __init__(self, parent_widget, titles=None, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.outPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.outPut.editable_set(False)
        self.outPut.scrollable_set(True)
        self.outPut.callback_changed_add(self.changedCb)
        self.outPut.show()

        frame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        frame.text = "Input:"
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        bx.horizontal = True
        bx.show()

        frame.content = bx

        self.inPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.inPut.single_line_set(True)
        self.inPut.callback_activated_add(self.enterPressed)
        self.inPut.show()

        enterButton = Button(self)
        enterButton.text = "Execute"
        enterButton.callback_pressed_add(self.enterPressed)
        enterButton.show()

        bx.pack_end(self.inPut)
        bx.pack_end(enterButton)

        self.pack_end(self.outPut)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None

    def changedCb(self, obj):
        obj.cursor_end_set()

    def enterPressed(self, btn):
        if not self.cmd_exe:
            self.runCommand(self.inPut.text)
            self.inPut.text = ""
        else:
            ourResult = self.cmd_exe.send("%s\n" % self.inPut.text)
            self.inPut.text = ""

    def runCommand(self, command, done_cb=None):
        self.cmd_exe = cmd = ecore.Exe(
            command, ecore.ECORE_EXE_PIPE_READ | ecore.ECORE_EXE_PIPE_ERROR | ecore.ECORE_EXE_PIPE_WRITE
        )
        cmd.on_add_event_add(self.command_started)
        cmd.on_data_event_add(self.received_data)
        cmd.on_error_event_add(self.received_error)
        cmd.on_del_event_add(self.command_done)

        self.done_cb = done_cb

    def command_started(self, cmd, event, *args, **kwargs):
        self.outPut.entry_append("---------------------------------")
        self.outPut.entry_append("<br>")

    def received_data(self, cmd, event, *args, **kwargs):
        self.outPut.entry_append("%s" % event.data)
        self.outPut.entry_append("<br>")

    def received_error(self, cmd, event, *args, **kwargs):
        self.outPut.entry_append("Error: %s" % event.data)

    def command_done(self, cmd, event, *args, **kwargs):
        self.outPut.entry_append("---------------------------------")
        self.outPut.entry_append("<br>")
        self.cmd_exe = None
        if self.done_cb:
            if callable(self.done_cb):
                self.done_cb()
开发者ID:JeffHoogland,项目名称:python-elm-extensions,代码行数:83,代码来源:embeddedterminal.py

示例2: CommandOutputEntry

# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import entry_append [as 别名]
class CommandOutputEntry(Table):
    def __init__(self, parent, min_size=(0,0)):
        Table.__init__(self, parent, size_hint_expand=EXPAND_BOTH, 
                       size_hint_fill=FILL_BOTH)
        
        self._entry = Entry(self, scrollable=True, editable=False,
                            line_wrap=ELM_WRAP_NONE, 
                            size_hint_expand=EXPAND_BOTH, 
                            size_hint_fill=FILL_BOTH)

        self._wheel = Progressbar(self, style='wheel', pulse_mode=True,
                                  size_hint_expand=EXPAND_BOTH)

        self._rect = Rectangle(self.evas, size_hint_min=min_size,
                               size_hint_expand=EXPAND_BOTH, color=(0,0,0,0))

        self.pack(self._entry, 0, 0, 1, 1)
        self.pack(self._rect,  0, 0, 1, 1)
        self.pack(self._wheel, 0, 0, 1, 1)

        self._last_was_carriage = False
        self._entry.show()
        self._rect.show()
        self.show()

    @property
    def text(self):
        return self._entry.text
    @text.setter
    def text(self, text):
        self._entry.text = text

    def pulse_start(self):
        self._rect.repeat_events = False
        self._wheel.pulse(True)
        self._wheel.show()

    def pulse_stop(self):
        self._rect.repeat_events = True
        self._wheel.pulse(False)
        self._wheel.hide()

    def successfull(self):
        self._entry.entry_append('<success>Operation successfully completed.</success><br>')
    
    def failure(self):
        self._entry.entry_append('<failure>Error! Something goes wrong.</failure><br>')
    
    def error_set(self, text):
        self._entry.text = '<failure>Error:</failure><br>%s' % text

    def append_raw(self, line, sep=None):
        if self._last_was_carriage is True:
            self._entry.cursor_selection_begin()
            self._entry.cursor_line_end_set()
            self._entry.cursor_selection_end()
            self._entry.entry_insert('')
        if sep == '\n':
            self._entry.entry_append(line + '<br>')
            self._entry.cursor_end_set()
            self._last_was_carriage = False
        elif sep == '\r':
            self._entry.entry_append(line)
            self._last_was_carriage = True
        else:
            self._entry.entry_append(line)
            self._last_was_carriage = False
开发者ID:DaveMDS,项目名称:egitu,代码行数:69,代码来源:utils.py

示例3: Calculator

# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import entry_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:
#.........这里部分代码省略.........
开发者ID:pyfisch,项目名称:ecalculate,代码行数:103,代码来源:ecalculate.py


注:本文中的efl.elementary.entry.Entry.entry_append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。