Added a typemap that converts strings to wxColour objects either using
the colour name or a string of the format #RRGGBB Started the wxStyledTextCtrl Python demos Other assorted tweaks and fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7214 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,4 +1,16 @@
|
||||
"""
|
||||
<html><body>
|
||||
This demo shows how to embed an ActiveX control in a wxPython application, (Win32 only.)
|
||||
<p>
|
||||
The MakeActiveXClass function dynamically builds a new Class on the fly, that has the
|
||||
same signature and semantics as wxWindow. This means that when you call the function
|
||||
you get back a new class that you can use just like wxWindow, (set the size and position,
|
||||
use in a sizer, etc.) except its contents will be the COM control.
|
||||
<p>
|
||||
This demo embeds the Adobe Acrobat Reader, and gives you some buttons for opening a PDF
|
||||
file, changing pages, etc. that show how to call methods on the COM object. If you don't
|
||||
have Acrobat Reader 4.0 installed it won't work.
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
|
@@ -1,4 +1,16 @@
|
||||
"""
|
||||
<html><body>
|
||||
This demo shows how to embed an ActiveX control in a wxPython application, (Win32 only.)
|
||||
<p>
|
||||
The MakeActiveXClass function dynamically builds a new Class on the fly, that has the
|
||||
same signature and semantics as wxWindow. This means that when you call the function
|
||||
you get back a new class that you can use just like wxWindow, (set the size and position,
|
||||
use in a sizer, etc.) except its contents will be the COM control.
|
||||
<p>
|
||||
This demo embeds the Internet Exploer WebBrowser control, and shows how to receive events
|
||||
from the COM control. (The title bar and status bar are updated as pages change, in addition
|
||||
to the log messages being shown.)
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
@@ -38,8 +50,12 @@ class TestPanel(wxWindow):
|
||||
self.ie = theClass(self, -1, style=wxSUNKEN_BORDER)
|
||||
|
||||
|
||||
btn = wxButton(self, wxNewId(), " Open ")
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
|
||||
#btn = wxButton(self, wxNewId(), " Open ")
|
||||
#EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
|
||||
#btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxNewId(), " Home ")
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnHomeButton)
|
||||
btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxNewId(), " <-- ")
|
||||
@@ -104,6 +120,8 @@ class TestPanel(wxWindow):
|
||||
self.ie.Navigate(self.current)
|
||||
dlg.Destroy()
|
||||
|
||||
def OnHomeButton(self, event):
|
||||
self.ie.GoHome() ## ET Phone Home!
|
||||
|
||||
def OnPrevPageButton(self, event):
|
||||
self.ie.GoBack()
|
||||
|
@@ -14,6 +14,7 @@
|
||||
import sys, os
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.splashscreen import SplashScreen
|
||||
from wxPython.html import wxHtmlWindow
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -21,7 +22,7 @@ _useSplitter = true
|
||||
_useNestedSplitter = true
|
||||
|
||||
_treeList = [
|
||||
('New since last release', ['wxGrid', 'wxStyledTextCtrl',
|
||||
('New since last release', ['wxGrid', 'wxStyledTextCtrl_1',
|
||||
'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE',
|
||||
'FileBrowseButton', 'wxCalendar']),
|
||||
|
||||
@@ -157,12 +158,13 @@ class wxPythonDemo(wxFrame):
|
||||
EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
||||
EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wxNotebook(nbParent, -1)
|
||||
|
||||
# Set up a TextCtrl on the Overview Notebook page
|
||||
self.ovr = wxTextCtrl(self.nb, -1, style = wxTE_MULTILINE|wxTE_READONLY)
|
||||
self.ovr = wxHtmlWindow(self.nb, -1)
|
||||
self.nb.AddPage(self.ovr, "Overview")
|
||||
|
||||
|
||||
@@ -241,6 +243,16 @@ class wxPythonDemo(wxFrame):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnTreeLeftDown(self, event):
|
||||
pt = event.GetPosition();
|
||||
item, flags = self.tree.HitTest(pt)
|
||||
if item == self.tree.GetSelection():
|
||||
self.SetOverview(self.tree.GetItemText(item), self.curOverview)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnSelChanged(self, event):
|
||||
if self.dying:
|
||||
@@ -284,7 +296,7 @@ class wxPythonDemo(wxFrame):
|
||||
self.nb.SetSelection(2)
|
||||
|
||||
else:
|
||||
self.ovr.Clear()
|
||||
self.ovr.SetPage("")
|
||||
self.txt.Clear()
|
||||
self.window = None
|
||||
|
||||
@@ -307,11 +319,13 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
#---------------------------------------------
|
||||
def SetOverview(self, name, text):
|
||||
self.ovr.Clear()
|
||||
self.ovr.WriteText(text)
|
||||
self.curOverview = text
|
||||
lead = text[:6]
|
||||
if lead != '<html>' and lead != '<HTML':
|
||||
text = string.join(string.split(text, '\n'), '<br>')
|
||||
#text = '<font size="-1"><pre>' + text + '</pre></font>'
|
||||
self.ovr.SetPage(text)
|
||||
self.nb.SetPageText(0, name)
|
||||
self.ovr.SetInsertionPoint(0)
|
||||
self.ovr.ShowPosition(0)
|
||||
|
||||
#---------------------------------------------
|
||||
# Menu methods
|
||||
@@ -399,29 +413,27 @@ def main():
|
||||
|
||||
|
||||
overview = """\
|
||||
Python
|
||||
------------
|
||||
<html><body>
|
||||
<h2>Python</h2>
|
||||
|
||||
Python is an interpreted, interactive, object-oriented programming language often compared to Tcl, Perl, Scheme, or Java.
|
||||
|
||||
<p>
|
||||
Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, and new built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface.
|
||||
|
||||
wxWindows
|
||||
--------------------
|
||||
<p>
|
||||
<h2>wxWindows</h2>
|
||||
|
||||
wxWindows is a free C++ framework designed to make cross-platform programming child's play. Well, almost. wxWindows 2 supports Windows 3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version underway. Other ports are under consideration.
|
||||
|
||||
<p>
|
||||
wxWindows is a set of libraries that allows C++ applications to compile and run on several different types of computers, with minimal source code changes. There is one library per supported GUI (such as Motif, or Windows). As well as providing a common API (Application Programming Interface) for GUI functionality, it provides functionality for accessing some commonly-used operating system facilities, such as copying or deleting files. wxWindows is a 'framework' in the sense that it provides a lot of built-in functionality, which the application can use or replace as required, thus saving a great deal of coding effort. Basic data structures such as strings, linked lists and hash tables are also supported.
|
||||
|
||||
wxPython
|
||||
----------------
|
||||
<p>
|
||||
<h2>wxPython</h2>
|
||||
|
||||
wxPython is a Python extension module that encapsulates the wxWindows GUI classes. Currently it is only available for the Win32 and GTK ports of wxWindows, but as soon as the other ports are brought up to the same level as Win32 and GTK, it should be fairly trivial to enable wxPython to be used with the new GUI.
|
||||
|
||||
<p>
|
||||
The wxPython extension module attempts to mirror the class heiarchy of wxWindows as closely as possible. This means that there is a wxFrame class in wxPython that looks, smells, tastes and acts almost the same as the wxFrame class in the C++ version. Unfortunately, because of differences in the languages, wxPython doesn't match wxWindows exactly, but the differences should be easy to absorb because they are natural to Python. For example, some methods that return multiple values via argument pointers in C++ will return a tuple of values in Python.
|
||||
|
||||
<p>
|
||||
There is still much to be done for wxPython, many classes still need to be mirrored. Also, wxWindows is still somewhat of a moving target so it is a bit of an effort just keeping wxPython up to date. On the other hand, there are enough of the core classes completed that useful applications can be written.
|
||||
|
||||
<p>
|
||||
wxPython is close enough to the C++ version that the majority of the wxPython documentation is actually just notes attached to the C++ documents that describe the places where wxPython is different. There is also a series of sample programs included, and a series of documentation pages that assist the programmer in getting started with wxPython.
|
||||
"""
|
||||
|
||||
|
@@ -715,6 +715,7 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
This control provides a calendar control class for displaying and selecting dates. In addition, the class is extended and can now be used for printing/previewing.
|
||||
|
||||
Additional features include weekend highlighting and business type Monday-Sunday format.
|
||||
|
||||
See example for various methods used to set display month, year, and highlighted dates (different font and background colours).
|
||||
|
@@ -55,5 +55,32 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
overview = """\
|
||||
This demo shows various ways of using the ** NEW ** wxGrid. For more details see wxPython/demo/Grid*.py.
|
||||
<html><body>
|
||||
<h2>wxGrid</h2>
|
||||
|
||||
This demo shows various ways of using the <b><i>new and improved</i></b> wxGrid class.
|
||||
Unfortunatly it has not been documented yet, and while it is somewhat backwards compatible,
|
||||
if you try to go by the current wxGrid documentation you will probably just confuse yourself.
|
||||
<p>
|
||||
You can look at the sources for these samples to learn a lot about how the new classes work.
|
||||
<p><ol>
|
||||
<li><a href="GridSimple.py">GridSimple.py</a> A simple grid that shows how to catch all the
|
||||
various events.
|
||||
<p>
|
||||
<li><a href="GridStdEdRend.py">GridStdEdRend.py</a> A grid that uses non-default Cell Editors
|
||||
and Cell Renderers.
|
||||
<p>
|
||||
<li><a href="GridHugeTable.py">GridHugeTable.py</a> A grid that uses a non-default Grid Table.
|
||||
This table is read-only and simply generates on the fly a unique string for each cell.
|
||||
<p>
|
||||
<li><a href="GridCustTable.py">GridCustTable.py</a> This grid shows how to deal with tables
|
||||
that have non-string data, and how Cell Editors and Cell Renderers are automatically chosen
|
||||
based on the data type.
|
||||
<p>
|
||||
</ol>
|
||||
<p>
|
||||
You can also look at the <a href="data/grid.i">SWIG interface file</a> used to generate
|
||||
the grid module for a lot more clues as to how things work.
|
||||
|
||||
"""
|
||||
|
||||
|
81
utils/wxPython/demo/wxStyledTextCtrl_1.py
Normal file
81
utils/wxPython/demo/wxStyledTextCtrl_1.py
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.stc import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
demoText = """\
|
||||
|
||||
This editor is provided by a class named wxStyledTextCtrl. As
|
||||
the name suggests, you can define styles that can be applied to
|
||||
sections of text. This will typically be used for things like
|
||||
syntax highlighting code editors, but I'm sure that there are other
|
||||
applications as well. A style is a combination of font, point size,
|
||||
forground and background colours. The editor can handle
|
||||
proportional fonts just as easily as monospaced fonts, and various
|
||||
styles can use different sized fonts.
|
||||
|
||||
There are a few canned language lexers and colourizers included,
|
||||
(see the next demo) or you can handle the colourization yourself.
|
||||
If you do you can simply register an event handler and the editor
|
||||
will let you know when the visible portion of the text needs
|
||||
styling.
|
||||
|
||||
wxStyledTextEditor also supports setting markers in the margin...
|
||||
|
||||
|
||||
|
||||
|
||||
...and indicators within the text. You can use these for whatever
|
||||
you want in your application. Drag and Drop of text works, as well
|
||||
as virtually unlimited Undo and Redo capabilities, (right click to
|
||||
try it out.)
|
||||
|
||||
"""
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
ed = wxStyledTextCtrl(nb, -1)
|
||||
|
||||
ed.SetText(demoText)
|
||||
|
||||
ed.SetMarginType(0, wxSTC_MARGIN_NUMBER)
|
||||
ed.SetMarginWidth(0, 22)
|
||||
ed.StyleSetSpec(wxSTC_STYLE_LINENUMBER, "size:6,face:Ariel")
|
||||
|
||||
ed.SetMarginType(1, wxSTC_MARGIN_SYMBOL)
|
||||
ed.MarkerDefine(0, wxSTC_MARK_ROUNDRECT, "#DD0FCC", "RED")
|
||||
ed.MarkerDefine(1, wxSTC_MARK_CIRCLE, "FOREST GREEN", "SIENNA")
|
||||
ed.MarkerDefine(2, wxSTC_MARK_SHORTARROW, "blue", "blue")
|
||||
ed.MarkerDefine(3, wxSTC_MARK_ARROW, "#00FF00", "#00FF00")
|
||||
|
||||
ed.MarkerAdd(17, 0)
|
||||
ed.MarkerAdd(18, 1)
|
||||
ed.MarkerAdd(19, 2)
|
||||
ed.MarkerAdd(20, 3)
|
||||
ed.MarkerAdd(20, 0)
|
||||
|
||||
|
||||
return ed
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
app = wxPySimpleApp()
|
||||
frame = wxFrame(None, -1, "Tester...", size=(640, 480))
|
||||
win = runTest(frame, frame, sys.stdout)
|
||||
frame.Show(true)
|
||||
app.MainLoop()
|
||||
|
||||
|
Reference in New Issue
Block a user