不能从tkinter中的Text()对象获取()(python 3.5)

时间:2016-08-17 22:27:47

标签: python object tkinter python-3.5 nonetype

我正在tkinter中创建一个应用程序,由于某种原因,我无法从Text()类的对象调用函数'get()':我收到错误

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/test_l">


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/imageView12"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/kwadrat"
        android:adjustViewBounds="true"

        />

</RelativeLayout>

我做错了什么? 这是我的代码:

AttributeError: 'NoneType' object has no attribute 'get'

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

没关系!我碰巧想通了。而不是一行说

textinput = tkinter.Text().grid(row=0,column=0)

我把它分成两行说

self.textinput = tkinter.Text()
self.textinput.grid(row=0,column=0)

而不是

self.textinput.get()

我用过

self.textinput.get('1.0','end-1c')