title: How can I optimize my code for my Spanish Translation Program?
body: <p>I am currently a student obtaining a Bachelor's in Computer Science, and I am writing a python program in the little spare time that I have to help me learn Spanish. It's definitely not an extravagant program that I'm going to publish or anything, just for me to have fun and mess around with. I just learned the basic GUI structure of python programming with Tkinter, and I am just trying to be pointed in the right direction to optimize my code to make it smaller and not look so basic. I have 3500 lines of code so far, so I won't upload the whole code, but here is the structure of pretty much my entire program</p>
  
  <pre><code>def _months( self ):
      #Framework for the Month Window
      Frame.__init__( self )
      self.master.title( "Months" )
      self.grid()
      labelfont = ( "times", 18, "bold" )
      homefont = ( "times", 10, "bold" )
  
      self._monthMenuImage = PhotoImage( file = 'mexicoWater.gif' )
      self._monthBackgroundLabel = Label( self, image = self._monthMenuImage )
      self._monthBackgroundLabel.place( x = 0, y = 0 )
      self.grid_propagate(0)
      self["height"] = 600
      self["width"] = 800
  
      #January button
      self._januaryButton = Button( self, text = "January",
                                    command = self._switchJanuary )
      self._januaryButton.config( font = labelfont, bg = self.water2 )
      self._januaryButton.config( height = 0, width = 10 )
      self._januaryButton.place( x = 65, y = 325 )
  
      #February button
      self._februaryButton = Button( self, text = "February",
                                     command = self._switchFebruary )
      self._februaryButton.config( font = labelfont, bg = self.water2 )
      self._februaryButton.config( height = 0, width = 10 )
      self._februaryButton.place( x = 315, y = 325 )
  
      #March button
      self._marchButton = Button( self, text = "March",
                                  command = self._switchMarch )
      self._marchButton.config( font = labelfont, bg = self.water2 )
      self._marchButton.config( height = 0, width = 10 )
      self._marchButton.place( x = 565, y = 325 )
  </code></pre>
  
  <p>The <code>"command = self._switch...."</code> leads to different methods such as</p>
  
  <pre><code> def _switchJanuary( self ):
      if self._januaryButton["text"] == "January":
          self._januaryButton.config( bg = self.water1 )
          self._januaryButton["text"] = "Enero"
      else:
          self._januaryButton["text"] = "January"
          self._januaryButton.config( bg = self.water2 )
  
  def _switchFebruary( self ):
      if self._februaryButton["text"] == "February":
          self._februaryButton.config( bg = self.water1 )
          self._februaryButton["text"] = "Febrero"
      else:
          self._februaryButton["text"] = "February"
          self._februaryButton.config( bg = self.water2 )
  
  def _switchMarch( self ):
      if self._marchButton["text"] == "March":
          self._marchButton.config( bg = self.water1 )
          self._marchButton["text"] = "Marzo"
      else:
          self._marchButton["text"] = "March"
          self._marchButton.config( bg = self.water2 )
  </code></pre>
  
  <p>"self.water1" and "self.water2" are just cool blue colors that I declared as class variables earlier on.</p>
  
  <p>This is the basic structure of my entire code, with months, days, numbers and such. I'm just trying to find a way to make the code smaller, because I want to add a lot of different features to the program without it being a million lines. I've been told to use a dictionary, in which I could access the key values to translate the words instead of having to have each Button lead to a different method, but I am lost. Any help would be greatly appreciated. Thank you for your time!</p>