Create the following GUI using the Grid layout manager. You do not have to provide any functionality.

What will be an ideal response?

![15061|228x172](upload://4lyykKS788wYX0ISCy8l137ior5.png)
```
# Using Grid to create a calculator GUI

from Tkinter import *

class Calculator( Frame ):
"""Class Calculator with GUI"""

def __init__( self ):
"""Create calculator GUI"""

Frame.__init__( self )
self.grid( sticky = W+E+N+S )
self.master.title( "Calculator" )
self.master.rowconfigure( 0, weight = 1 )
self.master.columnconfigure( 0, weight = 1 )

# the Entry widget fits the entire cell
self.display = Entry( self )
self.display.grid( row = 0, columnspan = 4,
sticky = W+E )

# create and insert number buttons
self.numberButtons = []

for i in range( 9, -1, -1 ):

self.numberButton = Button( self, text = str( i ),
width = 5, name = str( i ) )
self.numberButtons.append( self.numberButton )

current = 0

for x in range( 1, 4 ):

for y in range( 2, -1, -1 ):

self.numberButtons[ current ].grid( row = x,
column = y )
current += 1

self.numberButtons[ -1 ].grid( row = 4, column = 0 )

# insert decimal button
self.decimalButton = Button( self, text = ".", width = 5,
name = "decimal" )
self.decimalButton.grid( row = 4 , column = 1 )

# insert operator buttons
self.operators = [ "/", "*", "-", "+" ]
x = 1

for operator in self.operators:

self.operatorButton = Button( self, text = operator,
width = 5, name = operator )
self.operatorButton.grid( row = x, column = 3 )
x += 1

self.equalsButton = Button( self, text = "=", width = 5,
name = "=" )
self.equalsButton.grid( row = 4, column = 2 )

def main():
Calculator().mainloop()

if __name__ == "__main__":
main()
```

Computer Science & Information Technology

You might also like to view...

By default all cells in a workbook are ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

What are the nine phases of the software life cycle?

What will be an ideal response?

Computer Science & Information Technology