Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- added missing changes to Calendar

- added example which shows DateField usage
  • Loading branch information...
commit 078e5a66161666e68dd1a4e576e4bab68a3172a9 1 parent 9ec8e81
@mahomahomaho mahomahomaho authored
View
3  .gitignore
@@ -20,3 +20,6 @@ __output__
.lock*
.waf*
+/.project
+/.pydevproject
+/.settings
View
3  examples/datefield/DateField.py
@@ -8,6 +8,7 @@
from pyjamas.ui.TextBox import TextBox
from pyjamas.ui.Button import Button
from pyjamas.ui.Calendar import DateField, Calendar, CalendarPopup
+from pyjamas.ui.MonthField import MonthField
class App:
def onModuleLoad(self):
@@ -17,12 +18,14 @@ def onModuleLoad(self):
df2 = DateField(format='%Y/%m/%d')
b = Button("Show Calendar", self)
self.cal = Calendar()
+ df3 = MonthField()
vp = VerticalPanel()
vp.setSpacing(10)
vp.add(df1)
vp.add(b)
vp.add(df2)
+ vp.add(df3)
RootPanel().add(vp)
View
2  examples/datefield/public/DateField.html
@@ -2,7 +2,7 @@
<head>
<meta name="pygwt:module" content="DateField">
<link rel='stylesheet' href='DateField.css'>
- <title>Calendar Example</title>
+ <title>Calendar and Monthfield Example</title>
</head>
<body bgcolor="white">
<script language="javascript" src="bootstrap.js"></script>
View
35 library/pyjamas/ui/Calendar.py
@@ -21,7 +21,7 @@
from pyjamas import DOM
import time
-from datetime import datetime
+from datetime import datetime, date
class Calendar(FocusPanel):
monthsOfYear = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -200,6 +200,17 @@ def drawFull(self, month, year):
self.middlePanel.setWidget(grid)
self.vp.add(self.middlePanel)
self.defaultGrid = grid
+
+ self._gridShortcutsLinks()
+ self._gridCancelLink()
+ #
+ # add code to test another way of doing the layout
+ #
+ self.setVisible(True)
+ return
+
+ def _gridShortcutsLinks(self):
+
#
# some links & handlers
#
@@ -209,25 +220,23 @@ def drawFull(self, month, year):
bh2.addClickListener(getattr(self, 'onToday'))
bh3 = Hyperlink(self.tomorrow)
bh3.addClickListener(getattr(self, 'onTomorrow'))
- bh4 = Hyperlink(self.cancel)
- bh4.addClickListener(getattr(self, 'onCancel'))
- #
- # add code to test another way of doing the layout
- #
+
b = HorizontalPanel()
b.add(bh1)
b.add(bh2)
b.add(bh3)
b.addStyleName("calendar-shortcuts")
self.vp.add(b)
+
+ def _gridCancelLink(self):
+ bh4 = Hyperlink(self.cancel)
+ bh4.addClickListener(getattr(self, 'onCancel'))
+
b2 = SimplePanel()
b2.add(bh4)
b2.addStyleName("calendar-cancel")
self.vp.add(b2)
- self.setVisible(True)
- return
-
def drawGrid(self, month, year):
# draw the grid in the middle of the calendar
@@ -438,6 +447,14 @@ def getTextBox(self):
def getCalendar(self):
return self.calendar
+ def getDate(self):
+ """ returns datetime.date object or None if empty/unparsable by current format"""
+ _sdate = self.tbox.getText()
+ try:
+ return datetime.strptime(_sdate, self.format).date()
+ except ValueError:
+ return None
+
def setID(self, id):
self.tbox.setID(id)
Please sign in to comment.
Something went wrong with that request. Please try again.