1. Homepage
  2. Programming
  3. BMET2922 Computational Analysis for Biomedical Signals - Laboratory : Graphical User Interfaces

BMET2922 Computational Analysis for Biomedical Signals - Laboratory : Graphical User Interfaces

Engage in a Conversation
澳洲AustraliaUniversity of SydneyBMET2922Computational Analysis for Biomedical SignalsGraphical User InterfacesPython

Laboratory
CourseNana.COM

Graphical User Interfaces CourseNana.COM

1 Introduction CourseNana.COM

To be able to access computer functionality some sort of user interface is required. Traditionally, this was a text-based interface. In some applications the text interface is still preferred and can be extremely powerful. In the majority of applications, from smart phones to medical instruments to industrial control systems, a Graphical User Interface (GUI) is often preferred. CourseNana.COM

2 Objective CourseNana.COM

The objective of this laboratory is to gain skills and confidence in using the capabilities of the pySuimpleGUI graphical user interface package (the call reference page is a handy reference). CourseNana.COM

3 Materials CourseNana.COM

You will need the following materials for this lab. 1. A computer with Python3 installed CourseNana.COM

The microcontroller board is not required for this lab. CourseNana.COM

4 PySimpleGUI CourseNana.COM

4.1 pySimpleGui CourseNana.COM

pySimpleGUI is a Python package to support the simple creation of complex GUIs which can easily interact with Python code. It is cross platform with the package available for Windows, Linux, Mac, and Android. Detailed information about the package is available @ https://pysimplegui.readthedocs.io/en/latest/ CourseNana.COM

The TkInter package, which ships as a standard part of the Python distribution, provides a Python- friendly interface to a cross platform programming language and GUI toolkit, called Tcl/Tk. CourseNana.COM

pySimpleGUI interworks with TkInter to provide a programmatically simple to easily create powerful and flexible GUIs. It is claimed that pySimpleGUI requires “1/2 to 1/10th the amount of code as underlying frameworks” if they were access directly. This means more time and effort can be spent on building the “right” GUI, rather than writing reams of code. CourseNana.COM

pySimplGUI provides a rich set of “elements” which include Text boxes, Sliders, Buttons / Radio buttons, Progress bars, Tables, tabs, panes and more. CourseNana.COM

4.1.1 Layout CourseNana.COM

The layout is a list of row definitions. Each row definition is also a list, even I there is only a single element in that row. i.e. elements in a single row are comma separated, and enclosed in square brackets. CourseNana.COM

Figure 2 - pySimpleGUI Layout declaration CourseNana.COM

4.1.2 Event Loop CourseNana.COM

The Event loop is an infinite loop which repetitively calls window.read(), with an optional timeout specified, to obtain the most recent event (e.g. button push) and a dictionary of values associated with elements in the window. CourseNana.COM

Using this information actions (e.g. button pushes) in the GUI can be detected and acted on, data can be read from the GUI, and using the dictionary window data can also be written to the GUI. Based on CourseNana.COM

Implementing GUIs using pySimpleGUI is comprised of two main parts: 1) creating the window CourseNana.COM


CourseNana.COM

including a “layout” declaration, and 2) continuously reading from the window using an “event CourseNana.COM

Figure 1 - pySimpleGUI layered package approach provides GUI portability CourseNana.COM

Loop”. CourseNana.COM

knowledge of GUI events and values code to implement any required behaviours is implemented in, or called form the event loop. CourseNana.COM

Note that the event sg.WIN_CLOSED (equal to None) in the example above is returned when the window is closed by the user. CourseNana.COM

The calling reference documentation for each of the elements is available @ https://pysimplegui.readthedocs.io/en/latest/call%20reference/. This describes each of the elements, and all of the associated options. Note that most options have useful default values. A first cut of a GUI can typically leave options at their default values. CourseNana.COM

A “cookbook” of examples is available @ https://pysimplegui.readthedocs.io/en/latest/cookbook/. CourseNana.COM

5 Exercises CourseNana.COM

In this lab, as series of programming exercises will be undertaken and functions written to create GUIs of varying complexity and functionality. For each of the exercises, the following are provided:- CourseNana.COM

  1. The docstring for your functions which describes the code to be written is provided (more below)
  2. An example window
  3. Sample output

For each exercise you should write a single function that produces the specified window, behaviour and output. CourseNana.COM

File header – For each file that you create in this lab, please include a header (ie literally the first few lines of the file) of the following format: note the triple “”” to start and finish it are important and must be included: CourseNana.COM

Function header – and for each function, include the header that is provided for that exercise (again, is should literally be the first few lines within the function): CourseNana.COM

import mod as mod
print(mod.__doc__) # prints file/module info print(mod.func.__doc__) # prints function info
CourseNana.COM

5.1 Investigate Themes CourseNana.COM

Create a python file that includes your function for this task. Here is the docstring to go in your function: CourseNana.COM

The default is 4. CourseNana.COM

Hint: the following code may be of assistance. Note that this exercise does not require a Layout or Event Loop. CourseNana.COM

sg.theme_previewer() # creates a window showing all themes themes=sg.theme_list() # returns a list of all themes CourseNana.COM

Output CourseNana.COM

Black BrightColors Dark2 DarkBlack1 DarkBlue10 DarkBlue13 DarkBlue16 DarkBlue3 DarkBlue6 DarkBlue9 DarkBrown2 Etc... CourseNana.COM

BlueMono CourseNana.COM

BrownBlue CourseNana.COM

DarkAmber CourseNana.COM

DarkBlue CourseNana.COM

DarkBlue11 CourseNana.COM

DarkBlue14 CourseNana.COM

DarkBlue17 CourseNana.COM

DarkBlue4 CourseNana.COM

DarkBlue7 CourseNana.COM

5.2 Simple Window CourseNana.COM

Docstring to go in your function for this task: “”” CourseNana.COM

5.3 Button Window CourseNana.COM

Docstring to go in your function for this task: “”” CourseNana.COM

5.4 Multi-Button Window CourseNana.COM

Create a new python file containing a single function for this task. It requires adding multiple buttons to the first row of the window layout. Here is the docstring for your function: CourseNana.COM

5.5 CourseNana.COM

Button pressed was Button 0 Button pressed was Button 2 Button pressed was Button 4 ... CourseNana.COM

          Checkpoint 2 Reached: call you tutors to mark it off CourseNana.COM

Multi-Slider Window CourseNana.COM

Create a new python file containing a single function for this task. It will require reading and understanding the slider element, described here. Scan through the arguments and their descriptions to figure out how to get your desired display and behaviour. Hint: setting the enable_events argument to True in the slider function will make the sliders trigger events whenever they are moved. Here is the docstring for your function: CourseNana.COM

5.6 CourseNana.COM

Slider0 moved to 2.0 Slider0 moved to 3.0 Slider0 moved to 4.0 Slider1 moved to 2.0 Slider1 moved to 4.0 Slider1 moved to 5.0 Slider1 moved to 6.0 Slider1 moved to 7.0 Slider2 moved to 2.0 Slider3 moved to 2.0 Slider3 moved to 3.0 Slider3 moved to 4.0 Slider3 moved to 5.0 Slider3 moved to 6.0 Slider3 moved to 7.0 Slider3 moved to 8.0 Slider3 moved to 9.0 CourseNana.COM

Listbox Window CourseNana.COM

Create a new python file containing a single function for this task. It requires including a listbox element on the first row of the layout, and an exit button on the second row. Again, scan through the arguments for the listbox element and their descriptions to figure out how to get your desired display and behaviour: CourseNana.COM

5.7 Matplotlib GUI CourseNana.COM

Create a new python file containing only your function for this task. Here is the docstring for your CourseNana.COM

There are also some modules you need to import after your docstring, and before your function: CourseNana.COM

from tkinter import *
from random import randint
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, FigureCanvasAgg
from matplotlib.figure import Figure
import tkinter as Tk
CourseNana.COM

This function must be called after the window is created. CourseNana.COM

The axes (ax) support methods including plot(), set_xlabel("...") , etc can then be applied to the ax object returned by addPlot(). Finally the plot can be displayed using the figAgg object returned by addPlot(), in the following way: CourseNana.COM

figAgg.draw() # refresh the canvas CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
澳洲代写,Australia代写,University of Sydney代写,BMET2922代写,Computational Analysis for Biomedical Signals代写,Graphical User Interfaces代写,Python代写,澳洲代编,Australia代编,University of Sydney代编,BMET2922代编,Computational Analysis for Biomedical Signals代编,Graphical User Interfaces代编,Python代编,澳洲代考,Australia代考,University of Sydney代考,BMET2922代考,Computational Analysis for Biomedical Signals代考,Graphical User Interfaces代考,Python代考,澳洲help,Australiahelp,University of Sydneyhelp,BMET2922help,Computational Analysis for Biomedical Signalshelp,Graphical User Interfaceshelp,Pythonhelp,澳洲作业代写,Australia作业代写,University of Sydney作业代写,BMET2922作业代写,Computational Analysis for Biomedical Signals作业代写,Graphical User Interfaces作业代写,Python作业代写,澳洲编程代写,Australia编程代写,University of Sydney编程代写,BMET2922编程代写,Computational Analysis for Biomedical Signals编程代写,Graphical User Interfaces编程代写,Python编程代写,澳洲programming help,Australiaprogramming help,University of Sydneyprogramming help,BMET2922programming help,Computational Analysis for Biomedical Signalsprogramming help,Graphical User Interfacesprogramming help,Pythonprogramming help,澳洲assignment help,Australiaassignment help,University of Sydneyassignment help,BMET2922assignment help,Computational Analysis for Biomedical Signalsassignment help,Graphical User Interfacesassignment help,Pythonassignment help,澳洲solution,Australiasolution,University of Sydneysolution,BMET2922solution,Computational Analysis for Biomedical Signalssolution,Graphical User Interfacessolution,Pythonsolution,