Re: Calendar compopnent

Alex Tweedly <[email protected]>
Newsgroups gmane.comp.python.pythoncard
Message-ID <[email protected]>
hwg wrote:
> I'm using the Calendar component to enter dates into a text field.  
> (Thanks to the example Calendar Dialog provided by Alex Tweedly on his 
> home page). 
>
> I just want to change the functionality a bit, and I'm not sure how to 
> do it.
>
> When the Calendar pops up, it is always sitting at today's date.  I 
> would like it to be sitting at whatever date was already in the text 
> box.  How do I change the "current date" on the Calendar programatically?
>
Certainly not the only way,
possibly not the best way,
but you can do something very like this .....

I made modifications to caldialog.py  I think to the same version as is 
on the web site) -  here's notes and the relevant section that I changed

1. add the import of datetime
2. added year, month and day parameters to the __init__
3. set the date as soon as the custom dialog is created  (i.e. before it 
is displayed)

and then you'll need to make changes to the calling code to extract the 
date from the text box and pass it in ...

import wx
import datetime

class CalDialog(model.CustomDialog):
    def __init__(self, parent, txt='', y=2006, m=1, d=1):
        model.CustomDialog.__init__(self, parent)
        self.components.Calendar1.PySetDate(datetime.date(y,m,d))


    def on_Calendar1_mouseDoubleClick(self, event):
        self.EndModal(wx.ID_OK)
       
    def on_btnOK_mouseClick(self, event):
        print "in ok click"
        event.Skip()
       
def calDialog(parent, y=2006, m=1, d=2):
    dlg = CalDialog(parent, y=y, m=m, d=d)
    result = dlg.showModal()



-- 

Alex Tweedly      mailto:[email protected]      www.tweedly.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Pythoncard-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.