Why is `None` returned instead of tkinter.Entry object?

后端 未结 3 2065
别跟我提以往
别跟我提以往 2020-12-20 23:51

I\'m new to python, poking around and I noticed this:

from tkinter import *
def test1():
    root = Tk()
    txtTest1 = Entry(root).place(x=10, y=10)
    pri         


        
3条回答
  •  执念已碎
    2020-12-21 00:31

    because Entry.place() returns None

    in a more C-like language you could do:

    (txtTest1 = Entry(root)).place(x=10, y=10)
    

    and txtText1 would be the Entry object, but that syntax is illegal in Python.

提交回复
热议问题