【问题标题】:Kivy reStructuredText renderer popup?Kivy reStructuredText 渲染器弹出窗口?
【发布时间】:2018-07-02 02:33:18
【问题描述】:

我想要 kivy reStructuredText 渲染器中引用的弹出效果,默认情况下,当我们按下任何引用时,它会滚动到引用,这里我想用弹出替换滚动,我已经搜索了很长时间但徒劳无功,今天我在 kivy 文档中找到了goto(ref, *largs),是否可以使用它来调用参考弹出窗口?是否可以在另一个类中重新定义 RstDocument 函数并使用它?我是初学者。

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder

Builder.load_string("""
<RSTGUI>:
    RstDocument:
        text: root.doc
        goto: # Any Popup aur bubble with reference
""")

class RSTGUI(BoxLayout):
    doc="""
.. _top:

Hello world
===========

This is an **emphased text**, some ``interpreted text``.
And this is a reference to top_::

    $ print("Hello world")


"""
class RST(App):
    def build(self):
        return RSTGUI()


if __name__=='__main__':
    RST().run()

【问题讨论】:

    标签: python popup kivy restructuredtext


    【解决方案1】:

    经过一番研究,我已经弄清楚了,Alhumdolillah。

    from kivy.app import App
    from kivy.uix.boxlayout import BoxLayout
    from kivy.lang import Builder
    from kivy.uix.rst import RstDocument
    from kivy.uix.popup import Popup
    
    Builder.load_string("""
    
    <RSTGUI>:
        MyRST:
            text: root.doc
    
    
    
    
    <about_us_popup>:
        size_hint: 0.8,0.6
        title: "About Us"
        BoxLayout:
            orientation:'vertical'
            RstDocument:
                text: "MyText"
            Button:
                text:"OK"
                size_hint: 1,0.1
                on_press:root.dismiss()
    
    
    
    """)
    
    
    
    class RSTGUI(BoxLayout):
    
        doc="""
    .. _top:
    
    Hello world
    ===========
    
    This is an **emphased text**, some ``interpreted text``.
    And this is a reference to top_::
    
        $ print("Hello world")
    
    """
    
    class MyRST(RstDocument):
    
        def __init__(self, **kwargs):
            super(MyRST, self).__init__(**kwargs)
            self.about_us_popup = about_us_popup()
    
        def goto(self, ref, *largs):
            self.about_us_popup.open()
    
    
    class RST(App):
        def build(self):
            return RSTGUI()
    
    
    class about_us_popup(Popup):
        pass
    
    if __name__=='__main__':
        RST().run()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多