[英]python tkinter layout - Creating Two Text Widgets With Scrollbar in a Full-screen Window and a few other additional widgets
I want to create a program that opens in full-screen and in which the left side of the program window is a Text widget with a scrollbar on the right, such that it's width is 60% of the screen width and the right side is also a Text widget with a scrollbar and its width is 40% of the screen width, here is what I tried to do without success so far, as you can see by running this code (the blue and green colors are just for comfort):我想创建一个全屏打开的程序,其中程序窗口的左侧是一个文本小部件,右侧有一个滚动条,这样它的宽度是屏幕宽度的 60%,右侧也是一个带有滚动条的文本小部件,其宽度是屏幕宽度的 40%,这是我迄今为止尝试做但没有成功的事情,正如您通过运行此代码所看到的(蓝色和绿色只是为了舒适):
import tkinter as tk
from tkinter.scrolledtext import *
master = tk.Tk()
w = master.winfo_screenwidth()
h = master.winfo_screenheight()
master.geometry("{}x{}".format(w,h))
main = ScrolledText(master, bg="blue", width=int(0.6*w), height=h)
sec = ScrolledText(master, bg="green", width=int(0.4*w), height=h)
main.frame.place(x=0, y=0)
sec.frame.place(x=int(0.6*w), y=0)
So first of all if you could help me implement this part correctly that would be very helpful, and then there are 3 additional widgets that I would like to add to that:所以首先,如果你能帮助我正确地实现这部分,那将非常有帮助,然后我想添加 3 个额外的小部件:
# Menu bar
menubar = Menu(app)
app.config(menu=menubar)
menu = Menu(menubar, tearoff=0)
menubar.add_cascade(label="Menu", menu=menu)
menu.add_command(label="menu", command=command)
.pack(side="bottom", fill="both")
.pack(side="bottom", fill="both")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.