Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python网格不允许get()工作_Python_User Interface_Tkinter - Fatal编程技术网

python网格不允许get()工作

python网格不允许get()工作,python,user-interface,tkinter,Python,User Interface,Tkinter,当我运行以下代码并打开GUI时,当我在输入框中输入内容并按下按钮时,它会显示下面提到的错误。 但是当我使用place而不是grid时,它工作得很好。 我也在使用pyqr码库 有没有办法解决这个问题 import tkinter import pyqrcode from multiprocessing import Process, Queue from pyqrcode import * from tkinter import * from tkinter import messagebox f

当我运行以下代码并打开GUI时,当我在输入框中输入内容并按下按钮时,它会显示下面提到的错误。 但是当我使用
place
而不是
grid
时,它工作得很好。 我也在使用pyqr码库

有没有办法解决这个问题

import tkinter
import pyqrcode
from multiprocessing import Process, Queue
from pyqrcode import *
from tkinter import *
from tkinter import messagebox
from tkinter import Tk, Label, Button, Entry
class app:
    def __init__(self, master):
        self.master = master
        master.title("Prosmack qr")
        self.L1=Label(master, text="Enter the qr content").grid(row=0, column=1, columnspan =2)
        self.E1=Entry(master, text="Enter the qr content").grid(row=0,column=3)
        self.B1=Button(master, text="Save as SVG" ,command = self.message1).grid(row=1, column=1, columnspan =2)
        self.B2=Button(master, text="Save as EPS" ,command = self.message2).grid(row=1, column=3, columnspan =2)
        self.L2=Label(master,text="Copyrights owned by prosmack").grid(row=2, column=1,columnspan=5)
    def message1(self):
        url = pyqrcode.create(self.E1.get())
        print(url.terminal(quiet_zone=1))
        url.svg('uca-url.svg', scale=1)
    def message2(self):
        url = pyqrcode.create(self.E1.get())
        print(url.terminal(quiet_zone=1))
        url.eps('uca-url.eps', scale=2)
root = Tk()
app = app(root)
root.resizable(0,0)
root.mainloop
以下是终端中显示的错误:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Home\AppData\Local\Programs\Python\Python36-32\lib\idlelib\run.py", line 137, in main
    seq, request = rpc.request_queue.get(block=True, timeout=0.05)
  File "C:\Users\Home\AppData\Local\Programs\Python\Python36-32\lib\queue.py", line 172, in get
    raise Empty
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Home\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)
  File "C:\Users\Home\Documents\New folder\fk.py", line 18, in message1
    url = pyqrcode.create(self.E1.get())
AttributeError: 'NoneType' object has no attribute 'get'
.grid()
方法在Tkinter中返回
None
。因此,当您这样做时,例如:

self.L1=Label(master, text="Enter the qr content").grid(row=0, column=1, columnspan =2)
您正在将
None
分配给
self.L1
。相反,您需要将
标签
(或
条目
按钮
)的创建分成两行,如下所示:

self.L1=Label(master, text="Enter the qr content")
self.L1.grid(row=0, column=1, columnspan =2)