Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio | Private | Search

 

Example: Create a Periodic Table Dialog
Function
Creates a periodic table with elements as buttons which report chemical information.
Version
version: 150308, v1.0
Author
D. R. G. Mitchell
Acknowledgements
Werner Grogger's GetElementSymbol() and GetElementName() functions are used here. Shixin Wang's sub-dialog code on the DMSUG web archive was useful in getting interactive sub-dialogs to work.
Comments

This example script will create a periodic table in which chemical elements are buttons. Pressing a button will cause a sub-dialog to appear, which reports some basic information on the element. You may choose to use this as a basis for any kind of database script which might report chemically-dependent information, such as edge/peak positions etc.

Key concepts demonstrated in this code are using dual state bevel buttons as a means of identifying which button has been pressed. This is useful when you have many (in this case 103) buttons using the same actionmethod. Also demonstrated is the use of an Interface to declare functions. This script uses two classes - one for the main dialog and one for sub-dialog. By using an Interface, functions declared in one class can be used by another. This avoids the need to have the same functions listed in both classes. The script also demonstrates how to create a sub-dialog which is interactive. The sub-dialog contains buttons which interact with the sub-dialog class. As such, the sub-dialog object must be allocated within the main dialog class (but not displayed until needed). This is a much more flexible approach than is possible when using Pose() to display a sub-dialog . There, only limited interaction is possible.

System Requirements
Should be compatible with all recent versions of DigitalMicrograph. Tested on GMS 2.3 running on XP.
Known Issues
Dialog construction takes a few seconds. Formatting of the buttons is fine on my system. However, I find that dialog layouts can shift slightly between versions of GMS and Windows operating systems.
Supported
Yes
Included Files
Main script file.
Source Code
See attached script