I can make a window modal by calling window.MakeModal(), and I
can make a window modeless by calling window.MakeModal(False),
but how do I determine whether or not the window is already
modal/modeless, as there doesn't appear to be a
window.IsModal()?
I can make a window modal by calling window.MakeModal(), and I can make a window modeless by calling window.MakeModal(False), but how do I determine whether or not the window is already modal/modeless, as there doesn't appear to be a window.IsModal()?
>I can make a window modal by calling window.MakeModal(), and
> I can make a window modeless by calling
> window.MakeModal(False), but how do I determine whether or
> not the window is already modal/modeless, as there doesn't
> appear to be a
>window.IsModal()?
Maybe you can test whether the window is enabled.
No, not really. Both modeless and modal windows can be enabled
or disabled, separate from their modality setting.
I can make a window modal by calling window.MakeModal(), and I can make a window modeless by calling window.MakeModal(False), but how do I determine whether or not the window is already modal/modeless, as there doesn't appear to be a window.IsModal()?
MakeModal simply disables all other top level windows (see below,) so there is no simple property for IsModal to return. You could check the status of all other TLWs...
void wxWindowBase::MakeModal(bool modal)
{
// Disable all other windows
if ( IsTopLevel() )
{
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow *win = node->GetData();
if (win != this)
win->Enable(!modal);
node = node->GetNext();
}
}
}
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
MakeModal simply disables all other top level windows (see
below,) so there is no simple property for IsModal to return.
You could check the status of all other TLWs...
Let me get this straight. Say I have (pseudocode):
MakeModal simply disables all other top level windows (see
below,) so there is no simple property for IsModal to return.
You could check the status of all other TLWs...
Let me get this straight. Say I have (pseudocode):
Yes, it appears that way. And yes, I agree that it
shoudln't. Please enter a bug report about it.
I'll do that, but before I do, what do you think of wx.Dialog's
IsModal() and ShowModal() functions being moved to wx.Frame?
Now, I haven't really ever used those functions, nor have I
looked at the source code, but I've always thought it felt
wrong that those were defined in wx.Dialog and not more
generally.
And are there use-cases for making individual windows modal? I'm
thinking this is specifically frame-level functionality, not
window-level stuff.
Yes, it appears that way. And yes, I agree that it
shoudln't. Please enter a bug report about it.
I'll do that, but before I do, what do you think of wx.Dialog's IsModal() and ShowModal() functions being moved to wx.Frame?
Now, I haven't really ever used those functions, nor have I looked at the source code, but I've always thought it felt wrong that those were defined in wx.Dialog and not more generally.
IsModal probably could be, well, to wxTopLevelWindow anyway, (it's the base class of both wxDialog and wxFrame.) ShowModal implements it's own event loop and is very specific to wxDialog.
And are there use-cases for making individual windows modal? I'm thinking this is specifically frame-level functionality, not window-level stuff.
Yep, the current implementation of MakeModal does nothing if the window is not a top level window, so it could probably be moved to wxTopLevelWindow as well. It's not my call though.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
> Now, I haven't really ever used those functions, nor have I
> looked at the source code, but I've always thought it felt
> wrong that those were defined in wx.Dialog and not more
> generally.
IsModal probably could be, well, to wxTopLevelWindow anyway,
(it's the base class of both wxDialog and wxFrame.)
ShowModal implements it's own event loop and is very
specific to wxDialog.
But that is exactly what a modal frame should do: implement its
own event loop. Shouldn't it?
Perhaps I should just be basing my frames on wxDialog instead of
wxFrame, to take advantage of the modal event loop
capabilities.
> And are there use-cases for making individual windows
> modal? I'm thinking this is specifically frame-level
> functionality, not window-level stuff.
Yep, the current implementation of MakeModal does nothing if
the window is not a top level window, so it could probably be
moved to wxTopLevelWindow as well. It's not my call though.
Ok, this is the wrong forum to be discussing this stuff, but
perhaps if it comes up in your discussions with the wxWidgets
hackers you could be an advocate for these changes (getting rid
of MakeModal and making ShowModal and IsModal functions of
wxTopLevelWindow - I'm sure the wxDialog-specific stuff can be
carved out.).
I submitted something on this as a 'feature request' already.
I'm having trouble saving a bitmap on Windows using wxPython 2.5.1.5.
I have code that worked under wxPython 2.4.2.4 that draws a waveform diagram
and saves it as a bitmap file. I am in the process of trying to upgrade to
wxPython 2.5.1.5, as I am trying to develop on Windows and Mac OS/X
simultaneously. I have updated my code, changing all of my DrawLine methods
to DrawLineXY, and the code works fine on the Mac. However, the SaveFile
command dies on Windows (Win2K).
For example, If I run:
print 'WaveformGraphic: About to save Bitmap "%s"' % waveformFilename
theBitmap.SaveFile(waveformFilename, wx.BITMAP_TYPE_BMP)
print "WaveformGraphic: Bitmap saved"
the second print statement is never executed, and the bitmap file that is
created crashes my system if I try to look at it, taking 100% of my
processing time until I reboot and complaining of sharing violations if I
try to delete it.
If I use:
print 'WaveformGraphic: About to save JPEG "%s"' %
(waveformFilename[:-3]+'jpg')
theBitmap.SaveFile(waveformFilename[:-3]+'jpg', wx.BITMAP_TYPE_JPEG)
print "WaveformGraphic: JPEG saved"
instead, I get the JPEG graphic I expect.
Has anybody else run into this problem? Any ideas what I can do to work
around it, other than using JPEGs intead of Bitmaps?
Thanks,
David Woods, Ph.D.
Wisconsin Center for Education Research
University of Wisconsin, Madison http://www.transana.org
print 'WaveformGraphic: About to save Bitmap "%s"' % waveformFilename
theBitmap.SaveFile(waveformFilename, wx.BITMAP_TYPE_BMP)
print "WaveformGraphic: Bitmap saved"
the second print statement is never executed,
Is there any exception?
and the bitmap file that is
created crashes my system if I try to look at it, taking 100% of my
processing time until I reboot and complaining of sharing violations if I
try to delete it.
If I use:
print 'WaveformGraphic: About to save JPEG "%s"' %
(waveformFilename[:-3]+'jpg')
theBitmap.SaveFile(waveformFilename[:-3]+'jpg', wx.BITMAP_TYPE_JPEG)
print "WaveformGraphic: JPEG saved"
instead, I get the JPEG graphic I expect.
Has anybody else run into this problem?
Please enter a bug report about it.
Any ideas what I can do to work
around it, other than using JPEGs intead of Bitmaps?
Have you tried converting the wx.Bitmap to a wx.Image and then saving it
from there? That may work.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!