Answer to Question #102103 in Python for Nomathemba Ndlovu

Question #102103
You are required to develop the user Interface for a single screen application for a travel agent to introduce the 2020 Olympic to potential travellers. Travel agent must have a list of visitors (name,email address) for follow-up. Each widget must be clearly labelled and there must be a clear MOTIVATION in terms of the functions .
1. Explain the use of the layout and spaces used on the user Interface
2. Include a button widget and motivate your selection.
3. Include a container widget and motivate your selection.
4. Include an input widget motivate your selection.
5. Include a display widget and motivate your selection.
6. Include a screenshot of the draft/proposal User Interface
1
Expert's answer
2020-02-02T07:57:39-0500

data.py

class Visitor:
    def __init__(self, name, email, ordered_data):
        self.name = name
        self.email = email
        self.ordered_data = ordered_data


visitors = [
    Visitor("Bradley Cooper", "BradleyCooper@gmail.com", "not ordered"),
    Visitor("Brad Pitt", "BradPitt@gmail.com", "not ordered"),
    Visitor("Leonardo DiCaprio", "LeonardoDiCaprio@gmail.com", "not ordered"),
    Visitor("Jennifer Connelly", "JenniferConnelly@gmail.com", "not ordered"),
    Visitor("Jim Carrey", "JimCarrey@gmail.com", "not ordered")
]

UI.py

from data import visitors
import tkinter
from tkinter.font import Font
from tkinter import ttk

current_visitor = ""

visitors_names = []

i = 0
while (i < len(visitors)):
    visitors_names.append(visitors[i].name)
    i += 1


def selected(event):
    global current_visitor, visitor_info

    i = 0
    while (i < len(visitors)):
        if (visitors_list.get() == visitors[i].name):
            current_visitor = visitors[i]

        i += 1


    visitor_info.configure(state="normal")
    visitor_info.delete(1.0,tkinter.END)

    visitor_info.insert(tkinter.END, "Name: " + current_visitor.name)
    visitor_info.insert(tkinter.END, "\nEmail: " + current_visitor.email)
    visitor_info.insert(tkinter.END, "\nOrdered data: " + current_visitor.ordered_data)

    visitor_info.configure(state="disabled")


def order():
    global current_visitor
    current_visitor.ordered_data = set_data_field.get()


root = tkinter.Tk()

title_font = Font(family="Consolas", size=16)
main_font = Font(family="Consolas", size=12)

root.resizable(False, False)
root.title("GUI")
root.geometry("640x360")

title = tkinter.Label(root, text="2020 Summer Olympics")
title.configure(font=title_font)
title.place(x=200, y=0)

opening_data = tkinter.Label(root, text="Opening: 24 July")
clothing_data = tkinter.Label(root, text="Closing: 9 August")
opening_data.configure(font=main_font)
clothing_data.configure(font=main_font)
opening_data.place(x=130, y=30)
clothing_data.place(x=350, y=30)

v = tkinter.Label(root, text="Visitor:")
v.configure(font=main_font)
v.place(x=170, y=80)

visitors_list = ttk.Combobox(root, values=visitors_names)
visitors_list.current(0)
visitors_list.bind("<<ComboboxSelected>>", selected)
visitors_list.configure(font=main_font)
visitors_list.place(x=270, y=80)

visitor_info = tkinter.Text(root, height = 5, width = 40)
visitor_info.configure(font=main_font, state="disabled")
visitor_info.place(x=140, y=120)

d = tkinter.Label(root, text="Order:")
d.configure(font=main_font)
d.place(x=120, y=250)

set_data_field = tkinter.Entry(root)
set_data_field.configure(font=main_font)
set_data_field.place(x=225, y=250)

set_data_field.insert(0, "24 July")

make_order = tkinter.Button(root, text="Make order", command=order)
make_order.configure(font=main_font)
make_order.place(x=460, y=245)

root.mainloop()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS