【发布时间】:2014-08-26 14:26:16
【问题描述】:
我正在使用 Python 的日历小部件。单击按钮时,我需要调用小部件。 情况是我找不到显示小部件本身的日历类中的方法是什么。 日历类取自这里: http://www.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html
这是我的导入:
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import time
import requests #needs to be installed
import pymysql #needs to be installed
import csv
import win32com.client #needs to be installed
from calendar import Calendar
import datetime
这里是按钮的创建:
# Calendar Buttons
calBut=ttk.Button(f2, width=4, text="Cal", command=Calendar.what_method?).grid(column=3,row=1, sticky=W)
据我所知,我可以设置按钮的命令来调用位于日历类中的小部件显示方法。 如何获取每次单击我的按钮时显示日历小部件的方法?显示的都没有显示小部件。
使用 Python 3.3.5 蜘蛛 WinPython 3.3.5
**编辑**
程序有选项卡,f2 表示按钮所在的选项卡。
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import time
import requests #needs to be installed
import pymysql #needs to be installed
import csv
import win32com.client #needs to be installed
import datetime
from calendar import Calendar
import calendar
#################################
# Create Button Click Calendar
def callback():
root2=Toplevel(f2)
ttkcal = Calendar(root2,firstweekday=calendar.SUNDAY)
ttkcal.pack(expand=1, fill='both')
root2.update()
root2.minsize(root2.winfo_reqwidth(), root2.winfo_reqheight())
# Calendar Buttons
b=ttk.Button(f2, width=4, text="Cal", command=callback).grid(column=3,row=1, sticky=W)
当我按下按钮时,它会打开日历窗口,但它是空的。控制台给了我错误:
TypeError: __init__() got multiple values for argument 'firstweekday
谢谢
【问题讨论】:
标签: python calendar widget qwidget qtgui