本文整理汇总了Python中calendar.Calendar.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Calendar.pack方法的具体用法?Python Calendar.pack怎么用?Python Calendar.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar.Calendar
的用法示例。
在下文中一共展示了Calendar.pack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryWindow
# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import pack [as 别名]
class HistoryWindow(Toplevel):
def __init__(self, root):
Toplevel.__init__(self, root)
self.title("History [Money Timer]")
self._cal = Calendar(self)
self._cal.pack()
self._dateLabel = Label(self)
self._dateLabel.pack()
self._timeLabel = Label(self)
self._timeLabel.pack()
for entry in self.master.history:
self._cal.add_day_action(year = entry["year"],
month = entry["mon"] - 1,
day = entry["day"],
action = self._show_day)
def _show_day(self, year, month, day):
print("Entry {}-{}-{} showing.".format(year, month +1, day))
entry = None
for item in self.master.history:
if item["year"] == year and item["mon"] == month + 1 and item["day"] == day:
entry = item
break
if entry == None:
return
monStr = str(entry["mon"]) if entry["mon"] >= 10 else "0" + str(entry["mon"])
dayStr = str(entry["day"]) if entry["day"] >= 10 else "0" + str(entry["day"])
wDayStr = entry["wday"] + " "*(5-len(entry["wday"])) if 5 - len(entry["wday"]) > 0 else entry["wday"]
intHr = int(entry["secSoFar"] // 3600)
intMin = int(entry["secSoFar"] % 3600 // 60)
intSec = int(entry["secSoFar"] % 60)
strMin = str(intMin) if intMin >= 10 else "0" + str(intMin)
strSec = str(intSec) if intSec >= 10 else "0" + str(intSec)
earningsStr = "{:.2f}".format(entry["earnings"])
earningsStr += " "*(7 - len(earningsStr)) if ((7 - len(earningsStr)) > 0) else earningsStr
self._dateLabel.config(text="{}-{}-{}\t{}".format(entry["year"],monStr,dayStr, wDayStr))
self._timeLabel.config(text="{}:{}:{}\t${}\t{:.1f}%".format(intHr,
strMin,
strSec,
earningsStr,
entry["percent"]))
def destroy(self):
self.master.historyOpen = False
super().destroy()