From: Robin Dunn Date: Mon, 13 Sep 1999 19:31:50 +0000 (+0000) Subject: The beginings of wxHtmlWindow support in the wxPython demo X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ec3e670f9f9942d5de4c543edfbc87fc3e0cd797 The beginings of wxHtmlWindow support in the wxPython demo git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3654 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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.

+
+ + +''' + def __init__(self, parent): + from wxPython.html import * + wxDialog.__init__(self, parent, -1, 'About wxPython') + self.html = wxHtmlWindow(self, -1, wxPoint(5,5), wxSize(400, 350)) + self.html.SetPage(self.text % wx.__version__) + wxButton(self, wxID_OK, 'OK', wxPoint(5, 365)).SetDefault() + self.Fit() + #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- diff --git a/utils/wxPython/demo/data/imagemap.htm b/utils/wxPython/demo/data/imagemap.htm new file mode 100644 index 0000000000..edebd33b82 --- /dev/null +++ b/utils/wxPython/demo/data/imagemap.htm @@ -0,0 +1,20 @@ + + +ImageMap Test + + + + +This is test. + + + + + + + + + + + + diff --git a/utils/wxPython/demo/data/imagemap.png b/utils/wxPython/demo/data/imagemap.png new file mode 100644 index 0000000000..2307eaed4e Binary files /dev/null and b/utils/wxPython/demo/data/imagemap.png differ diff --git a/utils/wxPython/demo/data/pic.png b/utils/wxPython/demo/data/pic.png new file mode 100644 index 0000000000..fcc18c1296 Binary files /dev/null and b/utils/wxPython/demo/data/pic.png differ diff --git a/utils/wxPython/demo/data/pic2.bmp b/utils/wxPython/demo/data/pic2.bmp new file mode 100644 index 0000000000..e79b526fc3 Binary files /dev/null and b/utils/wxPython/demo/data/pic2.bmp differ diff --git a/utils/wxPython/demo/data/tables.htm b/utils/wxPython/demo/data/tables.htm new file mode 100644 index 0000000000..b27eb5e3f5 --- /dev/null +++ b/utils/wxPython/demo/data/tables.htm @@ -0,0 +1,116 @@ + + + + + + + + +

+This is TABLES +tests page...

+ + +(yes, really, see bellow:) +
Click here to go to original testing page... +
Click here to go to manuals... +
  +
+ + + + + + + + + + + +
Top left +
(two lines expression) +

paragraph done

Top right
Bottom leftBottom right
+ +

Subsampling is shown there: +
  + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
ab
cd
+
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: +
  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Hellolkfdsjlk 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 kjshortebn formo lr lkdjsf lkjlf poer oi pjr po kpk 
abcd
123
AB
+ + + + + + + diff --git a/utils/wxPython/demo/data/test.htm b/utils/wxPython/demo/data/test.htm new file mode 100644 index 0000000000..e860212a79 --- /dev/null +++ b/utils/wxPython/demo/data/test.htm @@ -0,0 +1,248 @@ + + + + + +wxHTML Test + + + +click here to go to tables test page! +

+click here to go to IMAGEMAPs test page! + +

+This is - - default text, now switching to +

+

center, now still ctr, now exiting

+exited!.[link to down] +

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. +
+


This was a line. (BTW we are in fixed font +/ typewriter font right now :-) +
This is in BOLD face. This is ITALIC. This is E +V E R Y T H I N G. +
  +


+

+

Right now, centered REALLY Big Text, +how do you like (space) it?

+ +
RIGHT: text-2, text-1, +text+0, +text+1, +text+2, +text+3, +text+4 +
we are right now
+ +
we are center now
+we are left now. +

Blue italic text is displayed there.... +

+ +
This is heading one.

+this is normal +
+

+This is CENTERED heading one

+Yes, hmmmmmmmmm........, right now, we should +display some tiny nice image, he? +
Testing image imageand this is text...... +

Testing image imageand +this is text...... +
Testing image image (try clicking on the image :-) and +this is text...... +
  +
  +

+ +
    +
  1. +item one
  2. + +
  3. +item two
  4. + +
      +
    1. +nsted item
    2. +
    + +
  5. +last numbered item
  6. +
+ +

+Heading 1

+Italic text now... +

+Heading 2

+and now? +

+Heading 3

+ +

+Heading 4

+ +
+Heading 5
+ +
+Heading 6
+And this is normal text, once again :-) +
  +
  +
  +
  +
  +
  +

And yes, we're in HTML DOCUMENT +

hello? +
  +


+

+

This is centered paragraph

+ +

This is new par? +

We switched to BOLD +

This is new paragraph Bold is off now. +

new par +

  ----------- +

Hello +

    this is standalone :-) +
  1. +This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf +jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl +fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga +kjegiquw iuqdb qiud iquwd hurray googoo.
  2. + +
  3. +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
  4. + +
    (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 +
  5. +This is item nyumber 3.
  6. + +
  7. +This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf +jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl +fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga +kjegiquw iuqdb qiud iquwd hurray googoo.
  8. + +
  9. +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
  10. + +
  11. +This is item nyumber 3.
  12. + +
  13. +This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf +jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl +fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga +kjegiquw iuqdb qiud iquwd hurray googoo.
  14. + +
  15. +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
  16. + +
  17. +This is item nyumber 3.
  18. + +
  19. +This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf +jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl +fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga +kjegiquw iuqdb qiud iquwd hurray googoo.
  20. + +
  21. +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
  22. + +
  23. +This is item nyumber 3.
  24. + +
  25. +This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf +jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl +fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga +kjegiquw iuqdb qiud iquwd hurray googoo.
  26. + +
  27. +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
  28. + +


    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 +

  29. +This is item nyumber 3.
  30. +
+Now, you will see some PRE text:

+

// 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... + +""" +