Solved-Homework Assignment 4 -Solution

$30.00 $19.00

Instructions Please read the the following instructions carefully before coding. You may lose points if you fail to follow these instructions. Deadline for this assignment is May 10, 11:59PM. No late submissions accepted. You will need create a sub-folder for each question, since your answers to first two questions will have a complicated directory structure.…

You’ll get a: . zip file solution

 

 

Description

5/5 – (2 votes)

Instructions

Please read the the following instructions carefully before coding. You may lose points if you fail to follow these instructions.

Deadline for this assignment is May 10, 11:59PM. No late submissions accepted.

You will need create a sub-folder for each question, since your answers to first two questions will have a complicated directory structure.

Note: Please rename your folder in the right way before zipping! For example, if your name is Trung Nguyen and your student ID is 111345678, put all submission files in a folder named Trung_Nguyen_1112345678, then compress that folder to Trung_Nguyen_1112345678.zip.

  • Edit Functionality for Wiki[30 points + 5 points bonus]

Your task in this question is to add an edit page to the Flask example provided in Lecture 21 such that the users are able to edit an article with <postid> by navigating to /edit/<postid>. You will need to create an additional method inside the routes.py, create a new template named edit.html for the edit page, and create a new form object under forms.py. Also, you will need to add a link to the corresponding edit page in /posts/<postid>(e.g., there should be a link to /edit/3 in /posts/3) Once the user edits and submits an article, your method should save this new entry to a file named <postid>.txt. Updating the actual entry in the database can be a bit trickier, so we leave that as a bonus.

Figure 1: Sample Input Form for Question 1.

Bonus[5 points]: Update the corresponding database entry once the user edits an article.

  • Web Calculator[40 points]

Write a Flask application whose index page contains a form similar to the one shown in Figure 2. The user should be able to enter two numbers, and choose the desired operation. Once the user clicks submit, your application should redirect to /result/<operationname> (e.g., /result/add) and there it should display the result to the user, along with a link back to the index page. Your application should check for invalid inputs(i.e., it needs to ensure the inputs are integers or floats ) and redirect to another page(e.g., /result/error/) where

an error message will be displayed to the user, with a link back to the index page. Your application should also feature custom error pages for 404, 403 and 500 status codes(Contents of these pages are up to you). Your design elements should be decoupled from the Python code, and the overall design needs to be modular. You should concentrate on avoiding repeating code as much as possible.

Figure 2: Sample Input Form for Question 2.

  • GUI Programming [30 points + 5 bonus points]

Drawing Program[20 points]

The Canvas widget we have seen in the class allows us to do more than placing a text on a particular location. Among others, it is possible to draw lines, rectangles and ovals on a Canvas using appropriate functions(You can find out more about these functions at Tkinter documentation). Your task in this question is to design a GUI that allows user to draw rectangles, lines or ovals on a Canvas with the desired size and shape. All three functions take four size and shape parameters, so you will not need to worry about checking the number of parameters. However, your script should check whether the object stays in the boundaries of the Canvas, and if this is not the case, it should display a warning message as in Figure 4. Also, your script should check for invalid input such as non-integers or negative values, and display a warning message if there is an error.

Figure 3: Desired GUI for Question 3.

Figure 4: Sample Error Message for Question 3.

Advanced Features [10 points]

Add another entry field and three more radio buttons(red, green and blue) to allow users to choose width and color parameters. You can add these additional widgets below your original widgets.

Bonus [5 points]: Add a button to your program that allows users to delete the most recent shape.

3