-1

I am creating a grid view with different rows and columns, the main problem is that my scrollbar with text widget does not show up the entire GUI.

My code is as:

    # -----Zero Row----
lbl = Label(window, font=('Calibri',32), text='Title',bg = '#f0f0f0',bd =10,anchor='w').grid(row=0,columnspan=4)

#---- First Row ---
Label(window, text='Account Number').grid(row =1 , column = 0, sticky='nsew' )
Label(window, text='Balance').grid(row =1 , column = 1, sticky='nsew' )
btnLogOut = Button(window, text='Log Out', command = save_and_logout).grid(row= 1, column= 2, columnspan = 2, sticky='nsew')

#----Second Row----
Label(window, text='ON').grid(row =2 , column = 0, sticky='nsew')
Entry(window, textvariable = account_number_input).grid(row =2 , column = 1, sticky='nsew')
Button(window, text='OF', command = a).grid(row= 2, column= 2, sticky='nsew')
Button(window, text='SWITCH', command = a).grid(row= 2, column= 3, sticky='nsew')

#---Third Row----
text_scrollbar = Scrollbar ( window )
text_scrollbar.pack( side = RIGHT, fill = Y )
transaction_text_widget = Text(window, wrap = NONE, yscrollcommand = text_scrollbar.set)
# state = NORMAL for editing 
transaction_text_widget.config(state=NORMAL)
transaction_text_widget.insert("1.0", "text")
transaction_text_widget.insert("1232.30", "text")
transaction_text_widget.insert("132223.0", "text")
# state = DISABLED so that it cannot be edited once written 
transaction_text_widget.config(state=DISABLED)
transaction_text_widget.pack(side="left")
#Configure the scrollbars
text_scrollbar.config(command=transaction_text_widget.yview)
transaction_text_widget.grid(row = 3 , column = 1,sticky='nsw')


#-----------setting the column and row weights-----------
window.columnconfigure(0, weight=1)
window.columnconfigure(1, weight=1)
window.columnconfigure(2, weight=1)
window.columnconfigure(3, weight=1)

window.rowconfigure(0, weight =4)
window.rowconfigure(1, weight =2)
window.rowconfigure(2, weight =3)
window.rowconfigure(3, weight =3)

What might be the reason for this? If I remove the Third Row section the GUI is seen for other rows.

bhaskar
  • 991
  • 1
  • 15
  • 37
  • easier use a scrolled text widget? – 10SecTom May 14 '18 at 10:40
  • 1
    You're mixing `grid` and `pack` in the same master (`window`). Moreover, you even call both `grid` and `pack` on `transaction_text_widget`. Also see https://stackoverflow.com/a/44711332/3714930 and https://stackoverflow.com/a/11261014/3714930 – fhdrsdg May 14 '18 at 10:46

1 Answers1

0

I fixed it by just adding

    text_scrollbar.grid(row = 3 , columnspan = 4,sticky='nsew')

Thank you for the answer though.

bhaskar
  • 991
  • 1
  • 15
  • 37