在 python 的文本小部件中插入文本时出现问题
Problem in inserting text in text widget of python
from tkinter import *
class btr(Tk):
def __init__(self):
super(btr, self).__init__()
self.ticket = Text(self,height=12, width =70, bd = '10').grid(row=0, column=0)
self.ticket.insert(INSERT, "abcdefg")
self.ticket.insert(END, "abcdefg")
btr().mainloop()
请帮帮我。我对 tkinter(Python) 很陌生。
我正在制作一个 GUI 程序,但出现此错误
AttributeError: 'NoneType' object has no attribute 'insert'
请尽快帮助我。
您正在尝试为 Text
设置 .grid()
,而不是为它的实例设置 .grid()
。
创建Text
实例后简单设置.grid()
:
class Btr(Tk):
def __init__(self):
super(Btr, self).__init__()
self.ticket = Text(self, height=12, width=70, bd='10')
self.ticket.grid(row=0, column=0)
self.ticket.insert(INSERT, "abcdefccg")
self.ticket.insert(END, "abcdefgx")
Btr().mainloop()
from tkinter import *
class btr(Tk):
def __init__(self):
super(btr, self).__init__()
self.ticket = Text(self,height=12, width =70, bd = '10').grid(row=0, column=0)
self.ticket.insert(INSERT, "abcdefg")
self.ticket.insert(END, "abcdefg")
btr().mainloop()
请帮帮我。我对 tkinter(Python) 很陌生。
我正在制作一个 GUI 程序,但出现此错误
AttributeError: 'NoneType' object has no attribute 'insert'
请尽快帮助我。
您正在尝试为 Text
设置 .grid()
,而不是为它的实例设置 .grid()
。
创建Text
实例后简单设置.grid()
:
class Btr(Tk):
def __init__(self):
super(Btr, self).__init__()
self.ticket = Text(self, height=12, width=70, bd='10')
self.ticket.grid(row=0, column=0)
self.ticket.insert(INSERT, "abcdefccg")
self.ticket.insert(END, "abcdefgx")
Btr().mainloop()