2014-11-02 48 views
-1

我想能夠將攝氏轉換爲華氏。所以經過一些研究後,我找到了一個辦法。這是我的代碼:需要幫助,使一個簡單的攝氏度轉換器

celsius = float(input('Enter degree Celsius: ')) 

fahrenheit = (celsius * 1.8) + 32 
print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit)) 

raw_input ("Press Enter To Close") 

所以我的問題是我可以使這個簡單的小程序。所以就像我啓動它時它打開一個EXE文件,然後輸入一個例子100並點擊OK,然後在按鈕下面或者我得到一個答案。

類似於圖片。對於我使用photoshop的圖片。 http://i.imgur.com/XvTEj0c.png

+4

使用一些貴,像Tkinter的 – Hackaholic 2014-11-02 15:45:43

+0

我如何用我已經羅滕代碼結合Tkinter的?對不起,如果我的問題是愚蠢的,就像我說的那樣,對Python真的很陌生:)你能幫我嗎? – Eric 2014-11-02 15:51:15

+0

這個問題太廣泛了 - 你應該去做一些關於Python GUI工具包的自己的研究 – jonrsharpe 2014-11-02 15:51:51

回答

0

由於意見粘貼長的代碼是不可能的,這裏是一個非常艱難中起步:

#!/usr/bin/env python3 
import tkinter 
import tkinter.simpledialog 

root = tkinter.Tk() 
root.withdraw() 


celsius = tkinter.simpledialog.askfloat(
    'Celsius converter', 
    'Enter degree Celsius: ' 
) 
fahrenheit = (celsius * 1.8) + 32 
tkinter.messagebox.showinfo(
    'Celsius converter', 
    '%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' % (celsius, fahrenheit) 
)