user3562657
user3562657

Reputation: 167

Python - Tkinter empty window

I'm doing an assignment for a course and I'm not really sure what's up with the code but it runs without error, only displaying an empty window. I used an example given as a start and basically modified it to get this code. If needed I can provide the example code to compare.

    from Tkinter import *

class App(Tk):
  def __init(self):
        Tk.__init__(self)

        self.height()
        self.weigh()
        self.calculate()
        self.output()


  def height(self):

        Label(self, text = "Enter Height, feet").grid()

        self.feet = Entry(self)
        self.feet.grid(row = 0, column = 1)
        self.feet.insert(0, "100")

        lblinches = Label(self, text = "Enter Height, inches")
        lblinches.grid(row = 1, column = 0)

        self.inches = Entry(self)
        self.inches.grid(row = 1, column = 1)

  def weigh(self):

        Label(self, text = "Enter Weight").grid(row =2, column = 0)

        self.weight = Entry(self)
        self.weight.grid(row = 2, column = 1)


  def output(self):
        self.calcBMI = Button(self, text = "Calculate BMI")
        self.calcBMI.grid()
        self.calcBMI["command"] = self.calculate

        Label(self, text = "Body Mass Index").grid(row = 4)

        Label(self, text = "Status").grid(row = 5)    

  def calculate(self):

        feet1 = int(self.feet.get())
        inches1 = int(self.inches.get())
        height1 = feet1 *12 + inches1
        weight1 = int(self.weight.get())

        bmi = (weight1 * 703) / (height1 * 2)
        self.lblbmi["text"] = ".2f" % bmi


def main():

    app = App()
    app.mainloop()

main()

Upvotes: 0

Views: 655

Answers (1)

unutbu
unutbu

Reputation: 880707

__init should be __init__. Since __init__ was not defined, none of the configuration methods were called.

Upvotes: 2

Related Questions