forked from capocchi/DEVSimPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlWindow.py
73 lines (57 loc) · 1.74 KB
/
HtmlWindow.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
# -*- coding: utf-8 -*-
import os
import wx
import wx.html
class HtmlFrame(wx.Frame):
""" General Frame displaying Html doc
"""
###
def __init__(self, parent, id, title, size):
wx.Frame.__init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN )
file = wx.Menu()
file.Append(wx.ID_FILE, _('&File\tCtrl+F'), _('Open Html local file'))
menubar = wx.MenuBar()
menubar.Append(file, _('&File'))
self.SetMenuBar(menubar)
self.html = wx.html.HtmlWindow(self, wx.NewIdRef())
if "gtk2" in wx.PlatformInfo:
self.html.SetStandardFonts()
self.Bind(wx.EVT_MENU, self.OnLoadFile, id=wx.ID_FILE)
###
def LoadFile(self, path):
""" Load Html File from local path
"""
self.html.LoadFile(path)
###
def SetPage(self, s):
""" Set Html page from string
"""
self.html.SetPage(s)
###
def OnLoadFile(self, event):
""" Load Html file from dialog
"""
dlg = wx.FileDialog(self, wildcard = '*.htm*', style=wx.OPEN)
if dlg.ShowModal():
path = dlg.GetPath()
self.html.LoadPage(path)
dlg.Destroy()
###
def OnClearPage(self, event):
""" Clear page
"""
self.html.SetPage("")
def main():
app = wx.PySimpleApp()
# create a window/frame, no parent, -1 is default ID, title, size
frame = HtmlFrame(None, -1, "Alone Mode", size=(800,600))
# show the frame
frame.Show()
# start the event loop
app.MainLoop()
if __name__ == '__main__':
import builtins
import gettext
builtins.__dict__['HOME_PATH'] = os.getcwd()
builtins.__dict__['_'] = gettext.gettext
main()