Create two new qlineedits for name and symptoms respectively

Assignment Help Computer Engineering
Reference no: EM131734594

Assignment: Introduction to Computer Science for Life Scientists

Exercise 1 (GUI Programming, 25 Points)

1747_The-main-window-with-the-list-widget.jpg
Figure 1: The main window with the list widget.

In this exercise, you will develop a small GUI application that shows a list of subjects with their personal data, and allows the user to interactively edit it. We provide a scaffold list.py on the course webpage that you may use as a starting point. It defines ListWindow as a class for the main window, containing a member list of type QListWidget to show the list of subjects. Buttons underneath should allow editing. The personal data (name, year of birth, gender and symptoms) is stored in the member variable ListWindow.data.

Implement the function updateList() in the class ListWindow. It should populate list with the subject names currently stored in data. This requires the use of QListWidget.addItem() for each subject. Since updateList() might get called repeatedly, you have to QListWidget.clear() all previous entries from list first.

When the user clicks on the button Edit, we want the function onEditClicked() to be called. In the Qt library you can set a function handling the clicked signal via some_button.clicked.connect(some_function).

Add a new function onDeleteClicked() to ListWindow, that deletes the subject in data that is currently selected by the user in list. Don't forget to also repopulate list.

Now it is time to implement the SubjectDialog. It should present the detailed information of a single subject. For this we need to add GUI elements in the constructor SubjectDia- log. init (). We want to be able to edit the subject's name (text), the year of birth (number), gender (multiple choice) and symptoms (again, text).

1740_The-dialog-box-for-the-subject-data.jpg
Figure 2: The dialog box for the subject data.

- Create two new QLineEdits for the name and symptoms respectively. (only creating them won't make them visible on the dialog box, we will take care of that later with the help of layouts)

- Create a new QSpinBox for the year of birth. Set an appropriate range of allowed values with setRange().

- For the gender, create 3 new QRadioButtons ('m', 'f ' and ' ?' ). Since only one choice should be possible simultaneously, we also need to create a QButtonGroup and add the 3 radio buttons to it.

- Create two buttons for Ok and Cancel. Qt already provides default handlers for both (self.accept and self.reject), but you still need to connect them to the buttons.

- Create a suitable layout. Use a QHBoxLayout to arrange the two buttons in a horizontal row. QFormLayout allows to stack the other widgets vertically and automatically add labels next to them ('Name' etc.). Stack these two layouts vertically using a QVBoxLayout and apply it to the dialog via self.setLayout().

Hint: layouts in Qt have separate functions addWidget() and addLayout() to add child GUI elements directly or another child layout.

- We need to transport our subject's data in and out of the dialog. For this we need two new functions getData() and setData() in SubjectDialog. setData(subject) should receive the data of a single subject (as a list) and fill out the appropriate GUI elements (for example QLineEdit.setText() and QRadioButton.setChecked()). getData() should read out the GUI elements (for example QLineEdit.text()), put the data into a list and return it.

We can now also add a function in ListWindow to handle clicking the Add button. Similarly to onEditClicked() this new function should also show the SubjectDialog but add the result to data instead of replacing an existing element.

Add two new buttons Load and Save to the main window that let the user choose a file (via QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName()) and load/store data to the chosen file.

Hint: to store the subject list into a file, you can use your knowledge from previous assignments, but in this case, it is also permitted to use the pandas library, python's pickle mechanism or other methods you might prefer.

Reference no: EM131734594

Questions Cloud

Each step of the business-to-business buying process : Briefly, explain what would happen at each step of the business-to-business buying process.
Compute the materials price variance : Beary Company produces stuffed bears. Compute the Materials Price variance, Materials Usage variance and the Total Materials Variance
Does the article assign responsibility to persons : Does the article assign responsibility to persons or processes for the problems or achievements it reports?
Calculate net present value of the investment opportunity : Callaghan has an average cost of capital of 10 percent. Calculate the net present value of the investment opportunity
Create two new qlineedits for name and symptoms respectively : Create two new QLineEdits for name and symptoms respectively. Create a new QSpinBox for year of birth. Set appropriate range of allowed values with setRange().
Name the website and describe the features : Now that we have become familiar with technology and web design, can you now identify a website (can be any website, retail, business etc.)
Identify two products or services : Identify two products or services for which you believe reference group appeal would be very strong.
President of lakefront manufacturing : Lillian fok is president of lakefront manufacturing, a producer of bicycle tires. Fok makes 1,000 tires per day with the following resources labor
What should richman company report as a gain on the bonds : Assuming Richman Company has a portfolio of available-for-sale debt investments, what should Richman Company report as a gain (or loss) on the bonds

Reviews

Write a Review

Computer Engineering Questions & Answers

  What does this following algorithm calculate

What does this following algorithm calculate

  What is a possible downside of making such a choice

The mainframe currently only connects to terminals, but management wants to be able to access it from  desktop. You run a token ring network. The mainframe manufacturer supports Ethernet, but not token ring. maintain an outline of possible solutio..

  Discuss the requirements of a linear programming

Discuss the requirements of a linear programming (LP) model. Provide an example of an LP model and define each variable used. What are the key steps that need to be considered when formulating an LP problem

  Selectnbspan information system for development that

selectnbspan information system for development that would benefit your workplace or a workplace from a case study.

  Build bootstrap calculator and simulation calculator

Create a table of the results in word, or a text document and write up your conclusions based on the table, send me the document, and text copies or a dump file of your r programs."

  Consider a two-dimensional integer array of size n x m

Consider a two-dimensional integer array of size n x m that is to be used in your favorite programming language.

  Determining the closure under operation

Explain whether the following sets closed under following operations? Justify your answer. If a set is not closed under operation, what is its closure under the operation.

  Implement a new instruction that has two register operands

The MIPS instruction sequence could be used to implement a new instruction that has two register operands.

  Questiongiven following sequence of events interrupt

questiongiven following sequence of events interrupt requests irqi show which services routines cpu is executing for

  Suggest three techniques to overcome the given challenges

One of your developers tells you that it would be way too complicated to add voice recognition into the app. Suggest three techniques to overcome the challenges of implementing natural language into interface designs.

  Calculate and display their individual pay increases

They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases.

  Describe the key analogies and concepts the monitors expose

Describe the key analogies and concepts these monitors expose to users, including the task-domain objects users manipulate on the screen.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd