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...

A classmate of yours has coded the following version of selectionSort().Will it work? Explain.

``` /** * Sort the array elements in ascending order * using selection sort. * @param a the array of Objects to sort * @throws NullPointerException if a is null */ static void selectionSort( Object[] a ) { if ( a == null ) throw new NullPointerException(); // while the size of the unsorted part is > 1 for ( int unsortedSize = a.length; unsortedSize > 1; unsortedSize-- ) { // find the position of the largest // element in the unsorted section int maxPos = 0; for ( int pos = 1; pos < unsortedSize; pos++ ) if ( a[pos] > a[maxPos] ) maxPos = pos; // postcondition: maxPos is the position // of the largest element in the unsorted // part of the array // Swap largest value with the last value // in the unsorted part Object temp = a[unsortedSize – 1]; a[unsortedSize – 1] = a[maxPos]; a[maxPos] = temp; } } ```

Computer Science & Information Technology

You can open an existing Web site by clicking the Open Site command on the ____ menu.

A. Site B. Edit C. Tools D. Task Panes

Computer Science & Information Technology

To assist you in entering the VBA code, the Visual Basic Editor uses ____________________, a list of words that can be used in the macro statement and match what you type.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A technician documents the findings of illegal material that was found on a workstation. Which of the following should the technician do NEXT when storing the workstation?

A. Set all users to administrators B. Destroy the hard drive C. Reimage the workstation and deploy D. Adhere to the chain of custody

Computer Science & Information Technology