Need Help ?

Home / Expert Answers / Other / gui-layout-example-one-important-aspect-of-gui-design-is-the-layout-of-widgets-in-an-application-in-

(Answered): GUI Layout Example | One important aspect of GUI design is the layout of widgets in an application. ...



GUI Layout Example | One important aspect of GUI design is the layout of widgets in an application. In this problem you will

GUI Layout Example | One important aspect of GUI design is the layout of widgets in an application. In this problem you will lay out two buttons in a frame. Note that, although this problem uses buttons, the same layout ideas apply to any widget (including other frames). 1 import tkinter as tk 2 3 4 def pressed(): 5 6 Button callback function (command). 7 8 You may alter what this function does if you wish, but you must not rename 9 or delete it. 10 11 12 print ("Button Pressed!") 13 14 15 def create_layout (frame) : 16 17 Add two buttons to the frame. 18 19 Both buttons should have the callback (command) pressed, and they should 20 have the labels "Button" and "Button2". 21 22 The layout in the frame after running this function will be: 23 24 (Button1] (Button2] 25 26 27 Parameters: 28 frame (tk. Frame) : The frame to create the two buttons in. 29 30 31 You need to write a function create_layout that takes a frame as its only argument and adds two buttons at the left of the frame. The first (leftmost) button should have the label "Button1”, and the other should have the label "Button2". The callback (command) for both buttons should be the pressed function. There is no need to create a tk app (the root window and frame will be initialised for you). You must use pack for layout and not grid. The frame should appear as depicted below. When you run your code an extra window screen should pop up showing your layout. You can extend the window to enhance the image.


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer to GUI Layout Example | One important aspect of GUI design is the layout of widgets in an application. In this problem you ...

The Problem has Answer!

We have detailed solutions for you for more understanding.

View Answer