public
Description: Screenplay writing program
Homepage: http://www.oskusoft.com
Clone URL: git://github.com/oskusalerma/blyte.git
oskusalerma (author)
Mon Sep 08 06:23:11 -0700 2008
commit  21ce2faf8dca2eb52ea51480ae1bf6cae0d51a38
tree    5e1066594e119362fef504601088ba95f04a6ace
parent  dfcbe4bd651227bc8dc9b1142f3fc5b74da7cede
blyte / commandsdlg.py
100644 92 lines (65 sloc) 2.293 kb
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
81
82
83
84
85
86
87
88
89
90
91
92
import misc
import util
 
import xml.sax.saxutils as xss
from wxPython.wx import *
from wxPython.html import *
 
class CommandsDlg(wxFrame):
    def __init__(self, cfgGl):
        wxFrame.__init__(self, None, -1, "Commands",
                         size = (650, 600), style = wxDEFAULT_FRAME_STYLE)
 
        self.Center()
        
        vsizer = wxBoxSizer(wxVERTICAL)
        self.SetSizer(vsizer)
 
        s = '<table border="1"><tr><td><b>Key(s)</b></td>'\
            '<td><b>Command</b></td></tr>'
 
        for cmd in cfgGl.commands:
            s += '<tr><td bgcolor="#dddddd" valign="top">'
 
            if cmd.keys:
                for key in cmd.keys:
                    k = util.Key.fromInt(key)
                    s += "%s<br>" % xss.escape(k.toStr())
            else:
                s += "No key defined<br>"
 
            s += '</td><td valign="top">'
            s += "%s" % xss.escape(cmd.desc)
            s += "</td></tr>"
 
        s += "</table>"
        
        self.html = """
<html><head></head><body>
 
%s
 
<pre>
<b>Mouse:</b>
 
Left click Position cursor
Left click + drag Select text
Right click Unselect
 
<b>Keyboard shortcuts in Find/Replace dialog:</b>
 
F Find
R Replace
</pre>
</body></html>
""" % s
        
        htmlWin = wxHtmlWindow(self)
        rep = htmlWin.GetInternalRepresentation()
        rep.SetIndent(0, wxHTML_INDENT_BOTTOM)
        htmlWin.SetPage(self.html)
        htmlWin.SetFocus()
        
        vsizer.Add(htmlWin, 1, wxEXPAND)
 
        id = wxNewId()
        menu = wxMenu()
        menu.Append(id, "&Save as...")
 
        mb = wxMenuBar()
        mb.Append(menu, "&File")
        self.SetMenuBar(mb)
 
        EVT_MENU(self, id, self.OnSave)
 
        self.Layout()
 
        EVT_CLOSE(self, self.OnCloseWindow)
 
    def OnCloseWindow(self, event):
        self.Destroy()
 
    def OnSave(self, event):
        dlg = wxFileDialog(self, "Filename to save as",
            wildcard = "HTML files (*.html)|*.html|All files|*",
            style = wxSAVE | wxOVERWRITE_PROMPT)
 
        if dlg.ShowModal() == wxID_OK:
            util.writeToFile(misc.fromGUIUnicode(dlg.GetPath()), self.html,
                             self)
            
        dlg.Destroy()