Python 第二个文本编辑器小部件在框架tkinter中不可见
我正在使用Tkinter为项目制作IDE。我试图在一个框架中添加两个文本小部件,当我尝试这样做时,只会看到一个文本编辑器。我也尝试过在框架内使用.grid(),但它弄乱了布局,仍然没有显示出来 以下是我的代码(如果有帮助):Python 第二个文本编辑器小部件在框架tkinter中不可见,python,user-interface,tkinter,ide,Python,User Interface,Tkinter,Ide,我正在使用Tkinter为项目制作IDE。我试图在一个框架中添加两个文本小部件,当我尝试这样做时,只会看到一个文本编辑器。我也尝试过在框架内使用.grid(),但它弄乱了布局,仍然没有显示出来 以下是我的代码(如果有帮助): my_frame = Frame(window) my_frame.pack(pady=5, fill = X) #Scrollbar for the text editor text_scroll = Scrollbar(my_frame) text_scroll.p
my_frame = Frame(window)
my_frame.pack(pady=5, fill = X)
#Scrollbar for the text editor
text_scroll = Scrollbar(my_frame)
text_scroll.pack(side = RIGHT, fill =Y)
# Horizontal Scrollbar
hor_scroll = Scrollbar(my_frame, orient = 'horizontal')
hor_scroll.pack(side = BOTTOM, fill = X)
#Text Widget (Text Editor)
text = Text(my_frame, width = 100, height = 200, font = ("Helvetica",10),selectbackground = "black", selectforeground = "white", undo = True, yscrollcommand = text_scroll.set, wrap = "none",xscrollcommand = hor_scroll.set)
text.pack(side = TOP)
#Text Widget (Status Console)
console = Text(my_frame, width = 100, height = 200, font = ("Helvetica",10),selectbackground = "black", selectforeground = "white", undo = True, yscrollcommand = text_scroll.set, wrap = "none",xscrollcommand = hor_scroll.set)
console.pack(side = BOTTOM)
谢谢,,
Dhruv Guptaheight=200
(表示200行,而不是像素)使文本
小部件非常高,因此第二个文本
放在可视区域之外。尝试较小的高度值
。