-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyperlinkDialog.py
85 lines (60 loc) · 2.48 KB
/
hyperlinkDialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import tkinter as tk
from wwc_hyperlinkpagerefs import hyperlink, remove_links
class hyperlinkDialog(tk.Toplevel):
def __init__(self, parent, display, pgRange=None):
tk.Toplevel.__init__(self, parent)
self.parent=parent
self.display=display
self.pgRange=pgRange
self.displayDialog()
def displayDialog(self):
def onClosing():
print('closing')
self.display.updatestatusBar("")
self.destroy()
def onEscape(i):
onClosing()
def hyperLink():
options={}
options['pgRange']=e1.get()
self.display.updatestatusBar('Hyperlinking...')
if hyperlink(self.display.doc, self.display, options):
onClosing()
self.display.updatestatusBar('Finished hyperlinking.')
def removeLinks():
options={}
options['pgRange']=e1.get()
self.display.updatestatusBar('Removing links...')
if remove_links(self.display.doc, self.display, options):
onClosing()
self.display.updatestatusBar('Finished removing links.')
self.title('Hyperlink')
self.attributes('-topmost', True)
f1=tk.Frame(self)
f1.pack(fill=tk.X, padx=5)
l1=tk.Label(f1,text='Page range:')
l1.pack(side=tk.LEFT,padx=5,pady=5)
e1=tk.Entry(f1)
e1.pack(side=tk.LEFT, fill=tk.X, expand=1,pady=5)
if self.pgRange: #set pgRange if supplied
e1.delete(0,tk.END)
e1.insert(0,self.pgRange)
f2=tk.Frame(self)
f2.pack(fill=tk.X, padx=5)
l1=tk.Label(f2,text='Page ref style:')
l1.pack(side=tk.LEFT,padx=5,pady=5)
textVarpgRefs=tk.StringVar()
textVarpgRefs.set('[]')
styleChoices = ['[]', '{}', 'page', 'pg']
styleOption = tk.OptionMenu(f2, textVarpgRefs, *styleChoices)
styleOption.pack(side=tk.LEFT, fill=tk.X, expand=1,pady=5)
f3=tk.Frame(self)
f3.pack(fill=tk.X, padx=5, pady=5)
okButton=tk.Button(f3,text='Add links', command=hyperLink)
okButton.pack(side=tk.RIGHT)
removeButton = tk.Button(f3, text='Remove links', command=removeLinks)
removeButton.pack(side=tk.RIGHT)
cancelButton=tk.Button(f3,text='Cancel', command=onClosing)
cancelButton.pack(side=tk.RIGHT)
self.bind('<Key-Escape>', lambda i: onEscape(i))
self.protocol('WM_DELETE_WINDOW', onClosing)