Regarding Python 3:
1. Describe two fundamental differences between terminal-based user interfaces and GUIs.
2. Give an example of one application for which a terminal-based user interface is adequate and one example that lends itself best to a GUI
3. Describe what usually happens in the __init__ method of a main window class.
4. Explain why it's a good idea to make a new class a subclass of an existing class.
5. Write a code segment that centers the labels RED, WHITE, and BLUE vertically in a GUI window. The text of each label should have the color that it names, and the window's background color should be green. The background color of each label should also be green.
1. Describe two fundamental differences between terminal-based user interfaces and GUIs.
Answer:
Terminal Based
User Interfaces
GUI
1) Terminal Based User Interfaces are run by
issuing GUIs are
iteracted through graphical icons and indicators.
a command to them .
2) It is difficult to understand or to remember the
commands. Even a basic user can handle the GUI.
2. Give an example of one application for which a terminal-based
user interface is adequate and one example that lends itself best
to a GUI
Answer:
-> Any Application where there is a lesser
complexity in choosing options like simple programs involves few
options
ex: prime number, palindrome taking
input and showing results.
-> Any Application where you want to apply more
functionalities which makes it difficult for CLI to choose then GUI
is the best.
ex: Library Management , Chat
Server, Student Management and Video and Audio Player.
above all examples involves
multiple stages of selection and moving one stage to another is
becomes simple only if GUI is used.
3. Describe what usually happens in the __init__ method of a main
window class.
Answer:
-> __init__ () method is the constructor for
python class where an object for given class will be created.
and returned.
-> __inti__() is the place where all the
initilizations for the class are occurs.
-> for ex: MainWindow class setting title, size
etc.,
4. Explain why it's a good idea to make a new class a subclass
of an existing class.
Answer:
-> making a class as Subclass of another means
inherting the all the features of the base class
-> which makes the sub class more secured, flexible
,fast and easy to understand.
->ex: making a class as sub class for Frame class
makes the sub class to access all the Frame class
-> like accessing Frame class title,size and
events.
5. Write a code segment that centers the labels RED, WHITE, and
BLUE vertically in a GUI window.
The text of each label should have the color that it names, and the
window's background color should be green.
The background color of each label should also be green.
#------------- gui.py ----------
import tkinter as tk
class GUI:
def __init__(self,master):
self.master = master
#create 3 labels
#tkinter by default centers the
compoenents.
self.red =
tk.Label(self.master,text = "RED",fg="red",bg='green')
self.white =
tk.Label(self.master,text = "WHITE",fg="white",bg='green')
self.blue =
tk.Label(self.master,text = "BLUE",fg="blue",bg='green')
self.red.config(font=("Courier",
18))
self.white.config(font=("Courier",
18))
self.blue.config(font=("Courier",
18))
self.red.pack()
self.white.pack()
self.blue.pack()
root = tk.Tk()
gui = GUI(root)
root.configure(background='green')
root.mainloop()
Get Answers For Free
Most questions answered within 1 hours.