简体   繁体   English

AttributeError: 'int' 对象没有属性 'get' 我该如何修复它

[英]AttributeError: 'int' object has no attribute 'get' how can i fix it

Hey i tryed to make a canvas in tkinter and make the entry to a global variable but i get the error (AttributeError: 'int' object has no attribute 'get')嘿,我试图在 tkinter 中制作一个画布并输入一个全局变量,但我得到了错误(AttributeError: 'int' object has no attribute 'get')

def a():
 a1 = e1.get()
 b1 = e2.get()
 c1 = e3.get()
 print(a, b, c)

def window():
 window = Tk()

 my_canvas = Canvas(window, width=530, height=240, bd=0, highlightthickness=0)
 my_canvas.pack(fill="both", expand=True)

 global e1, e2, e3

 e1 = Entry(window, fg="black", bd=0)
 e2 = Entry(window, fg="black", bd=0)
 e3 = Entry(window, fg="black", bd=0)
 
 e1 = my_canvas.create_window(40, 20, anchor="nw", window=e1)
 e2 = my_canvas.create_window(40, 60, anchor="nw", window=e2)
 e3 = my_canvas.create_window(40, 100, anchor="nw", window=e3)

 button1 = Button(window, text='Print', bd=0, bg="black", fg="white", command=a)
 
 button1 = my_canvas.create_window(400, 20, anchor="nw", window=button1)
 
 window.mainloop()

 p = Process(target=window)
 p.start()
 p.join()

You are calling get on .create_window object您正在调用get on .create_window对象

You should not run over the Entry objects:你不应该跑过Entry对象:

from tkinter import Tk, Canvas, Button, Entry
from multiprocessing import Process

def a():
    a = e1.get()
    b = e2.get()
    c = e3.get()
    print(a, b, c)


def window():
    window = Tk()

    my_canvas = Canvas(window, width=530, height=240, bd=0, highlightthickness=0)
    my_canvas.pack(fill="both", expand=True)

    global e1, e2, e3

    e1 = Entry(window, fg="black", bd=0)
    e2 = Entry(window, fg="black", bd=0)
    e3 = Entry(window, fg="black", bd=0)

    e1_w = my_canvas.create_window(40, 20, anchor="nw", window=e1)
    e2_w = my_canvas.create_window(40, 60, anchor="nw", window=e2)
    e3_w = my_canvas.create_window(40, 100, anchor="nw", window=e3)

    button1 = Button(window, text='Print', bd=0, bg="black", fg="white", command=a)

    button1 = my_canvas.create_window(400, 20, anchor="nw", window=button1)

    window.mainloop()

    p = Process(target=window)
    p.start()
    p.join()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我该如何修复,AttributeError: 'NoneType' 对象没有属性 'send' - How can I fix, AttributeError: 'NoneType' object has no attribute 'send' 我该如何解决这个问题:AttributeError: 'NoneType' object has no attribute 'strip - How can i fix this :AttributeError: 'NoneType' object has no attribute 'strip AttributeError: 'function' object 没有属性 'read' — 我该如何修复? - AttributeError: 'function' object has no attribute 'read' — HOW CAN I FIX? AttributeError: 'function' object 没有属性 'split'。 我该如何解决? - AttributeError: 'function' object has no attribute 'split'. How I can fix it? 无法修复 Python 错误 AttributeError: 'int' object 没有属性 'get' - Cant fix Python error AttributeError: 'int' object has no attribute 'get' 如何修复AttributeError:“ int”对象在双向层中没有属性“ get_config” - How to fix AttributeError: 'int' object has no attribute 'get_config' in Bidirectional Layer AttributeError 'int' 对象没有属性 'get' - AttributeError 'int' object has no attribute 'get' AttributeError:“ int”对象没有属性“ get” - AttributeError: 'int' object has no attribute 'get' 如何修复“列表”object 在 Python/Django 中没有属性“get”(AttributeError) - How to fix 'list' object has no attribute 'get' (AttributeError) in Python/Django 如何修复 AttributeError: 'str' object has no attribute 'get_side' - How to fix AttributeError: 'str' object has no attribute 'get_side'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM