title: How to use If-Statement inside the command of tkinter Button, to check that tkinter CheckButton is click or not?
body: <h1>Program Summary</h1>
  
  <p>I'm making a python based text processing program. Here I am using following Tkinter widgets with following names for its GUI:</p>
  
  <ol>
  <li>Text widget          >   "text_input"</li>
  <li>Text widget          >   "text_output"</li>
  <li>CheckButton widget   >   "checkButton_tense"</li>
  <li>Button widget        >   "button_analyse"</li>
  </ol>
  
  <p>And Now I wanted to my program to run in following sequence.</p>
  
  <ol>
  <li>Taking text from "text_input". </li>
  <li>Perform the some Basic Text Processing in some other class on clicking the "button_analyse" and show output in "text_output".</li>
  <li>But if "checkButton_tense" widget is clicked/checked. Then it should also perform Tense Inspection along with basic text processing, else it should only perform basic text processing.</li>
  <li>Above operation no. 3 should be performed after checking status of "checkButton_tense" widget on clicking the "button_analyse" and show output in "text_output"</li>
  </ol>
  
  <h1>Problem/Error</h1>
  
  <p>Now when I use the if statement inside the "command=lambda:" of the my Tkinter Button "button_analyse" widget to check the status of "checkButton_tense" it gives me error. I have tried to do it with many ways but it don't works. </p>
  
  <p>I have tried the solution mentioned <a href="https://stackoverflow.com/questions/50050440/python-tkinter-button-with-if-else-statements">here</a>. But when I tried any solution like this i am unable to show my text in "text_output" widget because it is inside the different python method "main_gui_layout". I have also tried many other solutions given here at stack-overflow but don't found any identical. Kindly guide me in context of above mentioned problem and following code. </p>
  
  <h1>Code</h1>
  
  <pre><code>from tkinter import *
  from Examples import Examples
  from TextAnalysis import PerformTextAnalysis
  
  
  class MyGui:
      useExamples = Examples()
      performTextAnalysis = PerformTextAnalysis()
  
  def __init__(self, master):
      self.main_gui_layout(master)
  
  def main_gui_layout(self, master):
  
      # InputBox to get the input Text.
  
      text_input = Text(master, bd=1, height=15, width=100)
      text_input.insert('end', self.useExamples.example2)
      text_input.pack(side=TOP)
  
      # OutputBox to show the processed Text.
  
      text_output = Text(master, bd=1, height=15, width=100)
      text_output.pack(side=TOP)
  
      # CheckButton: it will perform tense analysis if checked/clicked
  
      tenseCheck_clicked = IntVar()
      checkButton_tense = Checkbutton(master, text="Tense Inspection", variable=tenseCheck_clicked,
                                      bg='#9aa7bc')
      checkButton_tense.var = tenseCheck_clicked
      checkButton_tense.pack(side=TOP)
  
      # Analysis Button: it will process text and show in output.
      # It will also perform Tense Analysis if Above "checkButton_tense" is check/active.
  
      button_analyse = Button(master, text="Analyse Requirements", width=20,
                              command=lambda:
                              [
                                  self.performTextAnalysis.get_userReqiurement(
                                  str(text_input.get('1.0', 'end'))),
                                  if tenseCheck_clicked == 1:
                                      ans = self.performTextAnalysis.performBasicAnalysis(),
                                      self.performTextAnalysis.performTenseAnalysis(),
                                      text_output.insert(END, ans)
                                  else:
                                  self.performTextAnalysis.performBasicAnalysis()
  
                              ])
      button_analyse.pack(side=TOP)
  </code></pre>