• <bdo id='EYEes'></bdo><ul id='EYEes'></ul>

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

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

        Kivy:将小部件放在前面

        Kivy: Bring widget to front(Kivy:将小部件放在前面)
      1. <i id='xEhN2'><tr id='xEhN2'><dt id='xEhN2'><q id='xEhN2'><span id='xEhN2'><b id='xEhN2'><form id='xEhN2'><ins id='xEhN2'></ins><ul id='xEhN2'></ul><sub id='xEhN2'></sub></form><legend id='xEhN2'></legend><bdo id='xEhN2'><pre id='xEhN2'><center id='xEhN2'></center></pre></bdo></b><th id='xEhN2'></th></span></q></dt></tr></i><div id='xEhN2'><tfoot id='xEhN2'></tfoot><dl id='xEhN2'><fieldset id='xEhN2'></fieldset></dl></div>
      2. <tfoot id='xEhN2'></tfoot>

      3. <small id='xEhN2'></small><noframes id='xEhN2'>

      4. <legend id='xEhN2'><style id='xEhN2'><dir id='xEhN2'><q id='xEhN2'></q></dir></style></legend>

                <bdo id='xEhN2'></bdo><ul id='xEhN2'></ul>
                    <tbody id='xEhN2'></tbody>
                  本文介绍了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:将小部件放在前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                    <tbody id='XkxJC'></tbody>

                1. <small id='XkxJC'></small><noframes id='XkxJC'>

                      • <bdo id='XkxJC'></bdo><ul id='XkxJC'></ul>

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

                          <tfoot id='XkxJC'></tfoot>