4.16 FAQ-375 How do I create custom toolbar buttons that run my script macros?
Last Update: 4/12/2016
Buttons on a toolbar are a convenient way of running LabTalk script files. To create your own buttons, you need 3 files in order to create a new button group. The first is the LabTalk script file that contains the script that is executed when the user clicks a button. The second is the bitmap file that contains the image that is displayed on your button(s). The third file, automatically created for you, is an INI file.
The INI file stores the name of the button group, the name of the bitmap file used to create the group, and the number of buttons that the group has.
When creating a custom button group for export to an .OPX file, consider saving your button group's initialization file, bitmap file(s), script file(s), and any other support files to a user-created subfolder in your User Files Folder. When another Origin user installs your .OPX file, your custom subfolder will automatically be created in the user's User Files Folder, and this subfolder will contain the files for the custom button group. This allows you to keep your custom files separate from the other Origin files.
Please follow these steps to put everything together.
- Use Code Builder to develop your LabTalk script OGS file, which contains one or more scripts, organized into different sections, to be associated with one or more buttons.
- Create a bitmap file, using any program that will create a 16 color bitmap such as Window's Paint.
- You can start with the built-in user defined toolbar bitmap with Window's Paint. Open Userdef.bmp found in your User Files Folder.
- The image height needs to remain at 16 and should not be changed. The image width should be 16 times the number of buttons needed. Each button is 16 pixels high by 16 pixels wide.
- Edit each button as needed.
- Save the BMP as a 16 Color Bitmap.
- In Origin, select View: Toolbars to open the Customize Toolbar dialog.
- Click on the Button Groups tab.
- Click the New button in the Button Groups to open the Create Button Group dialog.
- Enter a new Group Name.
- Specify the Number of Buttons.
- Click the Browse button to locate your bitmap file. This file should be in your User Files Folder.
- Click OK.
- The Save As dialog will open. Enter the same name as that of your bitmap file. Click OK to save the INI file. Your group is added to the Groups list. When you select it you will see your button(s).
- Click on one of the buttons to select it.
- Click the Settings button, to open the Button Settings dialog.
- Click the Browse button to locate your OGS file.
- Enter the Section Name of the OGS file and any arguments in the Argument List.
- Enter something descriptive in the Tool Tip Text box.
- Enter a status bar message in the Status Bar text box.
- Click OK.
- Repeat steps 15-21 for each of the buttons in your Button Group.
- Drag the first button out onto your Origin workspace. A toolbar is created. You can now drag all other buttons onto this toolbar.
Keywords:automate, click, repeat, button, bitmap, custom