2 #-----------------------------------------------------------
3 # Python script which creates a function "gettext(filename)"
4 # that reads an ASCII file and turns the contents into a
6 # Execute this script using menu option "File/Execute Script",
7 # if Python has been compiled in.
9 # Also: defines a function which can be called with a key
10 # macro (gets the filename via popup prompt) and binds it
11 # to key "^G" (ctrl-"g"), and defines a button named "Get Text"
12 # under the "Edit" menu which does the same.
13 #-----------------------------------------------------------
15 def newlabel(x
, y
, l
):
16 h1
=newelement("Label")
17 d
= {"scale": 1.0, "rotation": 0, "justify": 0, "pin": 0,
18 "position": (x
, y
), "string": l
}
29 D
= {'Font': 'Times-Roman'}
37 h1
= newlabel(T
[0], T
[1], S2
)
41 filepopup('Enter filename to import:', 'gettext')
43 bind('Control_G', 'prompttext')
44 newbutton('Edit', 'Get Text (^G)', 'prompttext')
46 #-----------------------------------------------------------