Click here to Skip to main content
15,357,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to select data from the sqllite3 database and insert them into the tkcalendar so the user can insert his event info (registration_check_date, car_type) and view them by clicking on the calendar specific colored date cell, I had converted the selected database data into a tuple, so it's can be inserted as a colored event cell in the calendar but the only info I get is the date when I clicked in the event cell, is there a way to get the date and car_type in a label.

What I have tried:

Python
from tkinter import *
from tkinter import ttk
import datetime
from tkcalendar import DateEntry,Calendar

fuction to get the event date(is there a way to get the other info)
def grad_date(self, event):
  self.eventl.config(text="Selected Date is: " + self.buyingcarsrigcal.get_date())

self.events = self.cursorObj.execute('SELECT registration_check_date, car_type FROM buying_rigistration_date order by registration_check_date') self.buying_registrationdates_event_output=self.cursorObj.fetchall() self.eventdict=dict(self.buying_registrationdates_event_output)

self.buyingcarsrigcal = Calendar(self.buyingcars_calendar_frame, selectmode='day',year=2022, month=1,day=1) self.buyingcarsrigcal.pack(pady=20, fill="both", expand=True)

for k in self.eventdict.keys():
   date = datetime.strptime(k, "%m-%d-%Y").date()
   self.buyingcarsrigcal.calevent_create(date, self.eventdict[k][0], 
   self.eventdict[k][1])

self.eventl = Label(self.buyingcars_calendar_frame, text="") self.eventl.pack(pady=20)

self.buyingcarsrigcal.bind("<<calendarselected>>",self.grad_date)
Posted
Updated 28-Apr-22 8:37am
v7
Comments
Richard MacCutchan 27-Apr-22 3:50am
   
Instead of posting the same thing twice, you should explain what the problem is.
asaad kittaneh 27-Apr-22 11:28am
   
Thank you for alerting me, now it's better
asaad kittaneh 30-Apr-22 21:14pm
   
can you help?
Richard MacCutchan 1-May-22 3:04am
   
With what? You have not explained what the problem is.
asaad kittaneh 2-May-22 22:03pm
   
I am trying to insert specific events in the calendar and these events will be selected from the database table and every row
including an event and date I succeed with inserting dates into the calendar but my goal is to insert the date and the event, not just the date, so when the user clicked on the colored calendar date cell, the GUI displays the date and event that is fetched from the DB row that including the specific date.
my problem: is that I don't know how to display the event and the date in the self.event label, it only shows the selected date.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900