Title: Bliss GUI Framework Quick introduction : concepts
1Bliss GUI Framework Quick introduction
concepts practical examples
- Presented by Matias Guijarro
- BLISS group
2What is the Bliss GUI Framework ?
1/2
- to provide libraries and tools to develop
Graphical User Interfaces on beamlines
- to emphasise on code reusability and GUI
standardization
- to free GUI programming from data sources and
controllers (spec, taco, tango, etc.)
- Written in Python, graphical toolkit Trolltech
Qt
- Model-View-Controller architecture
- Bricks instead of widgets as building blocks
- GUI Editor hides layout complexity for rapid GUI
building
3What is the Bliss GUI Framework ?
2/2
Application
Bliss Framework project
Bricks library
Abstraction layer
Control software (spec, taco, tango, etc.)
hardware
4Abstraction from Hardware and Control Software
- Model-View-Controller (MVC) architecture
- view is separated from model
- this ensures GUI code does not get mixed with
beamline control
Bliss Framework
abstraction layer
Beamline GUI application
GUI Bricks
hardware, spec, device servers
- The Hardware Repository abstraction layer
- part of the Bliss GUI Framework
- provides objects representing beamline control
devices
5Hardware Repository
- The Hardware Repository holds the description of
the devices, equipments and procedures of a
beamline in a database
- The database is a set of XML files
- Each file represents at least one Hardware Object
- The Hardware Repository manages the pool of
Hardware Objects
Hardware Repository module
XML
6Using bricks as building blocks
- A Framework GUI application is made of
cemented bricks
- All bricks derive from the same base class
BlissWidget
Bricks can communicate between them
Beamline GUI
Bricks have a behavior A brick holds a set of
properties for configuration
A brick has a graphical representation
- The Framework provide services for the bricks
- application
- properties persistance
- layout management
- run modes
- access to Hardware Repository
7Practical exercise 1 lets install the
Framework on a beamline
1/2
- Packages are available in the Bliss Installer
- applications/control/Framework/BlissFramework
Core the base components - applications/control/Framework/Bricks bricks
of the standard library each brick has its own
package - applications/control/Framework/Icons icons
library
- control/HWR/HardwareRepositoryServer one
Hardware Repository server is needed per beamline - control/HWR/HardwareRepositoryClient
- control/HWR/Object Hardware Objects library,
each Hardware Object has its own package
8Practical exercise 1 lets install the
Framework on a beamline
2/2
- Configuring Hardware Repository server
- needs one parameter path to the xml files
- optional parameter name of the server (hwr
by default)
- The Hardware Repository server should start with
the main beamline control computer use the
bliss_dserver script
- Once it is running, you can fill the Hardware
Repository directory with xml files describing
Hardware Objects
- the genSpecXML tool can generate automatically
xml files for a Spec version
basil genSpecXML basil oh1 /local/HardwareRep
ository
9Practical exercise 2 lets create a new GUI
application
1/3
- it generates an empty GUI application file
- it creates a startup script
10Practical exercise 2 lets create a new GUI
application
2/3
- Today there are more than 60 bricks
- approximatively 75 percent are for general use
- others are beamline-specific (MX, BM29, ID21,
ID13, etc.)
- Building a GUI application using the standard
bricks is easy
11Practical exercise 2 lets create a new GUI
application
3/3
- After setting properties, here is the result
12Practical exercise 3 lets write a (very)
simple brick
1/3
- The brick will be able to display a motor
position and status
- At the beginning, just code the appearance of
the brick
from BlissFramework.BaseComponents import
BlissWidget from qt import class
ExampleBrick(BlissWidget) def __init__(self,
args) BlissWidget.__init__(self, args)
self.motor_frame QVGroupBox(Motor name
here, self) hbox QHBox(self.motor_frame)
QLabel(Motor position , hbox)
self.motor_pos QLabel(hbox)
QVBoxLayout(self) self.layout().addWidget(self
.motor_frame) self.setSizePolicy(QSizePolicy.M
inimumExpanding, QSizePolicy.Fixed)
- Then save the file with the same name as the
brick class ExampleBrick.py in a Bricks
directory
- You can already see the new brick in the GUI
Editor by clicking on the Refresh button
13Practical exercise lets write a (very) simple
brick
2/3
- add a mnemonic property to the brick
from BlissFramework.BaseComponents import
BlissWidget from qt import class
ExampleBrick(BlissWidget) def __init__(self,
args) BlissWidget.__init__(self, args)
self.addProperty(mnemonic, string)
self.motor_frame QVGroupBox(Motor name
here, self) hbox QHBox(self.motor_frame)
QLabel(Motor position , hbox)
self.motor_pos QLabel(hbox)
QVBoxLayout(self) self.layout().addWidget(self
.motor_frame) self.setSizePolicy(QSizePolicy.M
inimumExpanding, QSizePolicy.Fixed) def
propertyChanged(self, property, old_value,
new_value) if propertymnemonic
self.motor self.getHardwareObject(new_value)
if self.motor is not None
self.connect(self.motor, positionChanged,
self.motor_pos_changed)
self.connect(self.motor, stateChanged,
self.motor_state_changed)
self.motor_frame.setTitle("Motor name s"
self.motor.username)
- 2nd step is to add the brick properties
- when the property changes, get the Hardware
Object (which should be a motor in this case)
- create connections between the Hardware Object
and the brick
- In this example we just need a mnemonic
property that will contain a reference to the
Motor Hardware Object
- When the property changes, the brick is
connected to the Motor Hardware Object
14Practical exercise lets write a (very) simple
brick
3/3
- now we just need to write the two missing methods
- motor_pos_changed called when
positionChanged signal is emitted by Motor
Hardware Object
- motor_state_changed called when stateChanged
signal is emitted by Motor Hardware Object
def motor_pos_changed(self, pos)
self.motor_pos.setText(str(pos)) def
motor_state_changed(self, state) bg_color
self.colorGroup().background() color
bg_color, bg_color, Qt.green, Qt.yellow,
Qt.yellow, Qt.red, bg_color
self.motor_pos.setPaletteBackgroundColor(colorsta
te)
- the final step is to test the brick into a GUI
15(No Transcript)
16Results already obtained with the Framework
- at the beginning of the project, high demand for
GUI on MX beamlines recently, Framework-based
GUIs are being created for other beamlines
mxCuBE
ID13 / Microfocus
ID21
- better Hardware Repository
- making interface to spec for small GUIs even
simpler - more possibilities for windows, layout, menu
bars, etc. - documentation
17Already existing documentation (dont laugh)
- Bliss Framework Startup Guide
http//www.esrf.fr/computing/bliss/guides/gui/fram
ework/FrameworkInstall.pdf
http//blissdb/bricks
18Thanks for your attention ? Any questions ?