<small id='PjhIc'></small><noframes id='PjhIc'>

      • <bdo id='PjhIc'></bdo><ul id='PjhIc'></ul>
      <i id='PjhIc'><tr id='PjhIc'><dt id='PjhIc'><q id='PjhIc'><span id='PjhIc'><b id='PjhIc'><form id='PjhIc'><ins id='PjhIc'></ins><ul id='PjhIc'></ul><sub id='PjhIc'></sub></form><legend id='PjhIc'></legend><bdo id='PjhIc'><pre id='PjhIc'><center id='PjhIc'></center></pre></bdo></b><th id='PjhIc'></th></span></q></dt></tr></i><div id='PjhIc'><tfoot id='PjhIc'></tfoot><dl id='PjhIc'><fieldset id='PjhIc'></fieldset></dl></div>
    1. <legend id='PjhIc'><style id='PjhIc'><dir id='PjhIc'><q id='PjhIc'></q></dir></style></legend>

        <tfoot id='PjhIc'></tfoot>

        Kivy:将小部件放在前面

        时间:2023-10-10
      1. <tfoot id='PzScr'></tfoot>

            1. <legend id='PzScr'><style id='PzScr'><dir id='PzScr'><q id='PzScr'></q></dir></style></legend>
                <tbody id='PzScr'></tbody>

                <i id='PzScr'><tr id='PzScr'><dt id='PzScr'><q id='PzScr'><span id='PzScr'><b id='PzScr'><form id='PzScr'><ins id='PzScr'></ins><ul id='PzScr'></ul><sub id='PzScr'></sub></form><legend id='PzScr'></legend><bdo id='PzScr'><pre id='PzScr'><center id='PzScr'></center></pre></bdo></b><th id='PzScr'></th></span></q></dt></tr></i><div id='PzScr'><tfoot id='PzScr'></tfoot><dl id='PzScr'><fieldset id='PzScr'></fieldset></dl></div>
                  <bdo id='PzScr'></bdo><ul id='PzScr'></ul>

                  <small id='PzScr'></small><noframes id='PzScr'>

                  本文介绍了Kivy:将小部件放在前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  ActionBar 中的图像重叠Toolbar.(工具栏

                  解决方案

                  你应该调用 add_widget()remove_widget() 而不是从 self (这是您的 ActionButton),但来自层次结构中较高的对象.您可以存储对 ActionBar 父级的引用或仅使用 Window 对象本身:

                  from kivy.core.window 导入窗口# ...类 MyActionButton(ActionButton):# ...def close_tooltip(self, *args):Window.remove_widget(self.tooltip)def display_tooltip(self, *args):Window.add_widget(self.tooltip)

                  请注意,这可能会更改工具提示小部件的计算大小.

                  我更新了参考答案.

                  Images in ActionBar overlap Toolbar. (Toolbar is Bubble with Label)
                  My code is based on this answer.

                  Example for ActionBar button:

                  TooltipButton:
                      icon: 'images/32/quit.png'
                      text: _('Quit')
                      on_press: quit()
                  

                  TooltipButton class:

                  class TooltipButton(ActionButton):
                      tooltip = Tooltip()
                  
                      def __init__(self, **kwargs):
                          Window.bind(mouse_pos=self.on_mouse_pos)
                          super(ActionButton, self).__init__(**kwargs)
                  
                      def on_mouse_pos(self, *args):
                          if not self.get_root_window():
                              return
                          pos = args[1]
                          self.tooltip.pos = pos
                          Clock.unschedule(self.display_tooltip)  # cancel scheduled event since I moved the cursor
                          self.close_tooltip()  # close if it's opened
                          if self.collide_point(*self.to_widget(*pos)):
                              Clock.schedule_once(self.display_tooltip, 1)
                  
                      def close_tooltip(self, *args):
                          self.remove_widget(self.tooltip)
                  
                      def display_tooltip(self, *args):
                          self.tooltip.tip.text = self.text
                          self.add_widget(self.tooltip)
                  

                  Tooltip rule (superclass is Bubble):

                  <Tooltip>:
                      tip: tip
                      Label:
                          id: tip
                          text_size: self.size
                          halign: 'center'
                          text: 'Tip'
                  

                  解决方案

                  You should call add_widget() and remove_widget() not from self (which is your ActionButton) but from an object that is higher in the hierarchy. You can store a reference to a parent of ActionBar or just use Window object itself:

                  from kivy.core.window import Window
                  
                  # ...
                  
                  class MyActionButton(ActionButton):
                      # ...
                  
                      def close_tooltip(self, *args):
                          Window.remove_widget(self.tooltip)
                  
                      def display_tooltip(self, *args):
                          Window.add_widget(self.tooltip)
                  

                  Note that this will probably change the computed size of your tooltip widget.

                  I updated referenced answer.

                  这篇关于Kivy:将小部件放在前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                • <tfoot id='SvDqN'></tfoot>

                • <i id='SvDqN'><tr id='SvDqN'><dt id='SvDqN'><q id='SvDqN'><span id='SvDqN'><b id='SvDqN'><form id='SvDqN'><ins id='SvDqN'></ins><ul id='SvDqN'></ul><sub id='SvDqN'></sub></form><legend id='SvDqN'></legend><bdo id='SvDqN'><pre id='SvDqN'><center id='SvDqN'></center></pre></bdo></b><th id='SvDqN'></th></span></q></dt></tr></i><div id='SvDqN'><tfoot id='SvDqN'></tfoot><dl id='SvDqN'><fieldset id='SvDqN'></fieldset></dl></div>

                  <small id='SvDqN'></small><noframes id='SvDqN'>

                    <tbody id='SvDqN'></tbody>

                  <legend id='SvDqN'><style id='SvDqN'><dir id='SvDqN'><q id='SvDqN'></q></dir></style></legend>
                  • <bdo id='SvDqN'></bdo><ul id='SvDqN'></ul>