简体   繁体   English

python tkinter layout - 在全屏窗口和其他一些附加小部件中创建两个带有滚动条的文本小部件

[英]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 个额外的小部件:

  1. A menubar on top.顶部的菜单栏。
  2. A Text widget in on the bottom of the window with the width of the entire screen, and height of one text line in the font specs of this text widget (this will be a sort of status bar).窗口底部的文本小部件,具有整个屏幕的宽度,以及此文本小部件的字体规范中一个文本行的高度(这将是一种状态栏)。
  3. line numbers in the left of the left text widget (the main one).左侧文本小部件(主要的)左侧的行号。 There is a post on how to create it here , but I'm not sure how to add it.有关于如何创建它后在这里,但我不知道如何添加它。
  1. Menubar菜单栏
# 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)

More here更多在这里

  1. Width of the entire screen整个屏幕的宽度
    You can use .pack(side="bottom", fill="both")您可以使用.pack(side="bottom", fill="both")

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM