1) Update documentation generator for `InfoBar`, `ListCtrl` and new additions;
2) Correct the `writeIfChanged` method, we can't use `str(text)` if the wxWidgets docs contain non-ascii compliant docstrings. Just treat them as unicode objects and use `codecs.open` to compare existing files with new docstrings;
3) Add empty stubs for the `ListCtrl Overview` and `Internationalization`, hopefully someone will populate them...
4) Small fix to the `MigrationGuide.txt`.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71031 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Andrea Gavana
2012-03-27 20:54:15 +00:00
parent 1d54d41e7b
commit 003fb0a804
19 changed files with 337 additions and 7 deletions

View File

@@ -18,12 +18,15 @@ import fnmatch
import tempfile
import commands
import shutil
import codecs
from distutils.file_util import copy_file
from distutils.dir_util import mkpath
from distutils.dep_util import newer
from distutils.spawn import spawn
reload(sys)
sys.setdefaultencoding('utf-8')
runSilently = False
@@ -626,11 +629,15 @@ def writeIfChanged(filename, text):
the content is different (therefore preserving the timestamp if there is
no update.)
"""
text = str(text)
if os.path.exists(filename):
current = open(filename, 'rt').read()
fid = codecs.open(filename, 'r', 'utf-8')
current = fid.read()
fid.close()
if current == text:
return
f = open(filename, 'wt')
f.write(text)
f = codecs.open(filename, 'w', 'utf-8')
f.write(text.encode('utf-8'))
f.close()

View File

@@ -232,7 +232,7 @@ your application when you use py2exe or other executable builder.
wx.ListCtrl
-----------
* In wx.ListItem and wx.ListEvent the "m_" properties are no longer
* In wx.ListItem and wx.ListEvent the ``"m_"`` properties are no longer
public. Instead use the associated getter/setter methods or the
auto-generated properties that are using them.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,213 @@
/*
* sidebar.js
* ~~~~~~~~~~
*
* This script makes the Sphinx sidebar collapsible and moveable.
*
* .sphinxsidebar contains .sphinxsidebarwrapper. The script adds
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
* used to collapse, expand and move the sidebar.
*
* The script saves per-browser/per-session cookies used to remember
* the collapsed state and position of the sidebar among the pages.
* Once the browser is closed the cookies are deleted and the position
* reset to the default set in the style sheed.
*
* Modifications and improvements made 2010 by Christoph Zwerschke.
*
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
$(function() {
var body = $('div.document');
var body_width = body.width();
var footer = $('div.footer');
var sidebar = $('div.sphinxsidebar');
var sidebarwrapper = $('div.sphinxsidebarwrapper');
var sidebarbutton = $('<div id="sidebarbutton"><div></div></div>');
var sbw_width = sidebar.width();
var sbb_width = 9;
var dark_color = $('div.related').css('background-color');
var light_color = sidebarwrapper.css('color');
var opacity_factor = $.browser.msie ? 1 : 0.75;
var collapsed = sidebarwrapper.is(':not(:visible)');
var rightside = sidebar.css('right') == '0px';
var dragging = null;
function set_sidebar() {
var width = collapsed ? 0 : sbw_width;
if (rightside) {
sidebar.css({
'width': width,
'left': 'auto',
'right': 0
});
sidebarbutton.css({
'right': collapsed ? 0 : width,
'left': 'auto'
});
body.add(footer).css({
'margin-right': width + sbb_width,
'margin-left': 0
});
} else {
sidebar.css({
'width': width,
'right': 'auto',
'left': '0'
});
sidebarbutton.css({
'left': collapsed ? 0 : width,
'right': 'auto'
});
body.add(footer).css({
'margin-left': width + sbb_width,
'margin-right': 0
});
}
sidebarbutton.find('div').text(rightside == collapsed ? '«' : '»');
}
function toggle_sidebar() {
collapsed ? expand_sidebar() : collapse_sidebar();
}
function collapse_sidebar() {
collapsed = true;
sidebarwrapper.hide();
set_sidebar();
sidebarbutton.attr('title', _('Expand sidebar'));
document.cookie = 'sidebar_collapsed=1';
}
function expand_sidebar() {
collapsed = false;
sidebarwrapper.show();
set_sidebar();
sidebarbutton.attr('title', _('Collapse sidebar'));
document.cookie = 'sidebar_collapsed=0';
}
function add_sidebar_button() {
sidebar.css('width', (collapsed ? 0 : sbw_width) + sbb_width);
sidebarbutton.attr('title', _('Collapse sidebar'));
sidebarbutton.css({
'color': light_color,
'font-size': 14,
'text-align': 'center',
'border-left': '1px solid ' + dark_color,
'border-right': '1px solid ' + dark_color,
'padding': '1px 0',
'margin': '0',
'width': sbb_width - 2,
'cursor': 'pointer',
'position': 'fixed',
'left': collapsed ? 0 : sbw_width,
'top': sidebar.css('top'),
'bottom': 0
});
sidebarbutton.find('div').css({
'position': 'relative',
'top': '50%',
'margin-top': -8
});
set_sidebar();
sidebarbutton.hover(
function() {
sidebarbutton.css('background-color', dark_color);
},
function() {
sidebarbutton.css('background-color', light_color);
}
);
sidebarbutton.mousedown(
function(e) {
if (dragging != null || e.which != 1) return;
dragging = {
'dragged': false,
'pageX': e.pageX
};
sidebarbutton.css('cursor', 'move');
}
);
sidebar.add(body).mouseup(
function(e) {
if (dragging == null)
return;
e.preventDefault();
if (dragging.dragged) {
var left = sidebar.offset().left;
if (rightside)
left = body_width - left;
if (left < 0 && !collapsed)
collapse_sidebar();
else if (left < body_width / 2 &&
left < sbw_width + 2 * sbw_width && collapsed)
expand_sidebar();
else {
if (left > body_width / 2)
rightside = !rightside;
set_sidebar();
}
if (opacity_factor != 1)
sidebar.css('opacity', dragging.opacity);
document.cookie = 'sidebar_rightside=' + (rightside ? '1' : '0');
} else
toggle_sidebar();
sidebarbutton.css('cursor', 'pointer');
dragging = null;
e.stopPropagation();
}
);
sidebar.add(body).mousemove(
function(e) {
if (dragging == null)
return;
e.preventDefault();
var pageX = e.pageX;
side = 'left';
sidebarbutton.css('left', pageX);
if (rightside)
pageX += sbb_width;
else
pageX -= sbw_width;
sidebar.css('left', pageX);
if (!dragging.dragged) {
dragging.dragged = true;
if (collapsed) {
sidebar.css('width', sbw_width);
sidebarwrapper.show();
}
if (opacity_factor != 1) {
dragging.opacity = sidebar.css('opacity');
sidebar.css('opacity', opacity_factor * dragging.opacity);
}
}
e.stopPropagation();
}
);
sidebar.append(sidebarbutton);
light_color = sidebarbutton.css('background-color');
}
function set_position_from_cookie() {
if (!document.cookie)
return;
var items = document.cookie.split(';');
for (var k = 0; k < items.length; k++) {
var key_val = items[k].split('=');
var key = $.trim(key_val[0]);
var val = $.trim(key_val[1]);
if (key == 'sidebar_collapsed')
collapsed = val == '1';
else if (key == 'sidebar_rightside')
rightside = val == '1';
}
}
set_position_from_cookie();
if (sidebar.length)
add_sidebar_button();
});

View File

@@ -0,0 +1,14 @@
.. include:: headings.inc
.. _internationalization:
==================================================
|phoenix_title| **Internationalization Overview**
==================================================
.. todo:: Write this section.

View File

@@ -0,0 +1,14 @@
.. include:: headings.inc
.. _listctrl overview:
===============================================
|phoenix_title| **ListCtrl Overview**
===============================================
.. todo:: Write this section.

View File

@@ -0,0 +1,13 @@
def OnAbout(self, event):
aboutInfo = wx.AboutDialogInfo()
aboutInfo.SetName("MyApp")
aboutInfo.SetVersion(MY_APP_VERSION_STRING)
aboutInfo.SetDescription(_("My wxPython-based application!"))
aboutInfo.SetCopyright("(C) 1992-2012")
aboutInfo.SetWebSite("http:#myapp.org")
aboutInfo.AddDeveloper("My Self")
wx.AboutBox(aboutInfo)

View File

@@ -0,0 +1,20 @@
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, title='InfoBar!')
self.infoBar = wx.InfoBar(self)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.infoBar, wx.SizerFlags().Expand())
# ... add other frame controls to the sizer ...
self.SetSizer(sizer)
def SomeMethod(self):
self.infoBar.ShowMessage("Something happened", wx.ICON_INFORMATION)

View File

@@ -0,0 +1,13 @@
item = -1
while 1:
item = listctrl.GetNextItem(item,
wx.LIST_NEXT_ALL,
wx.LIST_STATE_SELECTED)
if item == -1:
break
# This item is selected - do whatever is needed with it
wx.LogMessage("Item %ld is selected"%item)

View File

@@ -0,0 +1,13 @@
listCtrl = wx.ListCtrl(parent, style=wx.LC_REPORT)
for i in range(3):
listCtrl.InsertColumn(i, "Column %d"%i)
order = [2, 0, 1]
listCtrl.SetColumnsOrder(order)
# now listCtrl.GetColumnsOrder() will return order and
# listCtrl.GetColumnIndexFromOrder(n) will return order[n] and
# listCtrl.GetColumnOrder() will return 1, 2 and 0 for the column 0,
# 1 and 2 respectively

View File

@@ -0,0 +1,2 @@
listCtrl.SetItemState(item, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)

View File

@@ -0,0 +1,2 @@
listCtrl.SetItemState(item, 0, wx.LIST_STATE_SELECTED)

View File

@@ -0,0 +1,6 @@
def ListCompareFunction(self, item1, item2):
pass

View File

@@ -0,0 +1,11 @@
def ShowSimpleAboutDialog(self, event):
info = wx.AboutDialogInfo()
info.SetName(_("My Program"))
info.SetVersion(_("1.2.3 Beta"))
info.SetDescription(_("This program does something great."))
info.SetCopyright(wx.T("(C) 2007 Me <my@email.addre.ss>"))
wx.AboutBox(info)

View File

@@ -68,7 +68,8 @@ REMOVED_LINKS = ['Library:', 'Category:', 'Predefined objects/pointers:']
# This needs to be kept up to date when other stuff comes in (i.e., wx.grid,
# wx.html and so on)
MODULENAME_REPLACE = {'_core' : '',
'_dataview': 'dataview.'
'_dataview': 'dataview.',
'_adv' : '',
}
# Other C++ specific things to strip away
@@ -143,7 +144,7 @@ HTML_REPLACE = ['module', 'function', 'method', 'class', 'classmethod', 'staticm
# The SVN revision of wxWidgets/Phoenix used to build the Sphinx docs.
# There must be a more intelligent way to get this information automatically.
SVN_REVISION = '70741'
SVN_REVISION = '71022'
# Today's date representation for the Sphinx HTML docs
TODAY = datetime.date.today().strftime('%d %B %Y')

View File

@@ -144,6 +144,7 @@ def BuildEnumsAndMethods(sphinxDir):
text = text.replace(',,', ',').replace(', ,', ',')
text = text.replace(':note:', '.. note::')
text = text.replace(':see:', '.. seealso::')
text = text.replace('`String`&', 'string')
if text != orig_text:
fid = open(input, 'wt')