some fixes and a new mixin class added to the library
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
bec0a26172
commit
6a1836a0a4
@ -5,8 +5,8 @@
|
||||
# Author: Lorne White (email: lorne.white@telusplanet.net)
|
||||
#
|
||||
# Created:
|
||||
# Version 0.8
|
||||
# Date: Feb 27, 2001
|
||||
# Version 0.85
|
||||
# Date: June 20, 2001
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@ -31,7 +31,7 @@ def GetMonthList():
|
||||
if name != None:
|
||||
monthlist.append(name)
|
||||
return monthlist
|
||||
|
||||
|
||||
class CalDraw:
|
||||
def __init__(self, parent):
|
||||
self.pwidth = 1
|
||||
@ -635,7 +635,7 @@ class wxCalendar(wxWindow):
|
||||
|
||||
def ClearDsp(self):
|
||||
self.Clear()
|
||||
|
||||
|
||||
class CalenDlg(wxDialog):
|
||||
def __init__(self, parent, month=None, day = None, year=None):
|
||||
wxDialog.__init__(self, parent, -1, "Event Calendar", wxPyDefaultPosition, wxSize(280, 360))
|
||||
@ -647,8 +647,8 @@ class CalenDlg(wxDialog):
|
||||
start_month = self.calend.GetMonth()
|
||||
start_year = self.calend.GetYear()
|
||||
else:
|
||||
start_month = month
|
||||
start_year = year
|
||||
self.calend.month = start_month = month
|
||||
self.calend.year = start_year = year
|
||||
self.calend.SetDayValue(day)
|
||||
|
||||
self.calend.HideTitle()
|
||||
@ -691,7 +691,7 @@ class CalenDlg(wxDialog):
|
||||
mID = NewId()
|
||||
wxButton(self, mID, ' Ok ', wxPoint(x_pos, y_pos), but_size)
|
||||
EVT_BUTTON(self, mID, self.OnOk)
|
||||
|
||||
|
||||
mID = NewId()
|
||||
wxButton(self, mID, ' Close ', wxPoint(x_pos + 120, y_pos), but_size)
|
||||
EVT_BUTTON(self, mID, self.OnCancel)
|
||||
@ -704,6 +704,7 @@ class CalenDlg(wxDialog):
|
||||
|
||||
# log the mouse clicks
|
||||
def MouseClick(self, evt):
|
||||
self.month = evt.month
|
||||
self.result = [evt.click, str(evt.day), Month[evt.month], str(evt.year)] # result click type and date
|
||||
|
||||
if evt.click == 'DLEFT':
|
||||
@ -737,3 +738,4 @@ class CalenDlg(wxDialog):
|
||||
self.calend.Refresh()
|
||||
|
||||
|
||||
|
||||
|
43
wxPython/wxPython/lib/mixins/grid.py
Normal file
43
wxPython/wxPython/lib/mixins/grid.py
Normal file
@ -0,0 +1,43 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: wxPython.lib.mixins.grid
|
||||
# Purpose: Helpful mix-in classes for wxGrid
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 5-June-2001
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 2001 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython import wx, grid
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxGridAutoEditMixin:
|
||||
"""A mix-in class that automatically enables the grid edit control when
|
||||
a cell is selected.
|
||||
|
||||
If your class hooks EVT_GRID_SELECT_CELL be sure to call event.Skip so
|
||||
this handler will be called too.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.__enableEdit = 0
|
||||
wx.EVT_IDLE(self, self.__OnIdle)
|
||||
grid.EVT_GRID_SELECT_CELL(self, self.__OnSelectCell)
|
||||
|
||||
|
||||
def __OnIdle(self, evt):
|
||||
if self.__enableEdit:
|
||||
if self.CanEnableCellControl():
|
||||
self.EnableCellEditControl()
|
||||
self.__enableEdit = 0
|
||||
evt.Skip()
|
||||
|
||||
|
||||
def __OnSelectCell(self, evt):
|
||||
self.__enableEdit = 1
|
||||
evt.Skip()
|
||||
|
@ -50,14 +50,15 @@ class MagicImageList:
|
||||
'''Add an icon to the image list, or get the index if already there'''
|
||||
index = self.__magicImageListMapping.get (id (icon))
|
||||
if index is None:
|
||||
if isinstance( icon, wxIcon ):
|
||||
if isinstance( icon, wxIconPtr ):
|
||||
index = self.__magicImageList.AddIcon( icon )
|
||||
elif isinstance( icon, wxBitmap ):
|
||||
elif isinstance( icon, wxBitmapPtr ):
|
||||
if isinstance( mask, wxColour ):
|
||||
index = self.__magicImageList.AddWithColourMask( icon, mask )
|
||||
else:
|
||||
index = self.__magicImageList.Add( icon, mask )
|
||||
else:
|
||||
print icon.__class__.__name__
|
||||
raise ValueError("Unexpected icon object %s, "
|
||||
"expected wxIcon or wxBitmap" % (icon))
|
||||
self.__magicImageListMapping [id (icon)] = index
|
||||
|
Loading…
Reference in New Issue
Block a user