Python ui 模块,TextView() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用ui.TextView()

项目:pythonista-gestures    作者:mikaelho    | 项目源码 | 文件源码
def __init__(self):
      self.tv = ui.TextView(flex='WH', editable=False)
      self.add_subview(self.tv)
      self.tv.frame = (0, 0, self.width, self.height)

      g = Gestures()

      g.recognize_simultaneously = lambda gr, other_gr: gr == Gestures.PAN and other_gr == Gestures.PINCH

      g.fail_other = lambda gr, other_gr: other_gr == Gestures.PINCH

      g.add_tap(self, self.general_handler)

      g.add_long_press(self.tv, self.long_press_handler)

      pan = g.add_pan(self, self.pan_handler)

      #g.add_screen_edge_pan(self.tv, self.pan_handler, edges = Gestures.EDGE_LEFT)

      #g.add_swipe(self.tv, self.general_handler, direction = [Gestures.DOWN])

      #g.add_pinch(self, self.pinch_handler)

      g.add_rotation(self.tv, self.rotation_handler)
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def __init__(self):
            RootView.__init__(self)
            self.t1=ui.Label(frame=(0,60,400,20))
            self.t2=ui.Label(frame=(0,90,400,20))
            self.t3=ui.TextView( frame=(0,120,700,200),bg_color=(0.7,0.7,0.7,0.5))

            self.t3.text='textview for kb'
            # the first time the keyboard appears, get kbframe is wrong...
            #  so, show then hide keyboard.
            self.t3.begin_editing()
            ui.delay(self.t3.end_editing,0.5)
            # finally, show kbframe again
            ui.delay(self.t3.begin_editing,1.0)


            self.t1.text='touch to begin'
            [self.add_subview(s) for s in [self.t1,self.t2,self.t3]]
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def create_new_window(root,sender):
        v=ZoomView()
        v.bg_color=0.90, 0.90, 0.90
        v.border_color='grey'
        v.border_width=2
        v.x=random.randrange(75,300)
        v.y=random.randrange(75,300)
        v.width=v.height=300
        closebutton=ui.Button(frame=(250,0,50,50), bg_color='grey')
        closebutton.image=ui.Image.named('ionicons-close-round-32')
        closebutton.flex='bl'
        def closeview(sender):
            sender.superview.superview.remove_subview(sender.superview)
        closebutton.action=closeview
        tv=ui.TextView()
        tv.frame=(20,20,258,258)
        tv.flex='wh'
        v.add_subview(tv)
        v.add_subview(closebutton)
        root.add_subview(v)
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def __init__(self):
            RootView.__init__(self)
            self.t1=ui.Label(frame=(0,60,400,20))
            self.t2=ui.Label(frame=(0,90,400,20))
            self.t3=ui.TextView( frame=(0,120,700,200),bg_color=(0.7,0.7,0.7,0.5))

            self.t3.text='textview for kb'
            # the first time the keyboard appears, get kbframe is wrong...
            #  so, show then hide keyboard.
            self.t3.begin_editing()
            ui.delay(self.t3.end_editing,0.5)
            # finally, show kbframe again
            ui.delay(self.t3.begin_editing,1.0)


            self.t1.text='touch to begin'
            [self.add_subview(s) for s in [self.t1,self.t2,self.t3]]
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def create_new_window(root,sender):
        v=ZoomView()
        v.bg_color=0.90, 0.90, 0.90
        v.border_color='grey'
        v.border_width=2
        v.x=random.randrange(75,300)
        v.y=random.randrange(75,300)
        v.width=v.height=300
        closebutton=ui.Button(frame=(250,0,50,50), bg_color='grey')
        closebutton.image=ui.Image.named('ionicons-close-round-32')
        closebutton.flex='bl'
        def closeview(sender):
            sender.superview.superview.remove_subview(sender.superview)
        closebutton.action=closeview
        tv=ui.TextView()
        tv.frame=(20,20,258,258)
        tv.flex='wh'
        v.add_subview(tv)
        v.add_subview(closebutton)
        root.add_subview(v)
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def finddocstring(self):
        ''' find the docstring at current cursor location
        '''
        import StringIO
        from jedi import Script

        i=editor.get_selection()
        t=editor.get_text()
        (line,txt)=[(line,n) for (line,n) in enumerate(StringIO.StringIO(editor.get_text()[:i[1]]))][-1]
        script = Script(t, line+1, len(txt))

        dfn = script.goto_definitions()
        if dfn:
            doc=dfn[0].doc
            import ui
            v=ui.TextView()
            v.width=100
            v.height=50
            v.text=doc
            editor._set_toolbar(v)
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def make_right_side_view(cls, right_frame):
        text_view = ui.TextView(frame=right_frame)
        text_view.alpha = cls.views_alpha
        text_view.alignment = ui.ALIGN_CENTER
        text_view.editable = False
        text_view.text = '\n' + '1234567890 ' * 50
        return text_view
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def make_left_side_view(cls, left_frame):
        view = ui.TextView(frame=left_frame)
        view.alpha = cls.views_alpha
        view.editable = False
        return view
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def make_status_view(cls, status_frame):
        text_view = ui.TextView(frame=status_frame)
        text_view.alpha = cls.views_alpha
        text_view.alignment = ui.ALIGN_CENTER
        text_view.editable = False
        text_view.text = "Status: let the game begin...  It is white's turn to move"
        return text_view
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def popover(self, msg):
        textview = ui.TextView()
        textview.editable = False
        textview.font = ('AmericanTypewriter', 24)
        textview.alignment = ui.ALIGN_CENTER
        textview.text = msg
        pov = ui.View()
        pov.width = textview.width = 222
        pov.add_subview(textview)
        pov.present('popover')

# in the .pyui file, the "Custom View Class" must be set to AreYouEnabledView
项目:Pythonista_scripts    作者:wizardofozzie    | 项目源码 | 文件源码
def __init__(self):
        self.flex = 'WH'
        self.name = 'Swipe/Touch around to generate a hash'
        self.hash = hashlib.sha256()
        self.count = 0
        self.textview = ui.TextView()
        self.textview.touch_enabled = False
        self.textview.editable = False
        self.textview.flex = 'WH'
        self.add_subview(self.textview)
        self.present()
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def _show_documentation(definition):
    reuse = get_config_value('documentation.reuse', True)
    frame = get_config_value('documentation.frame', (630, 110, 730, 350))
    tag = '__blackmamba.show_documentation'
    if not reuse:
        tag += ':{}'.format(definition.full_name)

    manager = overlay.get_manager()

    o = manager.get_overlay(tag)
    if o:
        o.title = definition.name
        o.content_view.text = definition.docstring()
        o.expand()
        o.become_active()
        return

    tv = ui.TextView(
        text=definition.docstring(),
        background_color=get_theme_value('background_color'),
        text_color=get_theme_value('text_color'),
        font=get_editor_font()
    )
    tv.editable = False

    window_size = ui.get_window_size()
    x = frame[0]
    y = frame[1]
    width = min(window_size[0] - x - 12, frame[2])
    height = min(window_size[1] - y - 12, frame[3])
    manager.present(definition.name, tv, frame=(x, y, width, height), tag=tag)
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def __init__(self, change_set, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.name = 'Preview'
        self.apply_changes = False

        def apply(sender):
            self.apply_changes = True
            self.close()

        button = ui.ButtonItem('Apply', action=apply)
        self.right_button_items = [button]

        textview = ui.TextView(frame=self.bounds, flex='WH')
        textview.editable = False

        diff = _change_set_diff(change_set)
        attributed_string = _diff_to_attributed_string(diff)
        _set_attributed_text(textview, attributed_string)

        self.add_subview(textview)

        def cancel():
            self.close()

        self.handlers = [
            register_key_event_handler(UIEventKeyCode.escape, cancel),
            register_key_event_handler(UIEventKeyCode.dot, cancel, modifier=UIKeyModifier.command),
            register_key_event_handler(UIEventKeyCode.enter, lambda: apply(None))
        ]
项目:pythonista-scripts    作者:khilnani    | 项目源码 | 文件源码
def __init__(self, frame = None, flex = None, background_color = None, name = None, accessory_keys = True, extras = [], css = None):

        if frame: self.frame = frame
        if flex: self.flex = flex
        if background_color: self.background_color = background_color
        if name: self.name = name

        self.extras = extras
        self.css = css or self.default_css
        self.proxy_delegate = None

        self.enable_links = True
        self.editing = False
        self.margins = (10, 10, 10, 10)

        self.link_prefix = 'pythonista-markdownview:relay?content='
        self.debug_prefix = 'pythonista-markdownview:debug?content='
        self.init_postfix = '#pythonista-markdownview-initialize'
        self.in_doc_prefix = ''

        self.to_add_to_beginning = ('', -1)

        self.backpanel = ui.View()
        self.add_subview(self.backpanel)

        # Web fragment is used to find the right scroll position when moving from editing to viewing
        self.web_fragment = ui.WebView()
        self.web_fragment.hidden = True
        self.web_fragment.delegate = MarkdownView.ScrollLoadDelegate()
        self.add_subview(self.web_fragment)

        self.markup = ui.TextView()
        self.add_subview(self.markup)
        self.markup.font = ('<system>', 12)

        self.web = ui.WebView()
        self.web.scales_page_to_fit = False 
        self.web.content_mode = ui.CONTENT_TOP_LEFT
        self.add_subview(self.web)

        self.web.delegate = self
        self.markup.delegate = self

        self.markup.text = ''
        self.update_html()
        self.markup.bounces = False 

        # Ghosts are used to determine preferred size
        self.markup_ghost = ui.TextView()
        self.markup_ghost.hidden = True
        #self.add_subview(self.markup_ghost)
        self.web_ghost = ui.WebView()
        self.web_ghost.hidden = True
        #self.add_subview(self.web_ghost)

        if accessory_keys:
            self.create_accessory_toolbar()