oskusalerma / blyte

Screenplay writing program

This URL has Read+Write access

blyte / commandsdlg.py
c9ed51d4 » oskusalerma 2006-03-05 Add support for Unicode bui... 1 import misc
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 2 import util
3
4 import xml.sax.saxutils as xss
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 5 from wxPython.wx import *
6 from wxPython.html import *
7
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 8 class CommandsDlg(wxFrame):
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 9 def __init__(self, cfgGl):
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 10 wxFrame.__init__(self, None, -1, "Commands",
11 size = (650, 600), style = wxDEFAULT_FRAME_STYLE)
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 12
e4e3c82e » oskusalerma 2004-07-23 Commands help dialog: Center. 13 self.Center()
14
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 15 vsizer = wxBoxSizer(wxVERTICAL)
16 self.SetSizer(vsizer)
17
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 18 s = '<table border="1"><tr><td><b>Key(s)</b></td>'\
19 '<td><b>Command</b></td></tr>'
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 20
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 21 for cmd in cfgGl.commands:
22 s += '<tr><td bgcolor="#dddddd" valign="top">'
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 23
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 24 if cmd.keys:
25 for key in cmd.keys:
26 k = util.Key.fromInt(key)
27 s += "%s<br>" % xss.escape(k.toStr())
28 else:
29 s += "No key defined<br>"
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 30
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 31 s += '</td><td valign="top">'
32 s += "%s" % xss.escape(cmd.desc)
33 s += "</td></tr>"
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 34
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 35 s += "</table>"
36
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 37 self.html = """
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 38 <html><head></head><body>
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 39
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 40 %s
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 41
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 42 <pre>
43 <b>Mouse:</b>
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 44
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 45 Left click Position cursor
46 Left click + drag Select text
47 Right click Unselect
be1a1bcf » oskusalerma 2004-04-17 Update help text. 48
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 49 <b>Keyboard shortcuts in Find/Replace dialog:</b>
80b486b5 » oskusalerma 2004-04-18 Update help. 50
fe0c5c05 » oskusalerma 2004-05-30 Make End / Page up / Page d... 51 F Find
52 R Replace
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 53 </pre>
54 </body></html>
d1d9b7ed » oskusalerma 2005-05-13 Add configurable keyboard c... 55 """ % s
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 56
57 htmlWin = wxHtmlWindow(self)
58 rep = htmlWin.GetInternalRepresentation()
59 rep.SetIndent(0, wxHTML_INDENT_BOTTOM)
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 60 htmlWin.SetPage(self.html)
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 61 htmlWin.SetFocus()
62
63 vsizer.Add(htmlWin, 1, wxEXPAND)
670ae40a » oskusalerma 2005-05-15 Add configurable keyboard c... 64
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 65 id = wxNewId()
66 menu = wxMenu()
67 menu.Append(id, "&Save as...")
68
69 mb = wxMenuBar()
70 mb.Append(menu, "&File")
71 self.SetMenuBar(mb)
72
73 EVT_MENU(self, id, self.OnSave)
74
95505e70 » oskusalerma 2003-11-29 Add Help/Commands dialog. 75 self.Layout()
76
77 EVT_CLOSE(self, self.OnCloseWindow)
78
79 def OnCloseWindow(self, event):
80 self.Destroy()
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 81
82 def OnSave(self, event):
83 dlg = wxFileDialog(self, "Filename to save as",
84 wildcard = "HTML files (*.html)|*.html|All files|*",
85 style = wxSAVE | wxOVERWRITE_PROMPT)
86
87 if dlg.ShowModal() == wxID_OK:
c9ed51d4 » oskusalerma 2006-03-05 Add support for Unicode bui... 88 util.writeToFile(misc.fromGUIUnicode(dlg.GetPath()), self.html,
89 self)
5196ae7a » oskusalerma 2005-05-15 Add "Save as" to commands h... 90
91 dlg.Destroy()