我想创建一个具有10个文本框的SCROLL-ABLE主窗口。由于这些文本框无法容纳在一个窗口中,因此我想垂直和水平添加滚动条以查看主屏幕上不适合的文本框。
我用PAGE开发tkinter代码。这是上面输出的代码:
import sys
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
top = New_Toplevel (root)
root.mainloop()
w = None
def create_New_Toplevel(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
top = New_Toplevel (w)
return (w, top)
def destroy_New_Toplevel():
global w
w.destroy()
w = None
class New_Toplevel:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
top.geometry("1366x705+471+151")
top.title("New Toplevel")
top.configure(background="#d9d9d9")
self.Text1 = Text(top)
self.Text1.place(relx=0.01, rely=0.06, relheight=0.57, relwidth=0.39)
self.Text1.configure(background="white")
self.Text1.configure(font="TkTextFont")
self.Text1.configure(foreground="black")
self.Text1.configure(highlightbackground="#d9d9d9")
self.Text1.configure(highlightcolor="black")
self.Text1.configure(insertbackground="black")
self.Text1.configure(selectbackground="#c4c4c4")
self.Text1.configure(selectforeground="black")
self.Text1.configure(width=534)
self.Text1.configure(wrap=WORD)
self.Text1_1 = Text(top)
self.Text1_1.place(relx=0.42, rely=0.06, relheight=0.57, relwidth=0.41)
self.Text1_1.configure(background="white")
self.Text1_1.configure(font="TkTextFont")
self.Text1_1.configure(foreground="black")
self.Text1_1.configure(highlightbackground="#d9d9d9")
self.Text1_1.configure(highlightcolor="black")
self.Text1_1.configure(insertbackground="black")
self.Text1_1.configure(selectbackground="#c4c4c4")
self.Text1_1.configure(selectforeground="black")
self.Text1_1.configure(width=554)
self.Text1_1.configure(wrap=WORD)
self.Text1_2 = Text(top)
self.Text1_2.place(relx=0.84, rely=0.06, relheight=0.57, relwidth=0.28)
self.Text1_2.configure(background="white")
self.Text1_2.configure(font="TkTextFont")
self.Text1_2.configure(foreground="black")
self.Text1_2.configure(highlightbackground="#d9d9d9")
self.Text1_2.configure(highlightcolor="black")
self.Text1_2.configure(insertbackground="black")
self.Text1_2.configure(selectbackground="#c4c4c4")
self.Text1_2.configure(selectforeground="black")
self.Text1_2.configure(width=384)
self.Text1_2.configure(wrap=WORD)
self.Text1_3 = Text(top)
self.Text1_3.place(relx=0.01, rely=0.67, relheight=0.57, relwidth=0.39)
self.Text1_3.configure(background="white")
self.Text1_3.configure(font="TkTextFont")
self.Text1_3.configure(foreground="black")
self.Text1_3.configure(highlightbackground="#d9d9d9")
self.Text1_3.configure(highlightcolor="black")
self.Text1_3.configure(insertbackground="black")
self.Text1_3.configure(selectbackground="#c4c4c4")
self.Text1_3.configure(selectforeground="black")
self.Text1_3.configure(width=534)
self.Text1_3.configure(wrap=WORD)
self.Text1_4 = Text(top)
self.Text1_4.place(relx=0.42, rely=0.67, relheight=0.57, relwidth=0.41)
self.Text1_4.configure(background="white")
self.Text1_4.configure(font="TkTextFont")
self.Text1_4.configure(foreground="black")
self.Text1_4.configure(highlightbackground="#d9d9d9")
self.Text1_4.configure(highlightcolor="black")
self.Text1_4.configure(insertbackground="black")
self.Text1_4.configure(selectbackground="#c4c4c4")
self.Text1_4.configure(selectforeground="black")
self.Text1_4.configure(width=554)
self.Text1_4.configure(wrap=WORD)
self.Text1_5 = Text(top)
self.Text1_5.place(relx=0.84, rely=0.67, relheight=0.57, relwidth=0.39)
self.Text1_5.configure(background="white")
self.Text1_5.configure(font="TkTextFont")
self.Text1_5.configure(foreground="black")
self.Text1_5.configure(highlightbackground="#d9d9d9")
self.Text1_5.configure(highlightcolor="black")
self.Text1_5.configure(insertbackground="black")
self.Text1_5.configure(selectbackground="#c4c4c4")
self.Text1_5.configure(selectforeground="black")
self.Text1_5.configure(width=534)
self.Text1_5.configure(wrap=WORD)
if __name__ == '__main__':
vp_start_gui()