【发布时间】:2018-07-01 08:27:25
【问题描述】:
我想将选择变量从 load_file_popup 文件选择器传递到 GUI。当我在选择文件后按下加载按钮时会出错
TypeError: 'NoneType' 对象不可调用
这是我的代码(简化)
class GUI(BoxLayout):
file_path = StringProperty("Currently No File")
def __init__(self, **kwargs):
super(GUI, self).__init__(**kwargs)
self.load_file_popup = load_file_popup()
def load(self, selection):
self.file_path = str(selection[0])
self.dismiss()
class load_file_popup(Popup):
load = ObjectProperty()
这里是千伏
<load_file_popup>:
title: "Select File"
size_hint: .9, .9
SMSBoxLayout:
orientation: "vertical"
FileChooser:
id: filechooser
FileChooserIconLayout
SMSBoxLayout:
size_hint: (1, 0.1)
pos_hint: {'center_x': .5, 'center_y': .5}
SMSButton:
text: "Cancel"
on_release: root.dismiss()
SMSButton:
text: "Load"
on_release: root.load(filechooser.selection)
id: ldbtn
disabled: True if filechooser.selection==[] else False
【问题讨论】:
标签: python popup kivy filechooser