本文介绍了Kivy错误:属性错误:“无类型”对象没有属性“文本”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续运行一个错误,说属性错误:无类型对象没有属性文本我不知道问题出在哪里。做了相当数量的研究,但没有看到提供任何清晰的文章在这个问题上。想一想?



这是我的main.py文件



<$从kivy.app导入App
从kivy.uix.accordion导入Accordion,AccordionItem
从kivy.uix.tabbedpanel导入TabbedPanel
从从kivy.factory进口厂$ b kivy.lang进口生成器
kivy.uix.gridlayout进口网格布局
kivy.uix.floatlayout进口FloatLayout
.boxlayout进口的BoxLayout

$ b from kivy.uix.popup从kivy.uix.button导入弹出
导入按钮
从kivy.uix.widget导入
导入小部件
从kivy .uix.scrollview import从kivy.graphics导入ScrollView
从kivy.properties导入*
导入ObjectProperty

类OptionMenu(GridLayout):

的loadFile = OBJECTPROPERTY(无)
SAVEFILE = OBJECTPROPERTY(无)
TEXT_INPUT = OBJECTPROPERTY(无)
DEF dismiss_popup(个体):
self._popup.dismiss()

def show_load(self):
content = LoadDialog(load = self.load,cancel = self.dismiss_popup)
self._popup = Popup(title =Load file,content = content,size_hint =(0.9,0.9))
self._popup.open()

def load(self,path,filename):
with open(os.path。 join(path,filename [0]))as stream:
self.text_input.text = stream.read()
self.dismiss_popup()
$ b def show_save(self) :
content = SaveDialog(save = self.save,cancel = self.dismiss_popup)
self._popup = Popup(title =Save file,content = content,
size_hint =(0.9 ,0.9))
self._popup.open()

def save(self,path,filename):
with open(os.path.join(path,filename) , w')as stream:
stream.write(self.text_input.text)

self.dismiss_popup()
class GraphMenu(GridLayout):
pass
类UnnamedMenu(GridLayout的):


类LoadDialog(FloatLayout):
负载= OBJECTPROPERTY(无)
取消= OBJECTPROPERTY(无)
$ b $ class saveDialog(FloatLayout):
save = ObjectProperty(None)
text_input = ObjectProperty(None)
cancel = ObjectProperty(None)



class MainController(FloatLayout):
pass

$ b class MainApp(App):
def build(self):
rt = MainController()
return rt
Factory.register('Main',cls = MainController)
Factory.register('LoadDialog',cls = LoadDialog)
Factory.register ('SaveDialog',cls = SaveDialog)

if __name__ =='__main__':
MainApp()。run()

这是我的main.kv文件:

#kivy 1.0< OptionMenu>文本输入文件:输入文件on_release:self.parent.show_load()按钮:size_hint_y:0.05文本:保存文件on_release:self.parent.show_save()TextInput:id: text_input text:''RstDocument:text:text_input.text show_errors:True< MainController> BoxLayout:orientation:'horizo​​ntal'Accordion:size_hint_x:0.3 orientation:'vertical'AccordionItem:title:'Options'OptionMenu:id:'AppOpt'AccordionItem:title:'Config'UnnamedMenu:id:ConfigTab AccordionItem:title:'Graph' GraphMenu:id:GraphTab FloatLayout:size_hint_x:0.7标签:< scroller> < LoadDialog计算值:BoxLayout的:尺寸:root.size POS:root.pos取向: 垂直 FileChooserListView:ID:使用FileChooser的BoxLayout:size_hint_y:无高度:10按钮:文本: 取消 on_release:root.cancel()按钮:文本: 装载 on_release:root.load(filechooser.path,filechooser.selection)LT; SaveDialog计算值:TEXT_INPUT:TEXT_INPUT BoxLayout的:尺寸:root.size POS:root.pos取向: 垂直 FileChooserListView:ID:使用FileChooser on_selection:text_input.text = self.selection和self.selection [0]或 '' 的TextInput:ID:TEXT_INPUT size_hint_y:无高度:30的多行:假的BoxLayout:size_hint_y:无高度:30按钮:文本: 取消 on_release:根。取消()按钮:文本:保存on_release:root.save(filechooser.path,text_input.text)



这是完整的错误信息和堆栈转储:

\我的文件\下载\Kivy-1.8.0-py2.7-win32\设置环境变量:####################### ########## GST_REGISTRYC:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\registry.bin ------ --------- GST_PLUGIN_PATH:C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\lib\gstreamer-1.0-- -------------路径:C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\; C:\Users\\ \\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\Python27; C:\Users\\ My.Files\Downloads\Kivy-1.8.0-py2.7-win32\tools; C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\\ \\Python27\Scripts; C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\bin; C:\Users\Adit.Shah\\ \\下载\Kivy-1.8.0-py2.7-win32\MinGW\bin; C:\程序文件(x86)\ RSA SecurID令牌通用; C:\程序文件(x86)\英特尔\ iCLS Client \; C:\ Program Files \Intel\iCLS Client\; C:\ Windows \ system32; C:\ Windows; C:\ Windows \ System32 \Wbem; C:\ Windows \ System32 \WindowsPowerShell\\\v1.0\; C:\程序文件\Intel\WiFi\bin\; C:\程序文件\普通文件\英特尔\WirelessCommon\; C:\程序文件\SAS\SharedFiles(32)\Formats; c:\程序文件(x86)\ Microsoft SQL Server \ 110 \Tools\Binn\ ManagementStudio\; C:\\ Program Files(x86)\ Microsoft SQL Server \ 110 \Tools\Binn\; c:\ Program Files(x86)\ Microsoft SQL Server \ 110 \DTS\Binn\ --- ------------------------------- PYTHONPATH:C:\Users\My.Files\Downloads\Kivy- 1.8.0-py2.7-win32\kivy; ---------------------------------- ### ############################### done bootstraping kivy ...玩得开心!\\\
runningpython.exeD: \ workspace \kivyWork\GUI\main.py\\\
[INFO] Kivy v1.8.0 [INFO] [Logger]记录日志C:\ Users \ My.Files \.kivy\\ \\logs\kivy_15-02-19_77.txt [INFO] [Factory]加载157个符号[DEBUG] [Cache]寄存器< kv.lang> with limit = None,timeout = Nones [DEBUG] [Cache] register< kv.image> limit = None,timeout = 60s [DEBUG] [Cache]寄存器< kv.atlas> limit = None,timeout = Nones [INFO] [Image] Providers:img_tex,img_dds,img_pygame,img_gif(img_pil ignored)[DEBUG] [Cache] register< kv.texture> limit = 1000,timeout = 60s [DEBUG] [Cache]寄存器< kv.shader>限制= 1000,超时= 3600s [INFO] [文本]提供程序:pygame [DEBUG] [窗口]忽略< egl_rpi> (导入错误)[INFO] [窗口]提供者:pygame的([ 'window_egl_rpi']忽略)[调试] [窗口]显示驱动windib [DEBUG] [窗口]实际窗口大小:800×600 [DEBUG] [窗口]实际颜色位实际深度位:24 [调试] [窗口]实际模板位:8 [调试] [窗口]实际多重采样:4GLEW初始化成功[信息] [GL] OpenGL版本< 4.2 OpenGL供应商< Intel> [INFO] [GL] OpenGL渲染器< Intel?HD Graphics 4400> [INFO] [GL] OpenGL解析版本:4 ,2 [INFO] [GL]着色版本< 4.20-生成10.18.10.3621> [INFO] [GL]纹理最大尺寸< 16384> [INFO] [GL]纹理最大单位< ; 32> [DEBUG] [Shader] Fragment编译成功[DEBUG] [Shader] Vertex编译成功[DEBUG] [ImagePygame] Load< C:\ Users \ My.Files \Downloads\Kivy-1.8.0 -py2.7-win32\kivy\kivy\data\glsl\default.png> [INFO] [Window]不允许虚拟键盘,单一模式,不停靠[DEBUG] [App]加载kv< D:\ workspace \kivyWork\GUI\main.kv> [DEBUG] [Cache] register< kv.loader> limit = 500,timeout = 60s [INFO] [Loader]使用2个worker的线程池[DEBUG] [Cache] register< textinput.label> with limit = None,timeout = 60.0s [DEBUG] [Cache] register< textinput.width>限制=无,超时= 60.0s [调试] [图集]加载< C:\ Users \My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy \data\\\data\images\defaulttheme.atlas> [DEBUG] [Atlas]需要加载1张图片[DEBUG] [Atlas]加载< C:\ Users \ My.Files \\ \\下载\Kivy-1.8.0-py2.7-win32\kivy\kivy\data\\\\data\images\defaulttheme-0.png> [DEBUG] [ImagePygame] Load< ; C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\data\..\data\images\defaulttheme- 0.png> [INFO] [VideoGstplayer]使用Gstreamer 1.2.1.0 [INFO] [Video] Provider:gstplayer [INFO] [OSC] using< thread>对于套接字[DEBUG] [Base]从鼠标创建提供者[DEBUG] [Base]从wm_touch创建提供者[DEBUG] [Base]从wm_pen创建提供者[INFO] [Base]启动应用程序主循环[INFO] [GL] NPOT纹理支持可用[WARNING] [Accordion]没有足够的空间来显示所有的孩子[WARNING] [Accordion]需要132px,得到100px [WARNING] [Accordion]布局中止[WARNING]< __ main __,0x07106810的UnnamedMenu对象>没有设置列或行,布局没有触发。[警告]< __ main __。0x007106A40的GraphMenu对象> [WARNING] [Accordion]没有足够的空间显示所有的孩子[WARNING] [Accordion]需要132px,得到100px [WARNING] [Accordion]布局中止[WARNING]< __main __。在0x07106A40处的GraphMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>没有列或行设置,布局没有触发。[警告]< __ main __。0x07106810的UnnamedMenu对象>无法设置列或行,布局不会触发[错误]无法访问< \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ Kivy-1.8.0-py2.7-win32 \kivy\kivy\uix\filechooser.py,第122行,在is_hidden中返回GetFileAttributesExW(fn)[0]& FILE_ATTRIBUTE_HIDDENerror:(32,GetFileAttributesEx,因为它被另一个进程的进程不能访问该文件)[ERROR]无法访问到< \pagefile.sys>回溯(最近最后调用):文件C:\ Users \ My.Files \Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\uix\filechooser.py,第122行,在is_hidden返回GetFileAttributesExW(fn)[0]& FILE_ATTRIBUTE_HIDDENerror:(32,'GetFileAttributesEx','进程无法访问该文件,因为它被另一个进程使用')[INFO] [Base]正在离开应用程序进程... Traceback(最近一次调用的最后一个文件) D:\workspace\kivyWork\GUI\main.py,第76行,位于< module> MainApp()。run()文件C:\ Users \ My.Files \Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\app.py,第792行,运行runTouchApp()文件C:\ Users \ My.Files \Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py,第481行,在runTouchApp EventLoop.window.mainloop()文件C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\core\window\\ \\ window \\ pygame.py行381,在mainloop self._mainloop()文件C:\ Users \My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy \core\window\window_pygame.py 线287,在_mainloop EventLoop.idle()文件 C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7- win32 \kivy\kivy\base.py,第324行,在空闲self.dispatch_input()文件C:\ Users \My.Files\Downloads\Kivy-1.8.0-py2.7 -win32 \kivy\kivy\base.py,第309行,显示atch_input post_dispatch_input(* pop(0))文件C:\ Users \ My.Files \Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py,线275,在post_dispatch_input wid.dispatch( 'on_touch_up',我)文件 _event.pyx,线路316,在kivy._event.EventDispatcher.dispatch(kivy\_event.c:4409)文件C:\Users \My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\uix\behaviors.py,线110,在on_touch_up self.dispatch( 'on_release')文件_event.pyx行312,在kivy._event.EventDispatcher.dispatch(kivy \_event.c:4359)文件C:\ Users \ My.Files \Downloads\Kivy-1.8.0 -py2.7-win32 \kivy\kivy\lang.py,第1299行,在custom_callback exec(__ kvlang __。co_value,idmap)文件D:\workspace\kivyWork\GUI\main.kv ,第63行,在< module> on_release:root.load(filechooser.path,filechooser.selection)文件D:\workspace\kivyWork\GUI\main.py,第34行,载入self.text_input.text = stream.read() AttributeError:'NoneType'对象没有任何属性'text'按任意键继续。 。 。

设置 text_input 的值,所以它仍然是默认的 None 。只是设置一个ID不会设置该属性。这里有几个简单的修复。

首先,您可以填写该值:

 < OptionMenu>:
#设置text_input属性为
下面的text_input id的值
text_input:text_input
。 ..
TextInput:
id:text_input
...

或者,您可以通过 ids 集合来访问该小部件,并完全删除 text_input 属性:


$ b $

  def load(self,path,filename):
with open(os.path.join(path,filename [0]) )作为流:
#self.ids是这个小部件规则的id的集合
self.ids.text_input.text = stream.read()
self.dismiss_popup()


Keep running into a error that says "Attribute Error: 'None Type' object has no attribute 'text'. I have no idea where the problem is. Did a fair amount of research, but saw no posts that provided any clarity on the issue. Thoughts?

This is my main.py file

from kivy.app import App
from kivy.uix.accordion import Accordion, AccordionItem
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.lang import Builder
from kivy.factory import Factory

from kivy.uix.popup import Popup
from kivy.uix.button import Button
import os
from kivy.uix.widget import Widget
from kivy.uix.scrollview import ScrollView
from kivy.graphics import *
from kivy.properties import ObjectProperty

class OptionMenu(GridLayout):

    loadfile = ObjectProperty(None)
    savefile = ObjectProperty(None)
    text_input = ObjectProperty(None)
    def dismiss_popup(self):
        self._popup.dismiss()

    def show_load(self):
        content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
        self._popup = Popup(title="Load file", content=content, size_hint=(0.9, 0.9))
        self._popup.open()

    def load(self, path, filename):
        with open(os.path.join(path, filename[0])) as stream:
            self.text_input.text = stream.read()
        self.dismiss_popup()

    def show_save(self):
        content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
        self._popup = Popup(title="Save file", content=content,
                            size_hint=(0.9, 0.9))
        self._popup.open()

    def save(self, path, filename):
        with open(os.path.join(path, filename), 'w') as stream:
            stream.write(self.text_input.text)

        self.dismiss_popup()
class GraphMenu(GridLayout):
    pass
class UnnamedMenu(GridLayout):
    pass

class LoadDialog(FloatLayout):
    load = ObjectProperty(None)
    cancel = ObjectProperty(None)

class SaveDialog(FloatLayout):
    save = ObjectProperty(None)
    text_input = ObjectProperty(None)
    cancel = ObjectProperty(None)



class MainController(FloatLayout):
    pass


class MainApp(App):
    def build(self):
        rt = MainController()
        return rt
Factory.register('Main', cls=MainController)
Factory.register('LoadDialog', cls=LoadDialog)
Factory.register('SaveDialog', cls=SaveDialog)

if __name__ == '__main__':
    MainApp().run()

This is my main.kv file:

#kivy 1.0
<OptionMenu>
    cols: 2
	row:10
    Button:
        size_hint_y: 0.05
        text: "Input File"
        on_release: self.parent.show_load()
	Button:
		size_hint_y:0.05
		text:"Save File"
		on_release:self.parent.show_save()
    TextInput:
        id: text_input
		text:''
	RstDocument:
		text: text_input.text
		show_errors: True

<MainController>
    BoxLayout:
        orientation: 'horizontal'
        Accordion:
            size_hint_x: 0.3
            orientation: 'vertical'
            AccordionItem:
                title:'Options'
                OptionMenu:
                    id: 'AppOpt'
			AccordionItem:
				title:'Config'
				UnnamedMenu:
					id:ConfigTab
			AccordionItem:
				title:'Graph'
				GraphMenu:
					id:GraphTab

        FloatLayout:
            size_hint_x: 0.7
            Label:

<scroller>


<LoadDialog>:
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"
        FileChooserListView:
            id: filechooser

        BoxLayout:
            size_hint_y: None
            height: 10
            Button:
                text: "Cancel"
                on_release: root.cancel()

            Button:
                text: "Load"
                on_release: root.load(filechooser.path, filechooser.selection)
<SaveDialog>:
    text_input: text_input
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"
        FileChooserListView:
            id: filechooser
            on_selection: text_input.text = self.selection and self.selection[0] or ''

        TextInput:
            id: text_input
            size_hint_y: None
            height: 30
            multiline: False

        BoxLayout:
            size_hint_y: None
            height: 30
            Button:
                text: "Cancel"
                on_release: root.cancel()

            Button:
                text: "Save"
                on_release: root.save(filechooser.path, text_input.text)

This is the full error message and stack dump:

botstrapping Kivy @ C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\
Setting Environment Variables:
#################################
GST_REGISTRY
C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\registry.bin
---------------
GST_PLUGIN_PATH:
C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\lib\gstreamer-1.0
---------------
PATH:
C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\;C:\Users\My.Files\Download
s\Kivy-1.8.0-py2.7-win32\Python27;C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-
win32\tools;C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\Python27\Scripts
;C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\gstreamer\bin;C:\Users\Adit
.Shah\Downloads\Kivy-1.8.0-py2.7-win32\MinGW\bin;C:\Program Files (x86)\RSA Secu
rID Token Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Inte
l\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Window
s\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program F
iles\Common Files\Intel\WirelessCommon\;C:\Program Files\SAS\SharedFiles(32)\For
mats;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio
\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (
x86)\Microsoft SQL Server\110\DTS\Binn\
----------------------------------
PYTHONPATH:
C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy;
----------------------------------
##################################
done bootstraping kivy...have fun!\n
running "python.exe "D:\workspace\kivyWork\GUI\main.py"" \n
[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in C:\Users\My.Files\.kivy\logs\
kivy_15-02-19_77.txt
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=
Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout
=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout
=Nones
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img
_gif (img_pil ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeo
ut=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeou
t=3600s
[INFO              ] [Text        ] Provider: pygame
[DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
[INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)

[DEBUG             ] [Window      ] Display driver windib
[DEBUG             ] [Window      ] Actual window size: 800x600
[DEBUG             ] [Window      ] Actual color bits r8 g8 b8 a8
[DEBUG             ] [Window      ] Actual depth bits: 24
[DEBUG             ] [Window      ] Actual stencil bits: 8
[DEBUG             ] [Window      ] Actual multisampling samples: 4
GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <4.2.0 - Build 10.18.10.3621>

[INFO              ] [GL          ] OpenGL vendor <Intel>
[INFO              ] [GL          ] OpenGL renderer <Intel(R) HD Graphics 4400>
[INFO              ] [GL          ] OpenGL parsed version: 4, 2
[INFO              ] [GL          ] Shading version <4.20 - Build 10.18.10.3621>

[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[DEBUG             ] [Shader      ] Fragment compiled successfully
[DEBUG             ] [Shader      ] Vertex compiled successfully
[DEBUG             ] [ImagePygame ] Load <C:\Users\My.Files\Downloads\Kivy-1.8.
0-py2.7-win32\kivy\kivy\data\glsl\default.png>
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, n
ot docked
[DEBUG             ] [App         ] Loading kv <D:\workspace\kivyWork\GUI\main.k
v>
[DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout
=60s
[INFO              ] [Loader      ] using a thread pool of 2 workers
[DEBUG             ] [Cache       ] register <textinput.label> with limit=None,
timeout=60.0s
[DEBUG             ] [Cache       ] register <textinput.width> with limit=None,
timeout=60.0s
[DEBUG             ] [Atlas       ] Load <C:\Users\My.Files\Downloads\Kivy-1.8.
0-py2.7-win32\kivy\kivy\data\..\data\images\defaulttheme.atlas>
[DEBUG             ] [Atlas       ] Need to load 1 images
[DEBUG             ] [Atlas       ] Load <C:\Users\My.Files\Downloads\Kivy-1.8.
0-py2.7-win32\kivy\kivy\data\..\data\images\defaulttheme-0.png>
[DEBUG             ] [ImagePygame ] Load <C:\Users\My.Files\Downloads\Kivy-1.8.
0-py2.7-win32\kivy\kivy\data\..\data\images\defaulttheme-0.png>
[INFO              ] [VideoGstplayer] Using Gstreamer 1.2.1.0
[INFO              ] [Video       ] Provider: gstplayer
[INFO              ] [OSC         ] using <thread> for socket
[DEBUG             ] [Base        ] Create provider from mouse
[DEBUG             ] [Base        ] Create provider from wm_touch
[DEBUG             ] [Base        ] Create provider from wm_pen
[INFO              ] [Base        ] Start application main loop
[INFO              ] [GL          ] NPOT texture support is available
[WARNING           ] [Accordion   ] not enough space for displaying all children

[WARNING           ] [Accordion   ] need 132px, got 100px
[WARNING           ] [Accordion   ] layout aborted.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.GraphMenu object at 0x07106A40> have no cols or r
ows set, layout is not triggered.
[WARNING           ] [Accordion   ] not enough space for displaying all children

[WARNING           ] [Accordion   ] need 132px, got 100px
[WARNING           ] [Accordion   ] layout aborted.
[WARNING           ] <__main__.GraphMenu object at 0x07106A40> have no cols or r
ows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[WARNING           ] <__main__.UnnamedMenu object at 0x07106810> have no cols or
 rows set, layout is not triggered.
[ERROR             ] unable to access to <\hiberfil.sys>
Traceback (most recent call last):
  File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\uix\filech
ooser.py", line 122, in is_hidden
    return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
error: (32, 'GetFileAttributesEx', 'The process cannot access the file because i
t is being used by another process.')
[ERROR             ] unable to access to <\pagefile.sys>
Traceback (most recent call last):
  File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\uix\filech
ooser.py", line 122, in is_hidden
    return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
error: (32, 'GetFileAttributesEx', 'The process cannot access the file because i
t is being used by another process.')
[INFO              ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "D:\workspace\kivyWork\GUI\main.py", line 76, in <module>
     MainApp().run()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\app.py",
line 792, in run
     runTouchApp()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py",
 line 481, in runTouchApp
     EventLoop.window.mainloop()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\core\wind
ow\window_pygame.py", line 381, in mainloop
     self._mainloop()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\core\wind
ow\window_pygame.py", line 287, in _mainloop
     EventLoop.idle()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py",
 line 324, in idle
     self.dispatch_input()
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py",
 line 309, in dispatch_input
     post_dispatch_input(*pop(0))
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\base.py",
 line 275, in post_dispatch_input
     wid.dispatch('on_touch_up', me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_e
vent.c:4409)
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\uix\behav
iors.py", line 110, in on_touch_up
     self.dispatch('on_release')
   File "_event.pyx", line 312, in kivy._event.EventDispatcher.dispatch (kivy\_e
vent.c:4359)
   File "C:\Users\My.Files\Downloads\Kivy-1.8.0-py2.7-win32\kivy\kivy\lang.py",
 line 1299, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "D:\workspace\kivyWork\GUI\main.kv", line 63, in <module>
     on_release: root.load(filechooser.path, filechooser.selection)
   File "D:\workspace\kivyWork\GUI\main.py", line 34, in load
     self.text_input.text = stream.read()
 AttributeError: 'NoneType' object has no attribute 'text'
Press any key to continue . . .

解决方案

You never set the value of text_input, so it is still the default None. Just setting an id doesn't set that attribute. There are a couple easy fixes here.

First, you can fill in that value:

<OptionMenu>:
    # this sets the `text_input` attribute to the value
    # of the `text_input` id below
    text_input: text_input
    ...
    TextInput:
        id: text_input
    ...

Alternatively, you can access the widget via the ids collection, and remove the text_input attribute completely:

def load(self, path, filename):
    with open(os.path.join(path, filename[0])) as stream:
        # self.ids is the collection of ids for this widget rule
        self.ids.text_input.text = stream.read()
    self.dismiss_popup()

这篇关于Kivy错误:属性错误:“无类型”对象没有属性“文本”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 16:39