我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用calendar.MONDAY。
def _weekend_trade_day_type(self, dates): types = [] weekdays = [] for dt in dates: weekday = dt.date().weekday() # ???????? if weekday == calendar.MONDAY: # ????????? _types = TRADE_DAY_TYPE_FIRST elif weekday == calendar.FRIDAY: # ???? _types = TRADE_DAY_TYPE_FRI elif weekday == calendar.SATURDAY: # ???? _types = TRADE_DAY_TYPE_SAT elif weekday == calendar.SUNDAY: # ?? _types = TRADE_DAY_TYPE_HOLIDAY else: # ????? _types = TRADE_DAY_TYPE_NORMAL types.append(_types) weekdays.append(weekday) return types, weekdays
def __init__(self, parent): Frame.__init__(self, parent) #Get Current Calender States firstDay = calendar.MONDAY year = self.datetime.now().year month = self.datetime.now().month selectedBg = '#9bc0d9' # Previous - 84b5d3 selectedFg = '#ffffff' self.date = self.datetime(year,month,1) self.selected = None self.currentTime = "" self.cal = getCalendar(None,firstDay) self.parent = parent self.initUI() #Main Calender Widget self.calenderStyleWidget() self.calenderPlaceWidget() self.calenderConfig() self.setupSelected(selectedBg, selectedFg) self.items = [self.calenderMainView.insert('', 'end', values='') for _ in range(6)] self.calenderMake() self.calenderMainView.bind('<Map>',self.minsize) #Add Events Listing Tabs self.eventViewerPlace() #Main Window Creation
def test_setfirstweekday(self): self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber') self.assertRaises(ValueError, calendar.setfirstweekday, -1) self.assertRaises(ValueError, calendar.setfirstweekday, 200) orig = calendar.firstweekday() calendar.setfirstweekday(calendar.SUNDAY) self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) calendar.setfirstweekday(calendar.MONDAY) self.assertEqual(calendar.firstweekday(), calendar.MONDAY) calendar.setfirstweekday(orig)
def test_setfirstweekday(self): self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') self.assertRaises(ValueError, calendar.setfirstweekday, -1) self.assertRaises(ValueError, calendar.setfirstweekday, 200) orig = calendar.firstweekday() calendar.setfirstweekday(calendar.SUNDAY) self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) calendar.setfirstweekday(calendar.MONDAY) self.assertEqual(calendar.firstweekday(), calendar.MONDAY) calendar.setfirstweekday(orig)
def __init__(self, master=None, **kw): """ WIDGET-SPECIFIC OPTIONS locale, firstweekday, year, month, selectbackground, selectforeground """ # remove custom options from kw before initializating ttk.Frame fwday = kw.pop('firstweekday', calendar.MONDAY) year = kw.pop('year', self.datetime.now().year) month = kw.pop('month', self.datetime.now().month) locale = kw.pop('locale', None) sel_bg = kw.pop('selectbackground', '#ecffc4') sel_fg = kw.pop('selectforeground', '#05640e') self._date = self.datetime(year, month, 1) self._selection = None # no date selected ttk.Frame.__init__(self, master, **kw) self._cal = get_calendar(locale, fwday) self.__setup_styles() # creates custom styles self.__place_widgets() # pack/grid used widgets self.__config_calendar() # adjust calendar columns and setup tags # configure a canvas, and proper bindings, for selecting dates self.__setup_selection(sel_bg, sel_fg) # store items ids, used for insertion later self._items = [self._calendar.insert('', 'end', values='') for _ in range(6)] # insert dates in the currently empty calendar self._build_calendar() # set the minimal size for the widget self._calendar.bind('<Map>', self.__minsize)