![]() ![]() Apart from the constructor, the class also exposes few public methods. Each entry is associated with a string variable and has a constant width. Like labels, all entries are on column 1, only row changes in the grid. The second group of widgets are the entry fields, which are used to take input from the user. grid(row =row, column = 0, sticky = 'E', padx = 10, pady = 10) Label(root, text =labelText, underline = 0) The final design of the layout is shown below,ĭef _init_( self, root, labelText, row): The design of the GUI is done using basic blocks and arranged in a format that well represents the final output. The identified widgets will be placed in a grid fashion using the grid() geometry manager of tkinter. One button for triggering calculation and other to clear the input fields. The three labels indicate the type of input/output, the first two entries take input for height and weight, the last entry is set to read-only and used to display the calculated BMI value back to the user. Considering the above, the GUI design includes 3 labels, 3 entries and 2 buttons. ![]() And, a call to action button to trigger the calculation after input is filled. ![]() Also, the calculated BMI value will be output back to the user. The look and feel of the GUI may vary with the underlying Operating System, ie., running the same code presented here may produce different looking user interface depending on the Operating System.įirst of all, the different input from the user needs to be identified, to calculate the BMI at least two inputs are required one for weight and one for height. The code is executed in the following environment, The GUI is implemented using tkinter and tkinter.ttk libraries in Python language. The article presents code to create a simple GUI to calculate BMI based on user input values. Body Mass Index can be calculated using a simple formula kg/m 2, where the weight is represented in kilograms (kg) and the height is represented in metres (m). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |