Size: 2487
Comment:
|
Size: 2490
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 43: | Line 43: |
1. guitype='', this specifies what type of widget we want to use for this GUI 1. row='', this specifies what row the widget should appear in 1. column='', this specifies what column the widget should appear in 1. rowspan='', this specifies how many rows the widget should span 1. columnspan='', this specifies how many columns the widget should span 1. browser, if the widget represnts and option that refers to a file, this keyword argument lists a filebrowser to use. |
1. guitype="", this specifies what type of widget we want to use for this GUI 1. row="", this specifies what row the widget should appear in 1. column="", this specifies what column the widget should appear in 1. rowspan="", this specifies how many rows the widget should span 1. columnspan="", this specifies how many columns the widget should span 1. browser="", if the widget represnts and option that refers to a file, this keyword argument lists a filebrowser to use. |
Tutorial to aid adding a new e2program to the e2projectmanager.py
This tutorial covers the necessary steps to incorporate a e2program into the projectmanager.
Modifications to the e2program itself
Canonical e2programs must maintain the following standards
Options are handled via EMArgumentParser, which is a subclass of Python's argparse module (version 2.7 and higher). For more information on argparse, see the python documentation. http://docs.python.org/dev/library/argparse.html
- Arguments are handled via EMArgumentParser.
- A line usage = """blah, blah, blah...""" must be present to give help info on the e2program
- A line progname = os.path.basename(sys.argv[0]) must be present
To illustrate what an e2program should look like, here is an example program:
1 #!/usr/bin/env python
2 #
3 # GPL licensing info goes here
4 #
5
6 from EMAN2 import *
7
8 def main():
9 progname = os.path.basename(sys.argv[0])
10 usage = """prog arg1, arg2, [options]
11 This is an exmaple program """
12
13 parser = EMArgumentParser(usage=usage,version=EMANVERSION)
14 parser.add_argument("--option1",type=str,help="This is the first option",default="myvalue")
15 parser.add_argument("--option2",type=int,help="This is the second option",default=1)
16 parser.add_argument("--option3",type=float,help="This is the third option",default=3.14)
17 parser.add_argument("--option4",action="store_true",help="This is the fourth option",default=False)
18
19 (options, args) = parser.parse_args()
20
21 print "Arguments are", args
22 print "Options are", options
23
24 if __name__ == __main__:
25 main()
To enable this program to be integrated into the GUI the following item must be implemented:
- For each argument the method: parser.add_pos_argument()
- To add dividing lines with help info into the GUI, add the method: parser.add_header()
- To all parser 'add' methods the following keyword arguments must be added
- guitype="", this specifies what type of widget we want to use for this GUI
- row="", this specifies what row the widget should appear in
- column="", this specifies what column the widget should appear in
- rowspan="", this specifies how many rows the widget should span
- columnspan="", this specifies how many columns the widget should span
- browser="", if the widget represnts and option that refers to a file, this keyword argument lists a filebrowser to use.