When I get a wxDateTime from a control, how do I translate it to a
python time?
Leazen
When I get a wxDateTime from a control, how do I translate it to a
python time?
Leazen
Leazen,
A simple way would be to take the GetXxxxx methods (GetMonth, GetDay,
GetYear etc)
create a tuple out of it (in the same order that time.localtime does) then
call time.mktime passing that tuple in. It will then create a proper epoch
time for you. Or you could do other things with that tuple like call
strftime, etc.
-brett
-----Original Message-----
From: Leazen [mailto:leazen@uol.com.ar]
Sent: Tuesday, February 04, 2003 8:14 PM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] Simple wxDateTime question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
When I get a wxDateTime from a control, how do I translate it to a
python time?
Leazen
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
So there is no direct way to get this, right?
Thanks.
Leazen
Brett Humphreys wrote:
Leazen,
A simple way would be to take the GetXxxxx methods (GetMonth, GetDay,
GetYear etc)
create a tuple out of it (in the same order that time.localtime does) then
call time.mktime passing that tuple in. It will then create a proper
epoch
time for you. Or you could do other things with that tuple like call
strftime, etc.-brett
-----Original Message-----
From: Leazen [mailto:leazen@uol.com.ar]
Sent: Tuesday, February 04, 2003 8:14 PM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] Simple wxDateTime questionWhen I get a wxDateTime from a control, how do I translate it to a
python time?Leazen
Brett Humphreys wrote:
Leazen,
A simple way would be to take the GetXxxxx methods (GetMonth, GetDay,
GetYear etc)
create a tuple out of it (in the same order that time.localtime does) then
call time.mktime passing that tuple in. It will then create a proper epoch
time for you. Or you could do other things with that tuple like call
strftime, etc.
Or call GetTicks()
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Leazen,
There doesnt' seem to be. It is actually humorous, as I was using the
wxCalendar or the wxCalendarCtrl yesterday, and it turns out there is yet
another library of date like functions and features called CDate.
It would be nice if there was some way to make these all play real nice with
each other. However to answer your question, to my knowledge, no there is
no real simple solution.
-brett
-----Original Message-----
From: Leazen [mailto:leazen@uol.com.ar]
Sent: Wednesday, February 05, 2003 7:14 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Simple wxDateTime question
So there is no direct way to get this, right?
Thanks.
Leazen
Brett Humphreys wrote:
Leazen,
A simple way would be to take the GetXxxxx methods (GetMonth, GetDay,
GetYear etc)
create a tuple out of it (in the same order that time.localtime does) then
call time.mktime passing that tuple in. It will then create a proper
epoch
time for you. Or you could do other things with that tuple like call
strftime, etc.-brett
-----Original Message-----
From: Leazen [mailto:leazen@uol.com.ar]
Sent: Tuesday, February 04, 2003 8:14 PM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] Simple wxDateTime questionWhen I get a wxDateTime from a control, how do I translate it to a
python time?Leazen
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Rigth!!!! I missed that one. Thanks.
Leazen
Robin Dunn wrote:
Brett Humphreys wrote:
Leazen,
A simple way would be to take the GetXxxxx methods (GetMonth, GetDay,
GetYear etc)
create a tuple out of it (in the same order that time.localtime does)
then
call time.mktime passing that tuple in. It will then create a proper
epoch
time for you. Or you could do other things with that tuple like call
strftime, etc.Or call GetTicks()
Hello everybody,
I am trying to put a wxBitmap in the right corner of a wxFrame.
Untill now, I found out how to get the size of my image :
- imageSize = wxSize(self.image.GetWidth(), self.image.GetHeight())
I also found out how to get the wxFrame size
- frameSize = self.GetSize()
But this is not working:
- image.DrawBitmap(self.image,frameSize[0] - imageSize[0], frameSize[1] - 2*imageSize[1])
Is there someone who can help me???
Thank you
Yann
mainWindow.py (6.64 KB)
yann.malet wrote:
I am trying to put a wxBitmap in the right corner of a wxFrame.
Depending on what else you're putting in the frame, it may be easiest to use a wxStaticBitmap control to load and size and paint your bitmap, and then using sizers to place it properly on your wxFrame. If you need to do custom drawing in other parts of the frame, then create a wxPanel that does the custom drawing on its client area, and use those same sizers to place it on the frame. Otherwise, you can use other simple controls to present whatever else you need to present.
Jeff Shannon
Technician/Programmer
Credit International
yann.malet wrote:
Hello everybody,
I am trying to put a wxBitmap in the right corner of a wxFrame.
Some platforms (you don't mention what you are using...) don't allow any drawing on a wxFrame. You should create a wxWindow or wxPanel and draw on that, and put it in the frame.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Hello again,
Thank you for the advise I had a wxPanel in my wxFrame.
So now my code lool like this
mainWindow.py (6.38 KB)
------------------------------------------------------------------
#!/usr/bin/env python
from wxPython.wx import *
from wxPython.lib.anchors import LayoutAnchors
class MyFrame(wxFrame):
"""This class is the main window of my application"""
def __init__(self, parent, id, title):
wxFrame.__init__(self,parent, -4, title,style = wxDEFAULT_FRAME_STYLE)
## self.panel = wxPanel(self, -1, wxDefaultPosition,wxDefaultSize , wxSIMPLE_BORDER)
self.panel = wxPanel(self, -1, size=self.GetSize(),style = wxSIMPLE_BORDER)
self.panel.SetBackgroundColour(wxColour(255, 255, 255))
self.CreateStatusBar()
self.image = wxBitmap('/home/commun/scripts/python/photo/appli/V_0.03/resource/001_star_butterfly.xpm', wxBITMAP_TYPE_XPM)
butterfly = wxStaticBitmap(self.panel, -1, self.image)
butterfly.SetConstraints(LayoutAnchors(butterfly, 1, 0, 1, 1))
b = wxButton(self.panel, 100, ' Button ')
lc = wxLayoutConstraints()
lc.bottom.SameAs(self.panel, wxTop, 20)
lc.right.SameAs(self.panel, wxRight, 40)
lc.height.AsIs()
lc.width.AsIs()
b.SetConstraints(lc)
self.statTxt = wxStaticText(self, -1, "", wxPoint(20, 10))
self.connectedFlag = 0
-------------------------------------------------------------------------------------
But I still unable to put the butterfly in the right bottom corner.
I attached grab of the result windows and also my code.
Is it possible to get some advise to constraint the position of my wxBitmap (the butterfly) and the button.
Thank you
Robin Dunn wrote:
yann.malet wrote:
Hello everybody,
I am trying to put a wxBitmap in the right corner of a wxFrame.
Some platforms (you don't mention what you are using...) don't allow any drawing on a wxFrame. You should create a wxWindow or wxPanel and draw on that, and put it in the frame.
Thank you for your help.
As you can see in the atached document your advice help me to get a good looking application.
Now I am facing a new problem:
I give users the possibility of changing panel color using wxColourDialog() everything is working fine except that I have to manualy create an event (move the window, resize it) in order to get the chosen color in my panel.
How can I run it automatically at the end of my OnColor function?
Reagrds,
Yann
Robin Dunn wrote:
yann.malet wrote:
Hello again,
Thank you for the advise I had a wxPanel in my wxFrame.
So now my code lool like this
------------------------------------------------------------------
#!/usr/bin/env pythonfrom wxPython.wx import *
from wxPython.lib.anchors import LayoutAnchorsclass MyFrame(wxFrame):
"""This class is the main window of my application"""
def __init__(self, parent, id, title):
wxFrame.__init__(self,parent, -4, title,style = wxDEFAULT_FRAME_STYLE)## self.panel = wxPanel(self, -1, wxDefaultPosition,wxDefaultSize , wxSIMPLE_BORDER)
self.panel = wxPanel(self, -1, size=self.GetSize(),style = wxSIMPLE_BORDER)
self.panel.SetBackgroundColour(wxColour(255, 255, 255))self.CreateStatusBar()
self.image = wxBitmap('/home/commun/scripts/python/photo/appli/V_0.03/resource/001_star_butterfly.xpm', wxBITMAP_TYPE_XPM)
butterfly = wxStaticBitmap(self.panel, -1, self.image)
butterfly.SetConstraints(LayoutAnchors(butterfly, 1, 0, 1, 1))b = wxButton(self.panel, 100, ' Button ')
lc = wxLayoutConstraints()
lc.bottom.SameAs(self.panel, wxTop, 20)
lc.right.SameAs(self.panel, wxRight, 40)
lc.height.AsIs()
lc.width.AsIs()
b.SetConstraints(lc)
self.statTxt = wxStaticText(self, -1, "", wxPoint(20, 10))
self.connectedFlag = 0-------------------------------------------------------------------------------------
But I still unable to put the butterfly in the right bottom corner.
There are a couple problems, first of all, the LayoutAnchors use the current position of the control in calculating the how to set the anchors, so you need to position the butterlfy how you want it to begin with:
butterfly.SetPosition((self.panel.GetSize()[0]-self.image.GetWidth(),
self.panel.GetSize()[1]-self.image.GetHeight()))Next you are setting the anchor on both the left and right sides as well as the bottom, you probably only want the right and bottom:
butterfly.SetConstraints(
LayoutAnchors(butterfly, top=0, left=0, bottom=1, right=1))Next, you have to tell the panel that it should do autolayout:
self.panel.SetAutoLayout(true)
Finally, the static text you add at the end as a child of the frame is making it so the panel is no longer the only child of the frame ans so the frame isn't resizing it to fill the frame, so remove that line.
yann.malet wrote:
Thank you for your help.
As you can see in the atached document your advice help me to get a good looking application.
Now I am facing a new problem:
I give users the possibility of changing panel color using wxColourDialog() everything is working fine except that I have to manualy create an event (move the window, resize it) in order to get the chosen color in my panel.
How can I run it automatically at the end of my OnColor function?
Call the Refresh() method.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Please don't post 600K to the list.
Niki Spahiev