Changeset 4232
- Timestamp:
- 07/04/08 10:13:10 (3 months ago)
- Files:
-
- trunk/dabo/ui/uiwx/dDateTextBox.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/ui/uiwx/dDateTextBox.py
r4186 r4232 15 15 16 16 class CalPanel(dPanel): 17 def __init__(self, parent, pos=None, dt=None, ctrl=None ): 17 def __init__(self, parent, pos=None, dt=None, ctrl=None, 18 extended=False): 18 19 if isinstance(dt, (datetime.datetime, datetime.date)): 19 20 self.date = dt … … 21 22 self.date = datetime.date.today() 22 23 self.ctrl = ctrl 24 self.extended = extended 23 25 super(CalPanel, self).__init__(parent, pos=pos) 24 26 … … 28 30 to the calendar's size. 29 31 """ 30 self.cal = dabo.ui.dCalendar(self, Position=(5, 5)) 32 calClass = {True: dabo.ui.dExtendedCalendar, False: dabo.ui.dCalendar}[self.extended] 33 self.cal = calClass(self, Position=(5, 5)) 31 34 self.cal.Date = self.date 32 35 self.cal.bindEvent(dEvents.Hit, self.onCalSelection) … … 42 45 self.ctrl.setDate(self.cal.Date) 43 46 self.ctrl.setFocus() 44 self. Visible = False47 self.Form.hide() 45 48 46 49 … … 50 53 if self.ctrl is not None: 51 54 self.ctrl.setFocus() 52 self. Visible = False55 self.Form.hide() 53 56 54 57 … … 76 79 # Do we display datetimes in 24-hour clock, or with AM/PM? 77 80 self.ampm = False 78 81 # Do we use the extended format for the calendar display? 82 self._extendedCalendar = False 83 79 84 80 85 def afterInit(self): 81 86 self._baseClass = dDateTextBox 82 87 self.Value = datetime.date.today() 88 self._calendarPanel = None 83 89 if self.showCalButton: 84 90 # Create a button that will display the calendar … … 102 108 C: Popup Calendar to Select 103 109 """) 104 self.DynamicToolTipText = lambda: {True: self._defaultToolTipText, 105 False: None}[self.Enabled and not self.ReadOnly] 106 110 # self.DynamicToolTipText = lambda: {True: self._defaultToolTipText, 111 # False: None}[self.Enabled and not self.ReadOnly] 112 113 self.DynamicToolTipText = lambda: "%s, %s" % self.formCoordinates() 107 114 108 115 def initEvents(self): … … 122 129 # ignore 123 130 return 124 availHt = self.Parent.Bottom - self.Bottom 125 try: 126 self.calPanel.cal.Date = self.Value 127 except AttributeError: 128 self.calPanel = CalPanel(self.Parent, dt=self.Value, ctrl=self) 129 cp = self.calPanel 130 cp.Position = (self.Left, self.Bottom) 131 if self.Bottom + cp.Height > self.Parent.Bottom: 132 # Maybe we should move it above 133 if cp.Height <= self.Top: 134 cp.Bottom = self.Top 135 else: 136 # We can't fit it cleanly, so try to fit as much as possible 137 cp.Top = max(0, (self.Parent.Height - cp.Height) ) 138 if self.Left + cp.Width > self.Parent.Right: 139 # Try moving it to the left 140 cp.Left = max(0, (self.Parent.Width - cp.Width) ) 141 cp.Visible = True 142 cp.bringToFront() 143 cp.setFocus() 131 cp = self._CalendarPanel 132 cp.cal.Date = self.Value 133 fp = self.Form.FloatingPanel 134 fp.Owner = self 135 fp.show() 144 136 145 137 … … 397 389 self.Value = dt 398 390 399 391 def _getCalendarPanel(self): 392 fp = self.Form.FloatingPanel 393 if not isinstance(self._calendarPanel, CalPanel) or not (self._calendarPanel.Parent is fp): 394 fp.clear() 395 self._calendarPanel = CalPanel(fp, dt=self.Value, ctrl=self, 396 extended=self.ExtendedCalendar) 397 fp.Sizer.append(self._calendarPanel) 398 fp.fitToSizer() 399 return self._calendarPanel 400 401 402 def _getExtendedCalendar(self): 403 return self._extendedCalendar 404 405 def _setExtendedCalendar(self, val): 406 if self._constructed(): 407 self._extendedCalendar = val 408 else: 409 self._properties["ExtendedCalendar"] = val 410 411 412 _CalendarPanel = property(_getCalendarPanel, None, None, 413 _("Reference to the displayed calendar (read-only) (CalPanel)")) 414 415 ExtendedCalendar = property(_getExtendedCalendar, _setExtendedCalendar, None, 416 _("""When True, the calendar is displayed in a larger format with more controls 417 for quickly moving to any date. Default=False (bool)""")) 418 419 400 420 401 421 if __name__ == "__main__":
