예제 #1
0
파일: gui.py 프로젝트: mwarchulinski/edone
    def _task_edit_start(self, task):
        pp = Popup(self.top_widget)
        pp.part_text_set('title,text', 'Edit task')

        en = Entry(pp, editable=True, single_line=True, scrollable=True,
                   text=task.raw_txt)
        en.callback_activated_add(lambda e: self._task_edit_end(task, en, pp))
        en.callback_aborted_add(lambda e: pp.delete())
        pp.part_content_set('default', en)

        b = Button(pp, text='Cancel')
        b.callback_clicked_add(lambda b: pp.delete())
        pp.part_content_set('button1', b)

        b = Button(pp, text='Accept')
        b.callback_clicked_add(lambda b: self._task_edit_end(task, en, pp))
        pp.part_content_set('button2', b)

        pp.show()

        en.cursor_begin_set()
        en.cursor_selection_begin()
        en.cursor_end_set()
        en.cursor_selection_end()
예제 #2
0
파일: utils.py 프로젝트: DaveMDS/egitu
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