Added wxDateTime, wxTimeSpan, and wxDateSpan to wxPython.utils.
Added wxCalendarCtrl. Other tweaks and fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -22,7 +22,7 @@ _useSplitter = true
|
||||
_useNestedSplitter = true
|
||||
|
||||
_treeList = [
|
||||
('New since last release', ['wxDragImage',
|
||||
('New since last release', ['wxDragImage', 'wxCalendarCtrl',
|
||||
]),
|
||||
|
||||
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),
|
||||
@@ -51,6 +51,7 @@ _treeList = [
|
||||
'wxImage', 'wxMask', 'PrintFramework', 'wxOGL',
|
||||
'PythonEvents', 'Threads',
|
||||
'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE',
|
||||
'wxDragImage', 'wxCalendarCtrl',
|
||||
]),
|
||||
|
||||
('wxPython Library', ['Layoutf', 'wxScrolledMessageDialog',
|
||||
|
@@ -78,6 +78,9 @@ def main(argv):
|
||||
raise SystemExit
|
||||
|
||||
name = argv[1]
|
||||
if name[-3:] == '.py':
|
||||
name = name[:-3]
|
||||
print name
|
||||
module = __import__(name)
|
||||
|
||||
|
||||
|
40
wxPython/demo/wxCalendarCtrl.py
Normal file
40
wxPython/demo/wxCalendarCtrl.py
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.calendar import *
|
||||
from wxPython.utils import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, ID, log):
|
||||
wxPanel.__init__(self, parent, ID)
|
||||
self.log = log
|
||||
|
||||
cal = wxCalendarCtrl(self, 101, wxDateTime_Now(), pos = (25,50),
|
||||
style = wxCAL_SHOW_HOLIDAYS | wxCAL_SUNDAY_FIRST)
|
||||
|
||||
EVT_CALENDAR(self, 101, self.OnCalSelected)
|
||||
|
||||
|
||||
def OnCalSelected(self, evt):
|
||||
self.log.write('OnCalSelected: %s\n' % evt.GetDate())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, -1, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """\
|
||||
<html><body>
|
||||
<h2>wxCalendarCtrl</h2>
|
||||
|
||||
Yet <i>another</i> calendar control. This one is a wrapper around the C++
|
||||
version described in the docs. This one will probably be a bit more efficient
|
||||
than the one in wxPython.lib.calendar, but I like a few things about it better,
|
||||
so I think both will stay in wxPython.
|
||||
"""
|
@@ -4,9 +4,10 @@ from wxPython.wx import *
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN)
|
||||
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN|wxMULTIPLE)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
for path in dlg.GetPaths():
|
||||
log.WriteText('You selected: %s\n' % path)
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
@@ -98,9 +98,15 @@ def runTest(frame, nb, log):
|
||||
# and finally, an indicator or two
|
||||
ed.IndicatorSetStyle(0, wxSTC_INDIC_SQUIGGLE)
|
||||
ed.IndicatorSetColour(0, wxRED)
|
||||
ed.IndicatorSetStyle(1, wxSTC_INDIC_DIAGONAL)
|
||||
ed.IndicatorSetColour(1, wxBLUE)
|
||||
ed.IndicatorSetStyle(2, wxSTC_INDIC_STRIKE)
|
||||
ed.IndicatorSetColour(2, wxRED)
|
||||
|
||||
ed.StartStyling(836, wxSTC_INDICS_MASK)
|
||||
ed.SetStyleFor(10, wxSTC_INDIC0_MASK)
|
||||
ed.SetStyleFor(10, wxSTC_INDIC1_MASK)
|
||||
ed.SetStyleFor(10, wxSTC_INDIC2_MASK | wxSTC_INDIC1_MASK)
|
||||
|
||||
|
||||
return ed
|
||||
|
@@ -53,6 +53,8 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
self.SetEdgeMode(wxSTC_EDGE_BACKGROUND)
|
||||
self.SetEdgeColumn(78)
|
||||
|
||||
self.SetCaretForeground("red")
|
||||
|
||||
# Setup a margin to hold fold markers
|
||||
#self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER?
|
||||
self.SetMarginType(2, wxSTC_MARGIN_SYMBOL)
|
||||
@@ -74,49 +76,44 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
self.StyleClearAll()
|
||||
|
||||
# Global default styles for all languages
|
||||
# Default
|
||||
self.StyleSetSpec(32, "face:%(helv)s,size:%(size)d" % faces)
|
||||
# Line number
|
||||
self.StyleSetSpec(33, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces)
|
||||
# Brace highlight
|
||||
self.StyleSetSpec(34, "fore:#0000FF,bold")
|
||||
# Brace incomplete highlight
|
||||
self.StyleSetSpec(35, "fore:#FF0000,bold")
|
||||
# Control characters
|
||||
self.StyleSetSpec(36, "face:%(other)s" % faces)
|
||||
self.StyleSetSpec(wxSTC_STYLE_DEFAULT, "face:%(helv)s,size:%(size)d" % faces)
|
||||
self.StyleSetSpec(wxSTC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces)
|
||||
self.StyleSetSpec(wxSTC_STYLE_CONTROLCHAR, "face:%(other)s" % faces)
|
||||
self.StyleSetSpec(wxSTC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold")
|
||||
self.StyleSetSpec(wxSTC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold")
|
||||
|
||||
# Python styles
|
||||
# White space
|
||||
self.StyleSetSpec(0, "fore:#808080")
|
||||
self.StyleSetSpec(SCE_P_DEFAULT, "fore:#808080")
|
||||
# Comment
|
||||
self.StyleSetSpec(1, "fore:#007F00,face:%(other)s" % faces)
|
||||
self.StyleSetSpec(SCE_P_COMMENTLINE, "fore:#007F00,face:%(other)s" % faces)
|
||||
# Number
|
||||
self.StyleSetSpec(2, "fore:#007F7F")
|
||||
self.StyleSetSpec(SCE_P_NUMBER, "fore:#007F7F")
|
||||
# String
|
||||
self.StyleSetSpec(3, "fore:#7F007F,italic,face:%(times)s" % faces)
|
||||
self.StyleSetSpec(SCE_P_STRING, "fore:#7F007F,italic,face:%(times)s" % faces)
|
||||
# Single quoted string
|
||||
self.StyleSetSpec(4, "fore:#7F007F,italic,face:%(times)s" % faces)
|
||||
self.StyleSetSpec(SCE_P_CHARACTER, "fore:#7F007F,italic,face:%(times)s" % faces)
|
||||
# Keyword
|
||||
self.StyleSetSpec(5, "fore:#00007F,bold")
|
||||
self.StyleSetSpec(SCE_P_WORD, "fore:#00007F,bold")
|
||||
# Triple quotes
|
||||
self.StyleSetSpec(6, "fore:#7F0000")
|
||||
self.StyleSetSpec(SCE_P_TRIPLE, "fore:#7F0000")
|
||||
# Triple double quotes
|
||||
self.StyleSetSpec(7, "fore:#7F0000")
|
||||
self.StyleSetSpec(SCE_P_TRIPLEDOUBLE, "fore:#7F0000")
|
||||
# Class name definition
|
||||
self.StyleSetSpec(8, "fore:#0000FF,bold")
|
||||
self.StyleSetSpec(SCE_P_CLASSNAME, "fore:#0000FF,bold,underline")
|
||||
# Function or method name definition
|
||||
self.StyleSetSpec(9, "fore:#007F7F,bold")
|
||||
self.StyleSetSpec(SCE_P_DEFNAME, "fore:#007F7F,bold")
|
||||
# Operators
|
||||
self.StyleSetSpec(10, "bold")
|
||||
self.StyleSetSpec(SCE_P_OPERATOR, "bold")
|
||||
# Identifiers
|
||||
#self.StyleSetSpec(11, "bold")#,fore:#FF00FF")
|
||||
#self.StyleSetSpec(SCE_P_IDENTIFIER, "bold")#,fore:#FF00FF")
|
||||
# Comment-blocks
|
||||
self.StyleSetSpec(12, "fore:#7F7F7F")
|
||||
self.StyleSetSpec(SCE_P_COMMENTBLOCK, "fore:#7F7F7F")
|
||||
# End of line where string is not closed
|
||||
self.StyleSetSpec(13, "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces)
|
||||
# Matched Operators
|
||||
self.StyleSetSpec(34, "fore:#FFFFFF,back:#0000FF,bold")
|
||||
self.StyleSetSpec(35, "fore:#000000,back:#FF0000,bold")
|
||||
self.StyleSetSpec(SCE_P_STRINGEOL, "fore:#000000,face:%(mono)s,back:#E0C0E0,eolfilled" % faces)
|
||||
|
||||
|
||||
self.SetCaretForeground("BLUE")
|
||||
|
||||
EVT_KEY_UP(self, self.OnKeyPressed)
|
||||
|
||||
|
@@ -5,6 +5,20 @@ import string
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyTreeCtrl(wxTreeCtrl):
|
||||
def __init__(self, parent, id, pos, size, style):
|
||||
wxTreeCtrl.__init__(self, parent, id, pos, size, style)
|
||||
|
||||
|
||||
def OnCompareItems(self, item1, item2):
|
||||
t1 = self.GetItemText(item1)
|
||||
t2 = self.GetItemText(item2)
|
||||
if t1 < t2: return -1
|
||||
if t1 == t2: return 0
|
||||
return 1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTreeCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
@@ -12,7 +26,7 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
self.tree = MyTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE)
|
||||
|
||||
#il = wxImageList(16, 16)
|
||||
@@ -25,19 +39,27 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
#self.tree.SetImageList(il)
|
||||
#self.il = il
|
||||
|
||||
# NOTE: For some reason tree items have to have a data object in
|
||||
# order to be sorted. Since our compare just uses the labels
|
||||
# we don't need any real data, so we'll just use None.
|
||||
|
||||
self.root = self.tree.AddRoot("The Root Item")
|
||||
self.tree.SetPyData(self.root, None)
|
||||
#self.tree.SetItemImage(self.root, idx1)
|
||||
|
||||
for x in range(15):
|
||||
child = self.tree.AppendItem(self.root, "Item %d" % x)
|
||||
self.tree.SetPyData(child, None)
|
||||
#self.tree.SetItemImage(child, idx2)
|
||||
#self.tree.SetItemSelectedImage(child, idx3)
|
||||
for y in range(5):
|
||||
last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
|
||||
self.tree.SetPyData(last, None)
|
||||
#self.tree.SetItemImage(last, idx4)
|
||||
#self.tree.SetItemSelectedImage(last, idx5)
|
||||
for z in range(5):
|
||||
self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))
|
||||
item = self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))
|
||||
self.tree.SetPyData(item, None)
|
||||
|
||||
self.tree.Expand(self.root)
|
||||
EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
|
||||
@@ -50,6 +72,7 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
EVT_RIGHT_DOWN(self.tree, self.OnRightClick)
|
||||
EVT_RIGHT_UP(self.tree, self.OnRightUp)
|
||||
|
||||
|
||||
def OnRightClick(self, event):
|
||||
pt = event.GetPosition();
|
||||
item, flags = self.tree.HitTest(pt)
|
||||
@@ -89,6 +112,9 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
pt = event.GetPosition();
|
||||
item, flags = self.tree.HitTest(pt)
|
||||
self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item))
|
||||
parent = self.tree.GetItemParent(item)
|
||||
self.tree.SortChildren(parent)
|
||||
event.Skip()
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
|
Reference in New Issue
Block a user