

画像のような為替変換を行いたいのですが、うまく機能しません。画像の挿入方法もわかりません。  
ご指摘、改善点お願いします。[![画像の説明をここに入力](https://i.stack.imgur.com/OBAeq.jpg)](https://i.stack.imgur.com/OBAeq.jpg)

[code]

    import tkinter
    import tkinter.messagebox
    root=tkinter.Tk()
    
    def convert():
    
    
        if radio_var.get() == 1: #chinese Yuan
            AusDollar = round(entry_var.get() * 0.209234,0)
            tkinter.messagebox.showinfo('Your ',str(entry_var), 'Chinese Yuan = ',str(AusDollar), ' in Australian Dollars')
    
        elif currency.upper() == 2: #Euro
            AusDollar = round(entry_var.get() * 1.59524,0)
            tkinter.messagebox.showinfo('Your ',str(entry_var), 'Euros = ',str(AusDollar), ' in Australian Dollars')
    
        elif currency.upper() == 3: #British Pound
            AusDollar = round(entry_var.get * 1.83338,0)
            tkinter.messagebox.showinfo('Your ',str(entry_var), 'British Pounds = ',str(AusDollar), ' in Australian Dollars')
    
        elif currency.upper() == 4: #Russian Ruble
            AusDollar = round(entry_var.get * 0.0214580,0)
            tkinter.messagebox.showinfo('Your ',str(entry_var), 'Russian Rubles = ',str(AusDollar), ' in Australian Dollars')
    
    
    
    main_frame = tkinter.Frame(root).grid()
    radio_var = tkinter.IntVar()
    radio_var.set(1)
    entry_var = tkinter.IntVar()
    
    
    #create butons
    
    tkinter.Label(main_frame, text = "please select the currency to convert").grid(column=1, row=1)
    
    tkinter.Radiobutton(main_frame, text="Chinese Yuan", variable=radio_var,
                        value=1).grid(column=1, row=2)
    tkinter.Radiobutton(main_frame, text="Euro", variable=radio_var,
                        value=2).grid(column=1, row=3)
    tkinter.Radiobutton(main_frame, text="British pound", variable =radio_var,
                        value=3).grid(column=1, row=4)
    tkinter.Radiobutton(main_frame, text="Russian Ruble", variable=radio_var,
                        value=4).grid(column=1, row=5)
    tkinter.Label(main_frame, text="How much money do you want to convert?:").grid(column=1, row=7)
    
    tkinter.Entry(main_frame, textvariable= entry_var, width=10).grid(column=2, row=7)
    
    tkinter.Button(main_frame,
                                    text="Convert", command=convert).grid(column=1, row=8)
    quit_button=tkinter.Button(main_frame, text ="Quit", command=root.destroy).grid(column=2, row=8)
    
    
    tkinter.mainloop() 
    
[/code]


CC BY-SA 4.0
2020-02-29T14:27:23.693
63459
2020-03-01T09:03:12.640
2020-03-01T09:03:12.640
38020
question
python tkinter
tkinterを使用し、為替変換をしたい


質問欄にあるコードでは `tkinter.messagebox.showinfo()` のパラメータ指定に誤りがあるのでエラーになってしまいます。

画像を挿入する処理は入れていないのですが、以下の様に書き換えてみました。

[code]

    from tkinter import Tk, Frame, Label, Button, Radiobutton, Entry, messagebox
    from tkinter import IntVar, W
    
    conversion_table = {
      1: {'currency': 'Chinese Yuan',   'rate': 0.209234},
      2: {'currency': 'Euro',           'rate': 1.595240},
      3: {'currency': 'British Pounds', 'rate': 1.833380},
      4: {'currency': 'Russian Ruble',  'rate': 0.021458},
    }
    
    class CurrencyConverter(Tk):
      def __init__(self):
        Tk.__init__(self)
        self.currency = IntVar(value=1)
        self.money = IntVar(value=0)
        self.counter = 1
    
        # Widgets
        frame = Frame(self).grid()
        Label(
          frame, text='Please select the currency to convert'
        ).grid(column=1, row=self.row(), columnspan=4, sticky=W, padx=5)
    
        # Currencies
        for k, item in conversion_table.items():
          Radiobutton(
            frame, text=item['currency'], variable=self.currency, value=k
          ).grid(column=1, row=self.row(1), columnspan=4, sticky=W, padx=20)
    
        # Entry box
        Label(
          frame, text='How much money do you want to convert?'
        ).grid(column=1, row=self.row(1), columnspan=3, sticky=W, padx=5)
        entry = Entry(frame, textvariable=self.money, width=10)
        entry.grid(column=4, row=self.row(), padx=(1,10))
        entry.configure(
          validate='key', vcmd=(entry.register(
            lambda p: True if p.isdigit() or p == '' else False), '%P')
        )
    
        # Buttons for operations
        Button(
          frame, text='Convert', command=self.convert
        ).grid(column=1, row=self.row(1), columnspan=2, pady=(10,0))
        Button(
          frame, text='Quit', command=self.destroy
        ).grid(column=3, row=self.row(), columnspan=2, padx=(10,0), pady=(10,0))
    
      def convert(self):
        try:
          val = self.money.get()
        except:
          return
        currency =  conversion_table[self.currency.get()]
        aus_dollar = round(val * currency['rate'], 1)
        messagebox.showinfo(
          'Results',
          f'Your {val} {currency["currency"]} = {aus_dollar} in Australian Dollars'
        )
    
      def row(self, step=0):
        self.counter += step
        return self.counter
    
    if __name__ == '__main__':
      gui = CurrencyConverter()
      gui.mainloop()
    
[/code]


CC BY-SA 4.0
2020-03-01T08:46:33.160
63470
2020-03-01T08:46:33.160
63459
answer