Is there a way to make an AboutDialogInfo/AboutBox window modal? I haven't been able to find it anywhere in the wxPyDocs or wx docs. Currently, when the AboutBox is open, I can still interact with the main window and open as many about boxes as I want, which doesn't seem like it should be the default behavior.
Here is some sample Python code:
PHP Code:
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
self.bg = wx.Panel(self, -1)
about_button = wx.Button(self.bg, -1, "About")
wx.EVT_BUTTON(about_button, -1, self.ShowAbout)
self.about = wx.AboutDialogInfo()
def ShowAbout(self, event):
wx.AboutBox(self.about)
class MyApp(wx.App):
def OnInit(self):
frame = MainWindow(None, -1, "Test")
frame.Show()
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
and sample C++ code:
PHP Code:
#include <wx/wx.h>
#include <wx/aboutdlg.h>
class MainWindow : public wxFrame
{
public:
MainWindow(const wxString& title);
void ShowAbout(wxCommandEvent& event);
private:
wxAboutDialogInfo about;
};
MainWindow::MainWindow(const wxString& title) : wxFrame(NULL, -1, title)
{
wxPanel *bg = new wxPanel(this);
wxButton *about_button = new wxButton(bg, -1, _T("About"));
about_button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainWindow::ShowAbout), 0, this);
}
void MainWindow::ShowAbout(wxCommandEvent& event)
{
wxAboutBox(about);
}
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MainWindow *frame = new MainWindow(_T("test"));
frame->Show();
SetTopWindow(frame);
return true;
}
Bookmarks