This commit was manufactured by cvs2svn to create tag
'DEBIAN_2_3_3_2'. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/DEBIAN_2_3_3_2@17391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -45,7 +45,10 @@ class CustomDataTable(wxPyGridTableBase):
|
||||
return len(self.data[0])
|
||||
|
||||
def IsEmptyCell(self, row, col):
|
||||
return not self.data[row][col]
|
||||
try:
|
||||
return not self.data[row][col]
|
||||
except IndexError:
|
||||
return true
|
||||
|
||||
# Get/Set values in the table. The Python version of these
|
||||
# methods can handle any data-type, (as long as the Editor and
|
||||
@@ -138,8 +141,22 @@ class CustTableGrid(wxGrid):
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, "Custom Table, data driven Grid Demo", size=(640,480))
|
||||
grid = CustTableGrid(self, log)
|
||||
p = wxPanel(self, -1, style=0)
|
||||
grid = CustTableGrid(p, log)
|
||||
b = wxButton(p, -1, "Another Control...")
|
||||
b.SetDefault()
|
||||
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
||||
EVT_SET_FOCUS(b, self.OnButtonFocus)
|
||||
bs = wxBoxSizer(wxVERTICAL)
|
||||
bs.Add(grid, 1, wxGROW|wxALL, 5)
|
||||
bs.Add(b)
|
||||
p.SetSizer(bs)
|
||||
|
||||
def OnButton(self, evt):
|
||||
print "button selected"
|
||||
|
||||
def OnButtonFocus(self, evt):
|
||||
print "button focus"
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
@@ -53,6 +53,14 @@ class SimpleGrid(wxGrid): ##, wxGridAutoEditMixin):
|
||||
|
||||
self.SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_BOTTOM)
|
||||
|
||||
# overflow cells
|
||||
self.SetCellValue( 9, 1, "This default cell will overflow into neighboring cells, but not if you turn overflow off.");
|
||||
self.SetCellSize(11, 1, 3, 3);
|
||||
self.SetCellAlignment(11, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
self.SetCellValue(11, 1, "This cell is set span 3 rows and 3 columns");
|
||||
|
||||
|
||||
|
||||
# test all the events
|
||||
EVT_GRID_CELL_LEFT_CLICK(self, self.OnCellLeftClick)
|
||||
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnCellRightClick)
|
||||
|
@@ -37,6 +37,7 @@ _treeList = [
|
||||
'wxKeyEvents',
|
||||
'wxWizard',
|
||||
'wxXmlResourceHandler',
|
||||
'wxTimeCtrl',
|
||||
]),
|
||||
|
||||
# managed windows == things with a caption you can close
|
||||
@@ -129,6 +130,7 @@ _treeList = [
|
||||
'wxRightTextCtrl',
|
||||
'wxStyledTextCtrl_1',
|
||||
'wxStyledTextCtrl_2',
|
||||
'wxTimeCtrl',
|
||||
]),
|
||||
|
||||
# How to lay out the controls in a frame/dialog
|
||||
|
@@ -4,7 +4,10 @@ from wxPython.wx import *
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", size=wxSize(350, 200), style=wxCAPTION)
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", size=wxSize(350, 200),
|
||||
style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
|
||||
#style = wxDEFAULT_DIALOG_STYLE
|
||||
)
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
@@ -63,10 +66,13 @@ def runTest(frame, nb, log):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
||||
|
@@ -223,7 +223,8 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
|
||||
|
||||
def OnItemActivated(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemActivated: %s\n" % self.list.GetItemText(self.currentItem))
|
||||
self.log.WriteText("OnItemActivated: %s\nTopItem: %s" %
|
||||
(self.list.GetItemText(self.currentItem), self.list.GetTopItem()))
|
||||
|
||||
def OnItemDelete(self, event):
|
||||
self.log.WriteText("OnItemDelete\n")
|
||||
|
@@ -45,7 +45,8 @@ class TestVirtualList(wxListCtrl):
|
||||
|
||||
def OnItemActivated(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemActivated: %s\n" % self.GetItemText(self.currentItem))
|
||||
self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" %
|
||||
(self.GetItemText(self.currentItem), self.GetTopItem()))
|
||||
|
||||
def getColumnText(self, index, col):
|
||||
item = self.GetItem(index, col)
|
||||
|
@@ -149,6 +149,7 @@ class MyCanvas(wxScrolledWindow):
|
||||
|
||||
def OnLeftButtonEvent(self, event):
|
||||
if event.LeftDown():
|
||||
self.SetFocus()
|
||||
self.SetXY(event)
|
||||
self.curLine = []
|
||||
self.CaptureMouse()
|
||||
|
@@ -20,50 +20,64 @@ class TestPanel(wxPanel):
|
||||
self.log = log
|
||||
|
||||
l1 = wxStaticText(self, -1, "wxTextCtrl")
|
||||
t1 = wxTextCtrl(self, 10, "Test it out and see", size=(125, -1))
|
||||
t1 = wxTextCtrl(self, -1, "Test it out and see", size=(125, -1))
|
||||
t1.SetInsertionPoint(0)
|
||||
EVT_TEXT(self, 10, self.EvtText)
|
||||
self.tc1 = t1
|
||||
EVT_TEXT(self, t1.GetId(), self.EvtText)
|
||||
EVT_CHAR(t1, self.EvtChar)
|
||||
EVT_SET_FOCUS(t1, self.OnSetFocus)
|
||||
EVT_KILL_FOCUS(t1, self.OnKillFocus)
|
||||
EVT_WINDOW_DESTROY(t1, self.OnWindowDestroy)
|
||||
|
||||
l2 = wxStaticText(self, -1, "Passsword")
|
||||
t2 = wxTextCtrl(self, 20, "", size=(125, -1), style=wxTE_PASSWORD)
|
||||
EVT_TEXT(self, 20, self.EvtText)
|
||||
t2 = wxTextCtrl(self, -1, "", size=(125, -1), style=wxTE_PASSWORD)
|
||||
EVT_TEXT(self, t2.GetId(), self.EvtText)
|
||||
|
||||
l3 = wxStaticText(self, -1, "Multi-line")
|
||||
t3 = wxTextCtrl(self, 30,
|
||||
t3 = wxTextCtrl(self, -1,
|
||||
"Here is a looooooooooooooong line of text set in the control.\n\n"
|
||||
"The quick brown fox jumped over the lazy dog...",
|
||||
size=(200, 100), style=wxTE_MULTILINE)
|
||||
t3.SetInsertionPoint(0)
|
||||
EVT_TEXT(self, 30, self.EvtText)
|
||||
EVT_TEXT(self, t3.GetId(), self.EvtText)
|
||||
b = wxButton(self, -1, "Test Replace")
|
||||
EVT_BUTTON(self, b.GetId(), self.OnTestReplace)
|
||||
b2 = wxButton(self, -1, "Test GetSelection")
|
||||
EVT_BUTTON(self, b2.GetId(), self.OnTestGetSelection)
|
||||
b3 = wxButton(self, -1, "Test WriteText")
|
||||
EVT_BUTTON(self, b3.GetId(), self.OnTestWriteText)
|
||||
self.tc = t3
|
||||
|
||||
l4 = wxStaticText(self, -1, "Rich Text")
|
||||
t4 = wxTextCtrl(self, 40, "If supported by the native control, this is red, and this is a different font.",
|
||||
t4 = wxTextCtrl(self, -1, "If supported by the native control, this is red, and this is a different font.",
|
||||
size=(200, 100), style=wxTE_MULTILINE|wxTE_RICH2)
|
||||
t4.SetInsertionPoint(0)
|
||||
t4.SetStyle(44, 47, wxTextAttr("RED", "YELLOW"))
|
||||
|
||||
points = t4.GetFont().GetPointSize() # get the current size
|
||||
f = wxFont(points+3, wxROMAN, wxITALIC, wxBOLD, true)
|
||||
t4.SetStyle(63, 77, wxTextAttr("BLUE", wxNullColour, f))
|
||||
|
||||
l5 = wxStaticText(self, -1, "Test Positions")
|
||||
t5 = wxTextCtrl(self, -1, "0123456789\n" * 5, size=(200, 100),
|
||||
style = wxTE_MULTILINE
|
||||
#| wxTE_RICH
|
||||
| wxTE_RICH2
|
||||
)
|
||||
EVT_LEFT_DOWN(t5, self.OnT5LeftDown)
|
||||
self.t5 = t5
|
||||
|
||||
|
||||
bsizer = wxBoxSizer(wxVERTICAL)
|
||||
bsizer.Add(b, 0, wxGROW)
|
||||
bsizer.Add(b2, 0, wxGROW)
|
||||
bsizer.Add(b3, 0, wxGROW)
|
||||
|
||||
sizer = wxFlexGridSizer(cols=3, hgap=6, vgap=6)
|
||||
sizer.AddMany([ l1, t1, (0,0),
|
||||
l2, t2, (0,0),
|
||||
l3, t3, bsizer,
|
||||
l4, t4, (0,0),
|
||||
l5, t5, (0,0),
|
||||
])
|
||||
border = wxBoxSizer(wxVERTICAL)
|
||||
border.Add(sizer, 0, wxALL, 25)
|
||||
@@ -84,6 +98,9 @@ class TestPanel(wxPanel):
|
||||
self.tc.Replace(5, 9, "IS A")
|
||||
#self.tc.Remove(5, 9)
|
||||
|
||||
def OnTestWriteText(self, evt):
|
||||
self.tc.WriteText("TEXT")
|
||||
|
||||
def OnTestGetSelection(self, evt):
|
||||
start, end = self.tc.GetSelection()
|
||||
text = self.tc.GetValue()
|
||||
@@ -96,6 +113,22 @@ class TestPanel(wxPanel):
|
||||
self.tc.GetStringSelection(),
|
||||
repr(text[start:end])))
|
||||
|
||||
def OnT5LeftDown(self, evt):
|
||||
evt.Skip()
|
||||
wxCallAfter(self.LogT5Position, evt)
|
||||
|
||||
def LogT5Position(self, evt):
|
||||
text = self.t5.GetValue()
|
||||
ip = self.t5.GetInsertionPoint()
|
||||
lp = self.t5.GetLastPosition()
|
||||
self.log.write("LogT5Position:\n"
|
||||
"\tGetInsertionPoint:\t%d\n"
|
||||
"\ttext[insertionpoint]:\t%s\n"
|
||||
"\tGetLastPosition:\t%d\n"
|
||||
"\tlen(text):\t\t%d\n"
|
||||
% (ip, text[ip], lp, len(text)))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
213
wxPython/demo/wxTimeCtrl.py
Normal file
213
wxPython/demo/wxTimeCtrl.py
Normal file
@@ -0,0 +1,213 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.timectrl import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel( wxPanel ):
|
||||
def __init__( self, parent, log ):
|
||||
|
||||
wxPanel.__init__( self, parent, -1 )
|
||||
self.log = log
|
||||
panel = wxPanel( self, -1 )
|
||||
|
||||
grid = wxFlexGridSizer( 0, 2, 20, 0 )
|
||||
|
||||
text1 = wxStaticText( panel, 10, "A 12-hour format wxTimeCtrl:")
|
||||
self.time12 = wxTimeCtrl( panel, 20, name="12 hour control" )
|
||||
spin1 = wxSpinButton( panel, 30, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
self.time12.BindSpinButton( spin1 )
|
||||
|
||||
grid.AddWindow( text1, 0, wxALIGN_RIGHT, 5 )
|
||||
hbox1 = wxBoxSizer( wxHORIZONTAL )
|
||||
hbox1.AddWindow( self.time12, 0, wxALIGN_CENTRE, 5 )
|
||||
hbox1.AddWindow( spin1, 0, wxALIGN_CENTRE, 5 )
|
||||
grid.AddSizer( hbox1, 0, wxLEFT, 5 )
|
||||
|
||||
|
||||
text2 = wxStaticText( panel, 40, "A 24-hour format wxTimeCtrl:")
|
||||
self.time24 = wxTimeCtrl( panel, 50, fmt24hr=true, name="24 hour control" )
|
||||
spin2 = wxSpinButton( panel, 60, wxDefaultPosition, wxSize(-1,20), 0 )
|
||||
self.time24.BindSpinButton( spin2 )
|
||||
|
||||
grid.AddWindow( text2, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
hbox2 = wxBoxSizer( wxHORIZONTAL )
|
||||
hbox2.AddWindow( self.time24, 0, wxALIGN_CENTRE, 5 )
|
||||
hbox2.AddWindow( spin2, 0, wxALIGN_CENTRE, 5 )
|
||||
grid.AddSizer( hbox2, 0, wxLEFT, 5 )
|
||||
|
||||
|
||||
text3 = wxStaticText( panel, 70, "A wxTimeCtrl without a spin button:")
|
||||
self.spinless_ctrl = wxTimeCtrl( panel, 80, name="spinless control" )
|
||||
|
||||
grid.AddWindow( text3, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
grid.AddWindow( self.spinless_ctrl, 0, wxLEFT, 5 )
|
||||
|
||||
|
||||
buttonChange = wxButton( panel, 100, "Change Controls")
|
||||
self.radio12to24 = wxRadioButton( panel, 110, "Copy 12-hour time to 24-hour control", wxDefaultPosition, wxDefaultSize, wxRB_GROUP )
|
||||
self.radio24to12 = wxRadioButton( panel, 120, "Copy 24-hour time to 12-hour control")
|
||||
self.radioWx = wxRadioButton( panel, 130, "Set controls to 'now' using wxDateTime")
|
||||
self.radioMx = wxRadioButton( panel, 140, "Set controls to 'now' using mxDateTime")
|
||||
|
||||
radio_vbox = wxBoxSizer( wxVERTICAL )
|
||||
radio_vbox.AddWindow( self.radio12to24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radio24to12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radioWx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
radio_vbox.AddWindow( self.radioMx, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
box_label = wxStaticBox( panel, 90, "Change Controls through API" )
|
||||
buttonbox = wxStaticBoxSizer( box_label, wxHORIZONTAL )
|
||||
buttonbox.AddWindow( buttonChange, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
buttonbox.AddSizer( radio_vbox, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
outer_box = wxBoxSizer( wxVERTICAL )
|
||||
outer_box.AddSizer( grid, 0, wxALIGN_CENTRE|wxBOTTOM, 20 )
|
||||
outer_box.AddSizer( buttonbox, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
|
||||
# Turn on mxDateTime option only if we can import the module:
|
||||
try:
|
||||
from mx import DateTime
|
||||
except ImportError:
|
||||
self.radioMx.Enable( false )
|
||||
|
||||
|
||||
panel.SetAutoLayout( true )
|
||||
panel.SetSizer( outer_box )
|
||||
outer_box.Fit( panel )
|
||||
panel.Move( (50,50) )
|
||||
self.panel = panel
|
||||
|
||||
|
||||
EVT_TIMEUPDATE( self, self.time12.GetId(), self.OnTimeChange )
|
||||
EVT_TIMEUPDATE( self, self.time24.GetId(), self.OnTimeChange )
|
||||
EVT_TIMEUPDATE( self, self.spinless_ctrl.GetId(), self.OnTimeChange )
|
||||
|
||||
EVT_BUTTON( self, buttonChange.GetId(), self.OnButtonClick )
|
||||
|
||||
|
||||
def OnTimeChange( self, event ):
|
||||
timectrl = self.panel.FindWindowById( event.GetId() )
|
||||
self.log.write('%s time = %s\n' % ( timectrl.GetName(), timectrl.GetValue() ) )
|
||||
|
||||
def OnButtonClick( self, event ):
|
||||
if self.radio12to24.GetValue():
|
||||
self.time24.SetValue( self.time12.GetValue() )
|
||||
|
||||
elif self.radio24to12.GetValue():
|
||||
self.time12.SetValue( self.time24.GetValue() )
|
||||
|
||||
elif self.radioWx.GetValue():
|
||||
now = wxDateTime_Now()
|
||||
self.time12.SetWxDateTime( now )
|
||||
self.time24.SetWxDateTime( now )
|
||||
self.spinless_ctrl.SetWxDateTime( now )
|
||||
|
||||
elif self.radioMx.GetValue():
|
||||
from mx import DateTime
|
||||
now = DateTime.now()
|
||||
self.time12.SetMxDateTime( now )
|
||||
self.time24.SetMxDateTime( now )
|
||||
self.spinless_ctrl.SetMxDateTime( now )
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest( frame, nb, log ):
|
||||
win = TestPanel( nb, log )
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = """<html><body>
|
||||
<P>
|
||||
<B>wxTimeCtrl</B> provides a multi-cell control that allows manipulation of a time
|
||||
value. It supports 12 or 24 hour format, and you can use wxDateTime or mxDateTime
|
||||
to get/set values from the control.
|
||||
<P>
|
||||
Left/right/tab keys to switch cells within a wxTimeCtrl, and the up/down arrows act
|
||||
like a spin control. wxTimeCtrl also allows for an actual spin button to be attached
|
||||
to the control, so that it acts like the up/down arrow keys.
|
||||
<P>
|
||||
The <B>!</B> key sets the value of the control to <B><I>now!</I></B>
|
||||
<P>
|
||||
Here's the API for wxTimeCtrl:
|
||||
<DL><PRE>
|
||||
<B>wxTimeCtrl</B>(
|
||||
parent, id = -1,
|
||||
<B>value</B> = '12:00:00 AM',
|
||||
pos = wxDefaultPosition,
|
||||
size = wxDefaultSize,
|
||||
<B>fmt24hr</B> = false,
|
||||
<B>spinButton</B> = None,
|
||||
<B>style</B> = wxTE_PROCESS_TAB,
|
||||
name = "time")
|
||||
</PRE>
|
||||
<UL>
|
||||
<DT><B>value</B>
|
||||
<DD>If no initial value is set, the default will be midnight; if an illegal string
|
||||
is specified, a ValueError will result. (You can always later set the initial time
|
||||
with SetValue() after instantiation of the control.)
|
||||
<DL><B>size</B>
|
||||
<DD>The size of the control will be automatically adjusted for 12/24 hour format
|
||||
if wxDefaultSize is specified.
|
||||
<BR>
|
||||
<DT><B>fmt24hr</B>
|
||||
<DD>If true, control will display time in 24 hour time format; if false, it will
|
||||
use 12 hour AM/PM format. SetValue() will adjust values accordingly for the
|
||||
control, based on the format specified.
|
||||
<BR>
|
||||
<DT><B>spinButton</B>
|
||||
<DD>If specified, this button's events will be bound to the behavior of the
|
||||
wxTimeCtrl, working like up/down cursor key events. (See BindSpinButton.)
|
||||
<BR>
|
||||
<DT><B>style</B>
|
||||
<DD>By default, wxTimeCtrl will process TAB events, by allowing tab to the
|
||||
different cells within the control.
|
||||
</DL>
|
||||
</UL>
|
||||
<BR>
|
||||
<BR>
|
||||
<DT><B>SetValue(time_string)</B>
|
||||
<DD>Sets the value of the control to a particular time, given a valid time string;
|
||||
raises ValueError on invalid value
|
||||
<BR>
|
||||
<DT><B>GetValue()</B>
|
||||
<DD>Retrieves the string value of the time from the control
|
||||
<BR>
|
||||
<DT><B>SetWxDateTime(wxDateTime)</B>
|
||||
<DD>Uses the time portion of a wxDateTime to construct a value for the control.
|
||||
<BR>
|
||||
<DT><B>GetWxDateTime()</B>
|
||||
<DD>Retrieves the value of the control, and applies it to the wxDateTimeFromHMS()
|
||||
constructor, and returns the resulting value. (This returns the date portion as
|
||||
"today".)
|
||||
<BR>
|
||||
<DT><B>SetMxDateTime(mxDateTime)</B>
|
||||
<DD>Uses the time portion of an mxDateTime to construct a value for the control.
|
||||
<EM>NOTE:</EM> This imports mx.DateTime at runtime only if this or the Get function
|
||||
is called.
|
||||
<BR>
|
||||
<DT><B>GetMxDateTime()</B>
|
||||
<DD>Retrieves the value of the control and applies it to the DateTime.Time()
|
||||
constructor, and returns the resulting value. (mxDateTime is smart enough to
|
||||
know this is just a time value.)
|
||||
<BR>
|
||||
<DT><B>BindSpinButton(wxSpinBtton)</B>
|
||||
<DD>Binds an externally created spin button to the control, so that up/down spin
|
||||
events change the active cell or selection in the control (in addition to the
|
||||
up/down cursor keys.) (This is primarily to allow you to create a "standard"
|
||||
interface to time controls, as seen in Windows.)
|
||||
<BR>
|
||||
<DT><B>EVT_TIMEUPDATE(win, id, func)</B>
|
||||
<DD>func is fired whenever the value of the control changes.
|
||||
</DL>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])])
|
||||
|
Reference in New Issue
Block a user