tk calendar changing event selection from full background selection to dot and working the event function

23 Views Asked by At
from constants import *
class Calendar_Display():
  def __init__(self,d):
    self.event_id = 0
    ''' Different ways of formatting date'''
    # dd/mm/YY
    self.date = d
    self.formatted = self.date.strftime("%m/%d/%y")
    self.formatted2 = datetime.strptime(self.formatted, "%m/%d/%y").date()

    self.day = self.date.strftime('%d')
    self.month = self.date.strftime('%m')
    self.year = self.date.strftime('%Y')
    self.Get()
    self.revert()
  def print(self):
    tk.Label(tab_search("Calendar"),text = f"Month abbreviation, day and year format = {self.d3}").pack(side="bottom")
    tk.Label(tab_search("Calendar"),text = f"dd/mm/YY format = {self.d1}").pack(side="bottom")
    tk.Label(tab_search("Calendar"),text = f"Textual month, day and year format = {self.d2}").pack(side="bottom")


  def display_Calendar_widget(self):
    self.calendar = Calendar(
      tab_search("Calendar"),
      selectmode="day",
      month=int(self.month),
      day=int(self.day),
      year=int(self.year),
      selectbackground = "red",
      selectforeground = "white"
      )
    self.calendar.place(x=0,y=0,width=W+300)
  def do(self,date):
    tk.Label(tab_search("Calendar"),text=f"Success, you clicked event on date {date}").pack()
  def revert(self):
    def jump():
      self.display_Calendar_widget()
    tk.Button(tab_search("Calendar"),text="Click to go back to today",command=jump,background="black",foreground="yellow").place(x=225,y=300)
  def add_event(self):
      self.event_id = self.calendar.calevent_create(self.formatted2, "Red Dot", "dot")
  def Get(self):
    self.display_Calendar_widget()
    def Date():
      date_lbl.config(text = self.calendar.get_date())
    tk.Button(tab_search("Calendar"),text="Get Date",command=Date).place(x=250,y=200)
    date_lbl = tk.Label(tab_search("Calendar"),text="")
    date_lbl.place(x=250,y=250)
  def start(self):
    #clicked_date = self.calendar.get_date()
    #tags = self.calendar.tag_names(self.date)
    self.add_event()
    #tk.Button(tab_search("Calendar"),text="Confirm event",command=clicked).place(x=350,y=200)

rn the add_event method changes the background from red to blue of that date permanently. Firstly I want it to just add a small coloured circle instead. and I want it to add a small coloured circle next to the other one if that date already has a coloured circle or just add one if it doesn't. I also want to know how to ACC work the "do" function, like how to get a function to be run when an event that has been created is clicked by the user.

0

There are 0 best solutions below