Last active
          November 2, 2015 01:51 
        
      - 
      
- 
        Save anthonygclark/f2a54d9ce0a7074a2356 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env python2 | |
| from Tkinter import * | |
| # Input value | |
| input_value = 0 | |
| # Output value | |
| output_value = 0 | |
| # Output Location | |
| output_field = None | |
| def CelsiusToFahrenheit(): | |
| global output_field | |
| v = input_value.get() | |
| if not v: return | |
| if v == 0.0: return | |
| else: | |
| output_field.delete(0, END) | |
| output_field.insert(0, (v * 9.0/5.0) + 32) | |
| def FahrenheitToCelsius(): | |
| global output_field | |
| v = input_value.get() | |
| if not v: return | |
| if v == 0.0: return | |
| else: | |
| output_field.delete(0, END) | |
| output_field.insert(0, (v - 32) * (5.0/9.0)) | |
| def create_window(): | |
| global input_value | |
| global output_value | |
| global output_field | |
| win = Tk() | |
| frame1 = Frame(win) | |
| frame1.pack() | |
| Label(frame1, text="Input").grid(row=0, column=0, sticky=W) | |
| input_value = DoubleVar() | |
| trash = Entry(frame1, textvariable=input_value) | |
| trash.grid(row=0, column=1, sticky=W) | |
| Label(frame1, text="Output").grid(row=1, column=0, sticky=W) | |
| output_value = DoubleVar() | |
| output_field = Entry(frame1, textvariable=output_value) | |
| output_field.grid(row=1, column=1, sticky=W) | |
| frame2 = Frame(win) # Row of buttons | |
| frame2.pack() | |
| b1 = Button(frame2,text="Fahrenheit To Celsius ", command=FahrenheitToCelsius) | |
| b2 = Button(frame2,text="Celsius To Fahrenheit", command=CelsiusToFahrenheit) | |
| b1.pack(side=LEFT) | |
| b2.pack(side=LEFT) | |
| return win | |
| win = create_window() | |
| win.mainloop() | 
      
      
  Author
  
  
        
      
            anthonygclark
  
      
      
      commented 
        Nov 1, 2015 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            