问题描述
是否可以使用
我不想在执行过程中更改大小,我只是不想为所有按钮写大小,而只是在MyLayout中写一次。
示例:在下面的代码中,我想要一些可以更改MyLayout中所有按钮的大小但不能更改LoadFilePicker中的按钮的大小。
科林
MyLayout:
Button:
pos_hint: {"x":0.05,"top":0.95}
text:"Import config"
on_release:
root.loadPicker()
Button:
pos_hint: {"x":0.2,"top":0.9}
text:"Poll A"
<LoadFilePicker>:
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"
FileChooserListView:
id: filechooser
BoxLayout:
size_hint_y: None
height: 30
Button:
text: "Cancel"
on_release: root.cancel()
Button:
text: "Load"
on_release: root.load(filechooser.path,filechooser.selection)
这是MyLayout类的定义。
class MyLayout(FloatLayout):
def load(self,path,filename):
self.dismiss_popup()
db = DataBase(filename)
db.loadData()
def dismiss_popup(self):
self._popup.dismiss()
def loadPicker(self):
content = LoadFilePicker(load=self.load,cancel=self.dismiss_popup)
self._popup = Popup(title="Load file",content=content,size_hint=(0.9,0.9))
self._popup.open()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)