Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Week 8 Lab (I/O) Update your state feedback form to store new comments in a flat file; add a button to return that file. Update

Week 8 Lab (I/O)

Update your state feedback form to store new comments in a flat file; add a button to return that file.

Update your state feedback form to store new comments in a database (either in memory or in a db file); add a button to return all records.

#!/usr/bin/env python3 #Name: Tkinter.py #Purpose: Create a state feedback form. #Developer: IO from tkinter import * from tkinter import ttk from tkinter import messagebox class Feedback: def __init__(self, master): master.title('Explore Texas Feedback') master.resizable(False, False) master.configure(background = '#e1b9b9') self.style = ttk.Style() self.style.configure('TFrame', background = '#e1b9b9') self.style.configure('TButton', background = '#e1b9b9') self.style.configure('TLabel', background = '#e1b9b9', font = ('Baloo', 13)) self.style.configure('Header.TLabel', font = ('Baloo', 20)) self.frame_header = ttk.Frame(master) self.frame_header.pack() self.logo = PhotoImage(file = 'tour_logo.gif') ttk.Label(self.frame_header, image = self.logo).grid(row = 0, column = 0, rowspan = 2) ttk.Label(self.frame_header, text = 'Thanks for Exploring!', style = 'Header.TLabel').grid(row = 0, column = 1) ttk.Label(self.frame_header, wraplength = 400, text = ("We're delighted you chose Explore Texas for your recent adventure!! " "Please tell us about your thoughts about the 'Desert to Sea' tour.")).grid(row = 1, column = 1) self.frame_content = ttk.Frame(master) self.frame_content.pack() ttk.Label(self.frame_content, text = 'Name:').grid(row = 0, column = 0, padx = 5, sticky = 'sw') ttk.Label(self.frame_content, text = 'Email:').grid(row = 0, column = 1, padx = 5, sticky = 'sw') ttk.Label(self.frame_content, text = 'Comments:').grid(row = 2, column = 0, padx = 5, sticky = 'sw') self.entry_name = ttk.Entry(self.frame_content, width = 24, font = ('Baloo', 10)) self.entry_email = ttk.Entry(self.frame_content, width = 24, font = ('Baloo', 10)) self.text_comments = Text(self.frame_content, width = 50, height = 10, font = ('Baloo', 10)) self.entry_name.grid(row = 1, column = 0, padx = 5) self.entry_email.grid(row = 1, column = 1, padx = 5) self.text_comments.grid(row = 3, column = 0, columnspan = 2, padx = 5) ttk.Button(self.frame_content, text = 'Submit', command = self.submit).grid(row = 4, column = 0, padx = 5, pady = 5, sticky = 'e') ttk.Button(self.frame_content, text = 'Clear', command = self.clear).grid(row = 4, column = 1, padx = 5, pady = 5, sticky = 'w') def submit(self): print('Name: {}'.format(self.entry_name.get())) print('Email: {}'.format(self.entry_email.get())) print('Comments: {}'.format(self.text_comments.get(1.0, 'end'))) self.clear() messagebox.showinfo(title = 'Explore Texas Feedback', message = 'Comments Submitted!') def clear(self): self.entry_name.delete(0, 'end') self.entry_email.delete(0, 'end') self.text_comments.delete(1.0, 'end') def main(): root = Tk() feedback = Feedback(root) root.mainloop() if __name__ == "__main__": main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

Question Can employees make contributions to a profit sharing plan?

Answered: 1 week ago