I want to display (read only) the date and time of current user login and
the date and time of that user's last login. I find the wx.DateTime() widget
but am not sure how to use it. Are there examples somewhere? I don't see one
in the 3.0.0.0 Main.py demo. Any class for this already written and
available for use by others?
I think that I need wx.DateTimeFromDMY() and wx.SetToCurrent() Or, Now(). How do I
size or style widgets for these?
Since I've not before extracted system dates or times for an application
I'm starting from scratch here.
Hi Rich. The wx.DateTime() class is not a widget, but an object that
stores a time, like the Python datetime.datetime object. The recommended
thing to do is to use a Python object if one exists instead of a wxPython
object, so you might want to try to use Python's datetime module for
representing the time. However the TimeCtrl (see below) expects to be fed
a wx.DateTime, so maybe it's not worth that, or you could write a function
that converts one to the other, etc. There is also the arrow package for
time, which I've heard good things about (Google for it), but may be
overkill for your needs.
A widget that can show the time in a "12:04:01" kind of way is a TimeCtrl
(wx.lib.masked.timectrl.TimeCtrl). Maybe if you use the Demo and look at
that widget that can get you on the right track. Or you could just show it
in any textual control, like a TextCtrl or staticText. Don't forget the
date--there is a datepicker ctrl for that as well.
Che
···
On Wed, Jul 16, 2014 at 8:11 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
I want to display (read only) the date and time of current user login and
the date and time of that user's last login. I find the wx.DateTime()
widget
but am not sure how to use it. Are there examples somewhere? I don't see
one
in the 3.0.0.0 Main.py demo. Any class for this already written and
available for use by others?
The wx.DateTime() class is not a widget, but an object
Che,
I did not write the message well. I was thinking of a wx.TextCtrl()
displaying the formatted date and time. Long day; high temperature ~90F and
my house (with my office) is not air conditioned.
... that stores a time, like the Python datetime.datetime object. The recommended thing to do is to use a Python object if one exists
instead of a wxPython object, so you might want to try to use Python's
datetime module for representing the time. However the TimeCtrl (see
below) expects to be fed a wx.DateTime, so maybe it's not worth that, or
you could write a function that converts one to the other, etc. There is
also the arrow package for time, which I've heard good things about
(Google for it), but may be overkill for your needs.
I know of the python datetime module, but did not find the TimeCtrl in the
demos.
A widget that can show the time in a "12:04:01" kind of way is a TimeCtrl
(wx.lib.masked.timectrl.TimeCtrl). Maybe if you use the Demo and look at
that widget that can get you on the right track.
I'll look again for it. I saw a reference, somewhere, to masked TextCtrl
but it had no explanation of how to define the masks. More research will
surely turn up that information.
Or you could just show it in any textual control, like a TextCtrl or
staticText. Don't forget the date--there is a datepicker ctrl for that as
well.
I found the DateCtrl but not the equivalent for time. From what you write
I need two widgets: one for the date the other for the time. That'll work
for me.
Rich,
Since you are only looking to a date/time simply
format it as a string and display it in either a static text or a
text control set to read only - you do not need masked input as it
is read only and you don’t need the user to be able to click on a
different date or select a different time so the widgets are not
really needed.
Gadget/Steve
···
On 17/07/14 03:02, Rich Shepard wrote:
On Wed, 16 Jul 2014, C M wrote:
The wx.DateTime() class is not a widget,
but an object
Che,
I did not write the message well. I was thinking of a
wx.TextCtrl()
displaying the formatted date and time. Long day; high temperature
~90F and
my house (with my office) is not air conditioned.
... that stores a time, like the Python
datetime.datetime object. The recommended thing to do is to use
a Python object if one exists
instead of a wxPython object, so you might want to try to use
Python’s
datetime module for representing the time. However the TimeCtrl
(see
below) expects to be fed a wx.DateTime, so maybe it's not worth
that, or
you could write a function that converts one to the other, etc.
There is
also the arrow package for time, which I've heard good things
about
(Google for it), but may be overkill for your needs.
I know of the python datetime module, but did not find the
TimeCtrl in the
demos.
A widget that can show the time in a
“12:04:01” kind of way is a TimeCtrl
(wx.lib.masked.timectrl.TimeCtrl). Maybe if you use the Demo and
look at
that widget that can get you on the right track.
I'll look again for it. I saw a reference, somewhere, to masked
TextCtrl
but it had no explanation of how to define the masks. More
research will
surely turn up that information.
Or you could just show it in any textual
control, like a TextCtrl or
staticText. Don't forget the date--there is a datepicker ctrl
for that as
well.
I found the DateCtrl but not the equivalent for time. From what
you write
I need two widgets: one for the date the other for the time.
I thought that might be the case, just like formatting currency for
display.
Thanks for clarifying the issue,
Rich
···
On Thu, 17 Jul 2014, Steve Barnes wrote:
Since you are only looking to *display* a date/time simply format it as a
string and display it in either a static text or a text control set to
read only - you do not need masked input as it is read only and you don't
need the user to be able to click on a different date or select a
different time so the widgets are not really needed.
I wrote an app that has a “clock” in the status bar, to obtain the time for it I do the following:
The import:
from datetime import datetime as DT
In a function that is is run by the app:
timestamp = DT.now().strftime(“%I:%M:%S %p”) # Grabs the current time and sets it to s specific format
self._sbar.SetStatusText(ts, 1) # Applies it to the right hand side of my split status bar
The code above is called every 1 second using wx.PyTimer, though I am currently looking for any possible solution to improve it.
You could use a similar setup and have the time applied to just about anything that accepts text, (IE: Button, static text, read-only text control, etc) instead of the status bar. The app I provided the code snippets from is used for clocking in and out at work. Whenever I clock in/out for the day or lunch it takes the time stamp of each action, applies it to read-only text controls and logs to a log file.
···
On Thursday, July 17, 2014 8:47:04 AM UTC-4, fuzzydoc wrote:
On Thu, 17 Jul 2014, Steve Barnes wrote:
Since you are only looking to display a date/time simply format it as a
string and display it in either a static text or a text control set to
read only - you do not need masked input as it is read only and you don’t
need the user to be able to click on a different date or select a
different time so the widgets are not really needed.
Gadget/Steve,
I thought that might be the case, just like formatting currency for
In my application I need to have a record of the user's current login date
and time and his/her last login date and time. That's for an audit trail of
who entered data when.
Rich
···
On Thu, 17 Jul 2014, Mike Stover wrote:
I wrote an app that has a "clock" in the status bar, to obtain the time for
it I do the following:
The app I provided the code snippets from is used for clocking in and out
at work. Whenever I clock in/out for the day or lunch it takes the time
stamp of each action, applies it to read-only text controls and logs to a
log file.