0

I want to create a SCROLL-ABLE main window which has 10 text boxes. As these text boxes cannot fit in one window, I want to add scrollbar vertically and horizontally to view the text boxes that cannot fit on the main screen.

Please see the image below for my output. I want to add scrollbar x and y axis to view boxes. Tkinter window

I used PAGE to develop the tkinter code. Here is my code for the above output:

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()
Raj Mehta
  • 314
  • 1
  • 4
  • 20
  • There aren't any questions which are _exact_ duplicates of your question, but your answer is there nonetheless. – abarnert Jun 25 '18 at 20:19
  • In particular, the accepted answer to the first duplicate question explains why you need a scrollable widget to put your `Text` boxes in, and shows one way to do that (by using a `Canvas` with another `Frame` inside it), which you should be able to adapt to your code. – abarnert Jun 25 '18 at 20:21
  • Alright. Thank you. – Raj Mehta Jun 25 '18 at 21:02

0 Answers0