title: Tkinter (Python) how to get values from all Text widgets in a Function
body: <p>I am building one of my first UIs with Tkinter and ttk and struggle to link one button click event to collect two widget values.
  I want to create a “settings” menu as a child frame and have a feature to modify and read current values from two Text widgets.</p>
  <p>So, I’d like:</p>
  <ol>
  <li>Have an ability to add OR remove text from widget.</li>
  <li>Using Button click event, collect current widget values and work with them in separate function</li>
  </ol>
  <p>With my current approach I am not sure how to read both widgets values (in case user changed them), as “command = lambda” allows me to sent only one argument.</p>
  <p>I was thinking to call a function with “GetValues” button click event, but not sure how to access Text widgets from the function.</p>
  <p>Here is my code</p>
  <pre><code>    from tkinter import *
  from tkinter import ttk
  
  # Print  values from both Text Widgets
  def getValues():
  
      print(TextAreaRegion.get(&quot;1.0&quot;,&quot;end-1c&quot;))
      print(TextAreaService.get(&quot;1.0&quot;, &quot;end-1c&quot;))
  
  #Create a child window for Settings
  def openSettingsWindow():
      settingsWindow = Toplevel(root)
      settingsWindow.title(&quot;Settings&quot;)
      settingsWindow.geometry('640x480+100+100')
      settingsWindow.resizable(False, False)
      Label(settingsWindow, text=&quot;Settings&quot;).pack()
  
      frameLeft = ttk.LabelFrame(settingsWindow)
      TextAreaRegion = Text(frameLeft, width=60, height=2, wrap='word')
  
  
      frameLeft.pack()
      frameLeft.config(height=400, width=300, relief=RIDGE, padding=(30, 15), text=&quot;Settings&quot;)
  
      ttk.Label(frameLeft, text=&quot;Regions:&quot;).grid(row=0, column=0, sticky='w', padx=5, pady=10)
      ttk.Label(frameLeft, text=&quot;Tenants:&quot;).grid(row=1, column=0, sticky='w', padx=5, pady=10)
  
      TextAreaRegion.grid(row=0, column=1, sticky='w')
      TextAreaRegion.insert('1.0 + 2 lines', &quot;RegionOne, RegionTwo&quot;)
  
      TextAreaService = Text(frameLeft, width = 60, height = 2)
      TextAreaService.grid(row=1, column=1, sticky='w')
      TextAreaService.insert('1.0 + 2 lines', &quot;ServiceOne, ServiceTwo&quot;)
  
      #Button
      buttonSave = ttk.Button(frameLeft, text=&quot;Get values&quot;, command=getValues)
      buttonSave.grid(row=3, column=0, sticky='w', padx=5)
  
  root = Tk()
  
  #Menu bar
  root.option_add('*tearOff', False)
  menubar = Menu(root)
  root.config(menu = menubar)
  file = Menu(menubar)
  menubar.add_cascade(menu = file, label = 'File')
  
  #Add menu elements
  file.add_command(label = 'Settings', command = openSettingsWindow )
  
  root.mainloop( )
  </code></pre>
  <p>I can get a value for one of the widget, if I use lambda, however, I can't use two arguments for lambda:</p>
  <pre><code>buttonSave = ttk.Button(frameLeft, text=&quot;Get values&quot;, command=lambda:print(TextAreaService.get(&quot;1.0&quot;, &quot;end-1c&quot;)))
  </code></pre>