diff --git a/utils/wxPython/demo/Main.py b/utils/wxPython/demo/Main.py index 92630666ee..175b0c4e15 100644 --- a/utils/wxPython/demo/Main.py +++ b/utils/wxPython/demo/Main.py @@ -23,7 +23,8 @@ _treeList = [ ('Miscellaneous Windows', ['wxGrid', 'wxSashWindow', 'wxScrolledWindow', 'wxSplitterWindow', - 'wxStatusBar', 'wxToolBar', 'wxNotebook']), + 'wxStatusBar', 'wxToolBar', 'wxNotebook', + 'wxHtmlWindow']), ('Common Dialogs', ['wxColourDialog', 'wxDirDialog', 'wxFileDialog', 'wxSingleChoiceDialog', 'wxTextEntryDialog', @@ -71,34 +72,42 @@ class wxPythonDemo(wxFrame): # Make a File menu self.mainmenu = wxMenuBar() menu = wxMenu() - mID = NewId() + mID = wxNewId() menu.Append(mID, 'E&xit', 'Get the heck outta here!') EVT_MENU(self, mID, self.OnFileExit) self.mainmenu.Append(menu, '&File') + # Make a Demo menu + menu = wxMenu() + for item in _treeList: + submenu = wxMenu() + for childItem in item[1]: + mID = wxNewId() + submenu.Append(mID, childItem) + EVT_MENU(self, mID, self.OnDemoMenu) + menu.AppendMenu(wxNewId(), item[0], submenu) + self.mainmenu.Append(menu, '&Demo') + + # Make a Help menu - mID = NewId() + mID = wxNewId() menu = wxMenu() menu.Append(mID, '&About', 'wxPython RULES!!!') EVT_MENU(self, mID, self.OnHelpAbout) self.mainmenu.Append(menu, '&Help') self.SetMenuBar(self.mainmenu) - selectedDemo = None - selectedDemoName = "Nada" - if len(sys.argv) == 2: - selectedDemoName = sys.argv[1] # Create a TreeCtrl - tID = NewId() + tID = wxNewId() + self.treeMap = {} self.tree = wxTreeCtrl(splitter, tID) root = self.tree.AddRoot("Overview") for item in _treeList: child = self.tree.AppendItem(root, item[0]) for childItem in item[1]: theDemo = self.tree.AppendItem(child, childItem) - if childItem == selectedDemoName: - selectedDemo = theDemo + self.treeMap[childItem] = theDemo self.tree.Expand(root) EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded) @@ -142,9 +151,16 @@ class wxPythonDemo(wxFrame): # select initial items self.nb.SetSelection(0) self.tree.SelectItem(root) - if selectedDemo: - self.tree.SelectItem(selectedDemo) - self.tree.EnsureVisible(selectedDemo) + + if len(sys.argv) == 2: + try: + selectedDemo = self.treeMap[sys.argv[1]] + except: + selectedDemo = None + if selectedDemo: + self.tree.SelectItem(selectedDemo) + self.tree.EnsureVisible(selectedDemo) + #--------------------------------------------- def WriteText(self, text): @@ -242,13 +258,14 @@ class wxPythonDemo(wxFrame): def OnHelpAbout(self, event): - about = wxMessageDialog(self, - "wxPython is a Python extension module that\n" - "encapsulates the wxWindows GUI classes.\n\n" - "This demo shows off some of the capabilities\n" - "of wxPython.\n\n" - " Developed by Robin Dunn", - "About wxPython", wxOK) + #about = wxMessageDialog(self, + # "wxPython is a Python extension module that\n" + # "encapsulates the wxWindows GUI classes.\n\n" + # "This demo shows off some of the capabilities\n" + # "of wxPython.\n\n" + # " Developed by Robin Dunn", + # "About wxPython", wxOK) + about = MyAboutBox(self) about.ShowModal() about.Destroy() @@ -266,6 +283,56 @@ class wxPythonDemo(wxFrame): self.window = self.otherWin self.otherWin = None + #--------------------------------------------- + def OnDemoMenu(self, event): + print event.GetId(), self.mainmenu.GetLabel(event.GetId()) + try: + selectedDemo = self.treeMap[self.mainmenu.GetLabel(event.GetId())] + except: + selectedDemo = None + if selectedDemo: + self.tree.SelectItem(selectedDemo) + self.tree.EnsureVisible(selectedDemo) + + + +#--------------------------------------------------------------------------- +#--------------------------------------------------------------------------- + +class MyAboutBox(wxDialog): + text = ''' + +
+wxPython %s |
+
wxPython is a Python extension module that +encapsulates the wxWindows GUI classes.
+ +This demo shows off some of the capabilities +of wxPython. Select items from the menu or tree control, +sit back and enjoy. Be sure to take a peek at the source code for each +demo item so you can learn how to use the classes yourself.
+ +wxPython is brought to you by Robin Dunn and
+Total Control Software, copyright 1999.
Please see license.txt for licensing information.
+Top left
+ (two lines expression) + paragraph done |
+
+Top right | +
Bottom left | + +Bottom right | +
Subsampling is shown there:
+
+
+
|
+
+2 | +||||
3 dflkj lkjfl dkjldkfjl flk jflkf lkjflkj ljlf ajlfj alff h khg hgj +gjg jg gjhfg fg gjh gjf jgf jgj f gjfgj kfajg | + +4
+ gh + gfh + gh + hg + 5 |
+
This is "default" table - with no sizes givev:
+
+
Hello | + +lkfdsjlk fj dlfj lkfj lkjflk jlfk lk fjlk elwkf lkejflek f jlekjflkj +ljlk lk jlkf lefjl j flkj ljl lf lfj lfjl lj lwe lekf;eh kfejh lkh kjh +kjhkj hkj hkj lkh kjh kjlh kj | + +shortebn formo lr lk | + +djsf lkjlf poer oi pjr po kpk | +
a | + +b | + +c | + +d | +
1 | + +2 | + +3 | +|
A | + +B | +
+click here to go to IMAGEMAPs test page! + +
+This is - - default text, now switching to +
center, now still ctr, now exiting
Hello, this *is* default charset (helvetica, probably) and it is displayed +with one COLOR CHANGE. Of course we +can have as many color changes as we can, what about this MADNESS? +
There was a space above.
+
+
+
Right now, centered REALLY Big Text, +how do you like (space) it?
Blue italic text is displayed there.... +
and
+this is text......
+
(try clicking on the image :-) and
+this is text......
+
+
+
And yes, we're in HTML DOCUMENT +
hello?
+
+
+
This is new par? +
We switched to BOLD +
This is new paragraph Bold is off now. +
new par +
----------- +
Hello +
(blockquote)two two two two two two twotwo +TWO two two two two two two twotwo TWO two two two two two two twotwo TWO ++two two two two two two twotwo TWO two two two two two two +twotwo TWO +two two two two two two twotwo TWO two two two+two two two twotwo TWO two two two two two two twotwo TWO +two two two two two two twotwo TWO
two two two two two two twotwo TWO two two two two
+two two twotwo TWO two two two two two two twotwo TWO two two two two two
+two twotwo TWO
+
two two two two two two twotwo TWO two two two two two +two twotwo TWO two two two two two two twotwo TWO two two two two two two +twotwo TWO +
+
// This is sample C++ code: + +void main(int argc, char *argv[]) +{ + printf("Go away, man!\n"); + i = 666; + printf("\n\n\nCRASH\n DOWN NOW. . . \n"); +}+ + + + + diff --git a/utils/wxPython/demo/wxHtmlWindow.py b/utils/wxPython/demo/wxHtmlWindow.py new file mode 100644 index 0000000000..07ec21a554 --- /dev/null +++ b/utils/wxPython/demo/wxHtmlWindow.py @@ -0,0 +1,106 @@ + +from wxPython.wx import * +from wxPython.html import * +from wxPython.lib.sizers import * + +#---------------------------------------------------------------------- + +# This shows how to catch the OnLinkClicked non-event. (It's a virtual +# method in the C++ code...) +class MyHtmlWindow(wxHtmlWindow): + def __init__(self, parent, id, log): + wxHtmlWindow.__init__(self, parent, id) + self.log = log + + def OnLinkClicked(self, link): + self.log.WriteText('OnLinkClicked: %s\n' % link) + + # Virtuals in the base class have been renamed with base_ on the font. + self.base_OnLinkClicked(link) + + + +class TestHtmlPanel(wxPanel): + def __init__(self, parent, frame, log): + wxPanel.__init__(self, parent, -1) + self.log = log + self.frame = frame + + + self.html = MyHtmlWindow(self, -1, log) + self.html.SetRelatedFrame(frame, "wxPython: (A Demonstration) -- %s") + self.html.SetRelatedStatusBar(0) + + self.box = box.wxBoxSizer(wxVERTICAL) + self.box.Add(self.html, 1) + + subbox = wxBoxSizer(wxHORIZONTAL) + btn = wxButton(self, 1201, "Show Default") + EVT_BUTTON(self, 1201, self.OnShowDefault) + subbox.Add(btn, 1) + + btn = wxButton(self, 1202, "Load File") + EVT_BUTTON(self, 1202, self.OnLoadFile) + subbox.Add(btn, 1) + + btn = wxButton(self, 1203, "With Widgets") + EVT_BUTTON(self, 1203, self.OnWithWidgets) + subbox.Add(btn, 1) + + btn = wxButton(self, 1204, "Back") + EVT_BUTTON(self, 1204, self.OnBack) + subbox.Add(btn, 1) + + btn = wxButton(self, 1205, "Forward") + EVT_BUTTON(self, 1205, self.OnForward) + subbox.Add(btn, 1) + + self.box.Add(subbox) + self.OnShowDefault(None) + + + def OnSize(self, event): + size = self.GetClientSize() + self.box.Layout(size) + + + def OnShowDefault(self, event): + self.html.LoadPage("data/test.htm") + + + def OnLoadFile(self, event): + pass + + + def OnWithWidgets(self, event): + pass + + def OnBack(self, event): + if not self.html.HistoryBack(): + wxMessageBox("No more items in history!") + + def OnForward(self, event): + if not self.html.HistoryForward(): + wxMessageBox("No more items in history!") + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestHtmlPanel(nb, frame, log) + return win + + +#---------------------------------------------------------------------- + + + + + +overview = """\ +wxHtmlWindow is capable of parsing and rendering most simple HTML tags. + +It is not intended to be a high-end HTML browser. If you're looking for something like that try http://www.mozilla.org - there's a chance you'll be able to make their widget wxWindows-compatible. I'm sure everyone will enjoy your work in that case... + +""" +