title: is there a way to grid an extra button while running your program in tkinter correctly?
body: <p>I'm making an mp3 player app and I want the user to be able to add playlists (which will be buttons in a grid system.
  Like so.<a href="https://i.stack.imgur.com/UIcAd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UIcAd.png" alt="enter image description here" /></a></p>
  <p>However in this state when I'm trying to add a playlist button this happens:
  <a href="https://i.stack.imgur.com/7xhON.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7xhON.png" alt="" /></a>
  The top buttons and the button i just added get squeezed off and the scrollbar is stuck (I can't use it)</p>
  <p>I've tried refreshing by <code>self.playlist_frame.update_idletasks()</code> after running <code>create_playlists()</code> but it doesn't seem to change anything</p>
  <h1>this is my code so you can test it:</h1>
  <pre><code>import os
  import tkinter as tk
  from tkinter import ttk
  from PIL import Image, ImageTk
  
  
  class MyApp:
      def __init__(self):
  
          self.root = tk.Tk()
  
          self.width = self.root.winfo_screenwidth()
          self.height = self.root.winfo_screenheight()
          self.height = self.root.winfo_screenheight() - int(self.height / 13)
          self.root.geometry(f'{self.width}x{self.height}')
          self.root.title(&quot;Mp3&quot;)
  
          self.c = '#14141D'
  
          self.playlists_buttons_list = []
          self.playlists = {}
          self.helping_d = {}
  
          self.main = ttk.Notebook(self.root)
          self.playlists_tab = tk.Frame(self.main)
          self.playlist_menu_frame = tk.Frame(self.playlists_tab, bg=self.c)
          self.playlists_canvas = tk.Canvas(self.playlists_tab, bg=self.c)
          self.playlist_frame = tk.Frame(self.playlists_canvas, bg=self.c)
          self.playlists_scrollbar = ttk.Scrollbar(self.playlists_tab, orient='vertical',
                                                   command=self.playlists_canvas.yview)
          self.add_playlist_win = tk.Toplevel(self.root)
          self.add_playlists_button = tk.Button(self.playlist_frame)
          self.default_img = Image.open('images/default.png').resize((75, 72))
          self.default_img = ImageTk.PhotoImage(self.default_img)
          self.add_img = Image.open('images/add.png').resize((50, 50))
          self.add_img = ImageTk.PhotoImage(self.add_img)
          self.widgets()
          self.root.mainloop()
  
      def widgets(self):
          self.playlists_tab.place(height=self.height, width=self.width, x=0, y=0)
          self.main.add(self.playlists_tab, text=&quot;Playlists&quot;)
          self.main.pack(expand=1, fill=&quot;both&quot;)
          self.playlist_frame = tk.Frame(self.playlists_canvas, bg=self.c)
          self.playlists_canvas.create_window((0, 0), window=self.playlist_frame, anchor='center')
          self.playlists_canvas.config(bg=self.c)
          self.playlists_canvas.place(height=int(self.height / 1.428), width=self.width, x=0, y=int(self.height / 9))
          self.add_playlists_button = tk.Button(self.playlists_canvas, image=self.add_img, bg=self.c, bd=0,
                                                command=self.add_playlists)
          self.add_playlists_button.place(x=1284, y=75)
          self.playlists_scrollbar.pack(side='right', fill='y')
          self.playlists_canvas.config(yscrollcommand=self.playlists_scrollbar.set)
          self.playlists_canvas.bind('&lt;Configure&gt;', lambda e: self.playlists_canvas.configure(
              scrollregion=self.playlists_canvas.bbox('all')))
  
          if os.path.getsize('playlistsnames.txt') != 0:
              lines = open('playlistsnames.txt', 'r', encoding='utf-8').read().splitlines()
              for i in lines:
                  self.playlists[i] = []
  
          self.create_playlists()
  
      def create_playlists(self):
          self.playlists_buttons_list = []
  
          for i in range(len(self.playlists.keys())):
              self.playlists_buttons_list.append(tk.Button(self.playlist_frame, bg=self.c,
                                                           text=' ' + list(self.playlists.keys())[i].split('!')[0],
                                                           fg='white', image=self.default_img, height=280, width=300))
              row = 0
              column = 0
              for i in self.playlists_buttons_list:
                  if column &gt; 3:
                      row += 1
                      column = 0
                  if column &gt; 7:
                      row += 1
                      column = 0
                  i.grid(row=row, column=column)
                  column += 1
  
      def get_name(self):
          self.name_of_plst = self.plst_entry.get()
          self.playlists[self.name_of_plst] = []
          self.create_playlists()
  
          with open('playlistsnames.txt', 'a', encoding='utf-8') as names_file:
              names_file.write(self.name_of_plst + '!\n')
  
      def add_playlists(self):
          self.add_playlist_win = tk.Toplevel(self.root)
          self.name_label = tk.Label(self.add_playlist_win, text='Name:', bg=self.c, fg='pink').pack()
          self.plst_entry = tk.Entry(self.add_playlist_win)
          self.plst_entry.pack()
          self.confirm_btn = tk.Button(self.add_playlist_win, text='Confirm', bg=self.c, fg='pink',
                                       command=self.get_name).pack()
          self.add_playlist_win.mainloop()
  
  
  MyApp()
  </code></pre>
  <p>I should also mention that because I store the playlist names in a file called playlistnames.txt when I rerun the program I can see all the playlist buttons plus the one I created before and things work just fine.
  So what I want is making the grid update and work <b>while</b> running the app <b>without</b> having to rerun the app of course</p>
  <p>My playlistsnames.txt file has this format: <br>
  rock! <br>
  metal! <br>
  chill! <br>
  rap! <br>
  jazz! <br>
  blues! <br>
  hard rock! <br>
  trap! <br></p>
  <p>Any suggestions would be helpful!
  Thanks in advance!</p>