title: Adding data dynamically to tkinter table
body: <p>I wanted to create a table like below</p>
  <p><a href="https://i.stack.imgur.com/APq7N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/APq7N.png" alt="enter image description here" /></a></p>
  <p>The data from the rows is generated continuously . I want to create my table in such a way that rows are created dynamically . I wrote below code (Very new to tinkter, may be just 6 hours new) but the no data is inserted .</p>
  <pre><code>from scapy.all import *
  from scapy.layers.http import HTTPRequest,HTTPResponse,HTTP # import HTTP packet
  
  from tkinter import ttk 
  import tkinter as tk 
  
  
  def generateData():
      sniff_packets()
      
      
  def sniff_packets():
      window.mainloop() # &lt;&lt;---The window loop 
      window.after(300, process_packet)
      sniff(filter=&quot;port 80&quot;, prn=process_packet, iface=&quot;utun2&quot;, store=False)
      
      
  def process_packet(packet):
      print(&quot;Called to process_packet() &quot;)
      
      http_packet = str(packet)
      if packet.haslayer(HTTP):
          #if &quot;www.xyz.com&quot; in http_packet:
          #    print(http_packet)
          if 'XYZ' in http_packet:
              
              if HTTPRequest in packet:
                  http_request = packet[HTTPRequest]
                  insertDataDynamic((arrangePacket(str(http_request)))
                  
                 
                  
              if HTTPResponse in packet:   
                  http_response = packet[HTTPResponse]
                  insertDataDynamic((arrangePacket(str(http_request)))
                  
      
      
      
               
          
   
  def insertDataDynamic(api_data):
          print(&quot;Called to insertDataDynamic() &quot;)
          treev.insert(&quot;&quot;, 'end', text =&quot;L1&quot;,  
               values =(&quot;DATA &quot;, api_data, &quot;HTTP&quot;))        
  
  
  
      
  
  def arrangePacket(httpLayer):
      
      ret = &quot;***************************************GET PACKET****************************************************\n&quot;
      ret += &quot;\n&quot;.join(httpLayer.split(r&quot;\r\n&quot;))
      ret += &quot;\n *****************************************************************************************************\n&quot;
      return ret
  
  
  if __name__ == &quot;__main__&quot;:
      window = tk.Tk() 
      window.resizable(width = 1, height = 1) 
      treev = ttk.Treeview(window, selectmode ='browse') 
      treev.pack(side ='right') 
    
      # Constructing vertical scrollbar 
      # with treeview 
      verscrlbar = ttk.Scrollbar(window,  
                                 orient =&quot;vertical&quot;,  
                                 command = treev.yview) 
        
      # Calling pack method w.r.to verical  
      # scrollbar 
      verscrlbar.pack(side ='right', fill ='x') 
        
      # Configuring treeview 
      treev.configure(xscrollcommand = verscrlbar.set) 
        
      # Defining number of columns 
      treev[&quot;columns&quot;] = (&quot;1&quot;,&quot;2&quot;,&quot;3&quot;) 
        
      # Defining heading 
      treev['show'] = 'headings'
        
      # Assigning the width and anchor to  the 
      # respective columns 
      treev.column(&quot;1&quot;, width = 500, anchor ='c') 
      treev.column(&quot;2&quot;, width = 500, anchor ='se') 
      treev.column(&quot;3&quot;, width = 500, anchor ='se')  
        
      # Assigning the heading names to the  
      # respective columns 
      treev.heading(&quot;1&quot;, text =&quot;Name&quot;) 
      treev.heading(&quot;2&quot;, text =&quot;Sex&quot;) 
      treev.heading(&quot;3&quot;, text =&quot;Age&quot;)
  
      generateData()
  </code></pre>
  <p>Also as soon as the mainloop starts ,the prn function of scapy doesn't work .</p>