我有两个程序,一个显示日历,用户可以在其中选择他的月份,然后查看该月的日历。其次,该程序有三个框架和一个按钮“日历”。我该怎么办,当点击'GUIframe.py'程序的“日历”按钮时,'CalendarWidget.py'的功能才会生效?
- > GUIFrame
taskHandler :: Channel -> MVar () -> (Message, Envelope) -> IO ()
...
consumeMsgs ch "tasks" Ack (taskHandler ch lock)
---> CalendarWidget.py
from tkinter import *
root = Tk()
frame = Frame(root)
frame.pack()
def Bprint():
print("CLICKED")
def Bprint1():
print("Clicked Blue!")
bottomframe1=Frame(root)
bottomframe1.pack( side = BOTTOM )
bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )
redbutton = Button(frame, text="Red", fg="red")
redbutton.pack( side = LEFT)
greenbutton = Button(frame, text="Brown", fg="brown")
greenbutton.pack(side = RIGHT)
bluebutton = Button(frame, text="Blue", fg="blue", command=Bprint1)
bluebutton.pack(side = LEFT)
blackbutton = Button(bottomframe, text="Black", fg="black", command=Bprint)
blackbutton.pack( side = BOTTOM)
cal_b= Button(bottomframe1, text="Calendar", fg="black")
cal_b.pack(side=BOTTOM)
root.mainloop()
答案 0 :(得分:0)
您需要将command
绑定到文件中的按钮,看起来要调用test
,这样您就可以执行from CalendarWidget import test
然后执行
cal_b= Button(bottomframe1, text="Calendar", fg="black", command = test)
虽然您可能不希望在整个地方都有额外的Tk()
个实例,因此您应该使用Toplevel
小部件作为日历。