Ubuntu Türkiye

Yazılım => Programlama => Python => Konuyu başlatan: mnaUltra - 01 Haziran 2017 - 15:13:57

Başlık: YARDIMLARINIZ LAZIM PYTHON SICAKLIK ÇEVİRİCİ İÇİN
Gönderen: mnaUltra - 01 Haziran 2017 - 15:13:57

Merhabalar ,

Buradaki ilk yardım isteyişim inşallah bilen arkadaşlarımız sorunumu çözerler  :D
Python da sıcaklık çevirici programı yapmaya çalışıyordum google da araştırma yaparken buldum bir tane ama eklemeler yapmak istedim mesela kelvini de çevirsin dedim lakin yapamadım tam doğru olarak ( program celciusten fahrenheit a karşılıklı olarak çevirme yapıyordu) Lafı daha fazla uzatmadan kod u ekliyim.

from Tkinter import*

class mygui():
    def __init__(self,master):
       
        self.master = master
        master.title("temp convert")
        master.geometry("300x300")

        self.celcius = 0.00
        self.fahrenheit = 0.00
        self.kelvin=0.00
        self.version = "v.1.1.1"
        self.creator = "by mnaUltra"

        frame = Frame(master)
        frame.pack()

        tool_bar = Menu(frame)    # en ustte cikan file cubugu budur
        master.config(menu=tool_bar)

        tool_barfile=Menu(tool_bar)    # ona file a exit ekledik
        tool_barfile.add_command(label="exit",command=master.quit)

        tool_baredit=Menu(tool_bar)
        tool_baredit.add_command(label="copy")

        tool_bar.add_cascade(label="file", menu=tool_barfile)
        tool_bar.add_cascade(label="edit",command=tool_baredit)
        tool_bar.add_cascade(label="help")

        self.version_label= Label(frame,text=self.version)
        self.version_label.pack()

        self.creator_label = Label(frame,bg="grey", text=self.creator)
        self.creator_label.pack()


        self.user_label = Label(frame, text="fahrenheit to celcius")
        self.user_label.pack()

        self.user_temp1 = Entry(frame)
        self.user_temp1.insert(0,self.fahrenheit)
        self.user_temp1.pack()

        self.converted_label1 = Label(frame, text=self.celcius)
        self.converted_label1.pack()

        self.user_label2=Label(frame, text= "celcius to fahrenheit")
        self.user_label2.pack()

        self.user_temp2 = Entry(frame)
        self.user_temp2.insert(0,self.celcius)
        self.user_temp2.pack()

        self.converted_label2=Label(frame, text= self.fahrenheit)
        self.converted_label2.pack()

        self.user_label3= Label(frame, text= "kelvin to celcius")
        self.user_label3.pack()
        self.user_temp3=Entry(frame)
        self.user_temp3.insert(0,self.kelvin)
        self.user_temp3.pack()
        self.converted_label3=Label(frame, text=self.celcius)
        self.converted_label3.pack()

        self.convert_button = Button(frame, text="convert", fg="blue",command=self.update)
        self.convert_button.pack(side=LEFT)

        self.quit_button = Button(frame, text="quit", fg="red",command=master.quit)
        self.quit_button.pack(side=RIGHT)

    def update(self):

        self.celcius=self.fahrenheit_to_celcius(self.user_temp1.get())
        self.fahrenheit =self.celcius_to_fahrenheit(self.user_temp2.get())
        self.celsius=self.kelvin_to_celcius(self.user_temp3.get())

        self.converted_label1.config(text= self.celcius)
        self.converted_label2.config(text= self.fahrenheit)
        self.converted_label3.config(text=self.kelvin)

    @staticmethod
    def fahrenheit_to_celcius(fahrenheit):
        celcius=(float(fahrenheit)-32) * (5/9)
        return celcius

    @staticmethod
    def celcius_to_fahrenheit(celcius):
        fahrenheit=float(celcius) * (9 / 5) + 32
        return fahrenheit

    @staticmethod
    def kelvin_to_celcius(celcius):
        kelvin=float(celcius) - 273.15
        return kelvin



Mesaj tekrarı yüzünden mesajınız birleştirildi. Bu mesajın gönderim tarihi : 01 Haziran 2017 - 16:05:43

Def kısımlarını biraz daha düzenledim ilk yolladığım baya bir düzensizdi. Buradan bakarsanız sorun şimdi daha net sanki.

    def update(self):

        self.celcius=self.fahrenheit_to_celcius(self.user_temp1.get())
        self.fahrenheit =self.celcius_to_fahrenheit(self.user_temp2.get())
        self.kelvin=self.kelvin_to_celcius(self.user_temp3.get())

        self.converted_label1.config(text= self.celcius)
        self.converted_label2.config(text= self.fahrenheit)
        self.converted_label3.config(text=self.kelvin)

    @staticmethod
    def fahrenheit_to_celcius(fahrenheit):
        celcius=(float(fahrenheit)-32) * ( 5 / 9)
        return celcius

    @staticmethod
    def celcius_to_fahrenheit(celcius):
        fahrenheit=float(celcius) * (9 / 5) + 32
        return fahrenheit

    @staticmethod
    def kelvin_to_celcius(celcius):
        kelvin=float(celcius) + 273.15
        return kelvin
Başlık: Ynt: YARDIMLARINIZ LAZIM PYTHON SICAKLIK ÇEVİRİCİ İÇİN
Gönderen: FireSwords - 27 Haziran 2017 - 15:37:45
Bunun için neden grafik arayüz yapmaya çalışıyorsun ki? Direkt komut satırından çalışan bir şey yapabilirsin çok daha basit olur hem.
Başlık: Ynt: YARDIMLARINIZ LAZIM PYTHON SICAKLIK ÇEVİRİCİ İÇİN
Gönderen: mnaUltra - 27 Haziran 2017 - 17:12:12
Biraz okuldan kaynaklı olabilir dostum console da pek çalışmıyoruz projelerde ben de arayüz kodluyorum çoğu projede. Fonksiyonlar hakkında bir yardımın dokunursa çok iyi olur ben sorunla ilgilenemedim bayadır.
Başlık: Ynt: YARDIMLARINIZ LAZIM PYTHON SICAKLIK ÇEVİRİCİ İÇİN
Gönderen: edge35 - 28 Haziran 2017 - 16:54:19
Ne yazık ki python bilmiyorum, yardımcı olamayacağım. Fakat;
Kodlarınızı kod etiketi içinde yazarsanız daha iyi olur. Eğer kullanımını bilmiyorsanız forum arama kısmından kod etiketi yazarsanız çıkar.
Bir de zaten yardım istediğiniz için konu açıyorsunuz, başlıkta da belirtmwnize gerek olmadığını ve düzenlerseniz daha anlaşılır olacağını düşünüyorum.
Mesajım da konunuzu yukarı taşımış olsun :)

Düzrnleme: code etiketi yazmanız gerekiyormuş, kod etiketi yazdım, çıkmadı
Başlık: Ynt: YARDIMLARINIZ LAZIM PYTHON SICAKLIK ÇEVİRİCİ İÇİN
Gönderen: ahmet12 - 10 Eylül 2017 - 14:40:11
ekle programa
import pytemperature
>>> pytemperature.c2f(37.78) # Celsius to Fahrenheit
100.0
>>> pytemperature.f2c(104) # Fahrenheit to Celsius
40.0
>>> pytemperature.c2k(40) # Celsius to Kelvin
313.15
>>> pytemperature.k2c(273.15) # Kelvin to Celsius
0.0
>>> pytemperature.k2f(273.15) # Kelvin to Fahrenheit
31.98
>>> pytemperature.f2k(100) # Fahrenheit to Kelvin
310.93
>>> pytemperature.r2c(80) # Romoe to Celsius
100.0
>>> pytemperature.c2r(100) # Romoe to Celsius
80.0
>>> pytemperature.r2k(80) #Romoe to Celsius
373.15