python - 提示计算器-语法错误

标签 python syntax-error calculator

大家好,我是相对较不熟悉编程的人,但都是试图使用GUI界面来构建小费计算器的人。没有什么大的,没有什么相对困难的,但是我遇到了错误。由于某种原因,我的Python不会显示错误。语法错误:它只是进入 shell ,然后返回脚本。它曾经显示错误,但我不知道怎么了...无论如何,如果你们可以帮助我解决此ID问题,我们将不胜感激。

`

# A tip calculator
# A tip calculator using a GUI interface
# Austin Howard Aug - 13 - 2014

from tkinter import *
#Creating buttons.
class Calculator(Frame):
    """ A GUI tip calculator."""
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.creating_buttons()
    def creating_buttons(self):
        """This list includes Entry fields, which the user will use to define
several objects such as Bill, and how many people are paying on that bill."""
        #Create an entry field button for how much the bill total is.
        #Create a label 
        bill_lbl = Label(self,
                         text = "Bill: ")
        bill_lbl.grid(row = 1,
                      column = 0,
                      columnspan = 1,
                      sticky = W)
        #Create an Entry field.
        bill_ent = Entry(self)
        bill_ent.grid(row = 1,
                      column = 1,
                      sticky = W)
        #Create a Button for how many people will be paying on the bill
        #Create label
        people_paying_lbl = Label(self,
                                  text = "How many people are paying on this bill?: ")
        people_paying_lbl.grid(row = 2,
                               column = 0,
                               columnspan = 1,
                               sticky = W)
        #Create an entry field
        people_paying_ent = Entry(self)
        people_paying_ent.grid(row = 2,
                               column = 1,
                               sticky = W)
        #Create a text box to display the totals in
        bill_total_txt = Text(self,
                              width = 40,
                              height = 40,
                              wrap = WORD)
        bill_total_txt.grid(row = 3,
                            column = 0,
                            columnspan = 2,
                            sticky = W)
        #Create a Submit button
        submit = Button(self,
                        text = "Submit",
                        command = self.total)
        submit.grid(row = 4,
                    column = 0,
                    sticky = W)

    def total(self):
        """ Takes the values from Bill, and # of people to get the amount that will be
displayed in the text box."""
        TAX = .15
        bill = float(bill_ent)
        people = people_paying_ent
        Total = ("The tip is: $", TAX * bill, "\nThe total for the bill is: $",
                 TAX * bill + bill,
                 "divided among the people paying equally is: $",
                 TAX * bill + bill / people "per, person.")
        bill_total_txt.delete(0.0, END)
        bill_total_txt.insert(0.0, Total)





#Starting the Program
root = Tk()
root.title("Tip Calculator")
app = Calculator(root)
root.mainloop()
`

最佳答案

您在第68行有一个错误:

更换

TAX * bill + bill / people "per, person.")


TAX * bill + bill / people, "per, person.")

还要确保在root.mainloop()之后删除反引号

关于python - 提示计算器-语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25299828/

相关文章:

JavaScript:未命中 "Uncaught SyntaxError"[Chrome]

javascript - 使用谷歌地图的价格计算器

python - 在 mac os 上使用 django 安装 mysql

python - 获取重复值并将其整数值相加

python - 如何附加和统一元组

c - 数值积分法、中点、误差、C 代码

python - Keras 变分自动编码器示例 - 潜在输入的使用

MYSQL GUID 触发器

java - 简单的计算器操作

javascript - 如何在 React/Redux 计算器中编写不重复某些值的条件语句?