python - 在滚动视图中将 minimum_height 绑定到 boxlayout 时出现键错误
问题描述
如何在 python 端的 ScrollView 中将 minimum_height 绑定到 BoxLayout?
这就是我所在的位置:
class BrokenScreen(screen):
def __init__(self, **kwargs):
super(BrokenScreen,self).__init__(**kwargs)
# build widgets
self.pop = Popup(auto_dismiss=False,size=(.8,.8))
self.box = BoxLayout(orientation='vertical', size_hint_y=None)
self.scroll = ScrollView()
# bind height, this is the line bringing about the error
self.box.bind(minimum_height=self.box.setter('height'))
# integrate
self.scroll.add_widget(self.box)
self.pop.add_widget(self.scroll)
当我尝试编译时,我收到以下错误:
KeyError: 'minimum_height'
做什么?
解决方案
Miket25 问是否box
有minimum_height
争论。
我能够通过使用 GridLayout 来解决我的问题。所以,可能不是(编辑:我是否错了box
has minimum_height
,请参阅接受的回复)。
# build widgets
self.pop = Popup(auto_dismiss=False,size=(.8,.8))
self.grid = GridLayout(cols=1, size_hint_y=None) #<- change this
self.scroll = ScrollView(size=self.size)
# bind height, this is the line bringing about the error
self.grid.bind(minimum_height=self.grid.setter('height')) # only changed var name
# integrate
self.scroll.add_widget(self.grid) # changed var name
self.pop.add_widget(self.scroll)
推荐阅读
- python - 具有大参数列表的python中的多处理
- html - 如何使 2 个表格高度相同,同时对其中一个表格使用警报
- google-apps-script - 您无法切换到 Apps 脚本创建的 Cloud Platform 项目 - 将 Apps 脚本文件与 Cloud 项目相关联
- python - 如何将 cross_validation 与 curve_fit 一起使用?
- c# - 在不同的运行期间解密加密的字符串
- javascript - 在哪里可以找到添加到 MicroTask Queue 的项目的完整列表?
- git - git 存储库中的 Composer 包冲突;如何在推送到远程时取消跟踪文件但避免删除文件
- python - 查找分类数据的十分位数?
- ruby-on-rails - 您可以使用 Webpacker 在 Rails 6 应用程序中直接使用 Web3.js 吗?
- crystal-reports - Crystal Reports 中的坐标系