Results 1 to 7 of 7

Thread: [wxPython/wxWidegts] AboutDialogInfo & Modal

  1. #1
    Join Date
    May 2008
    Beans
    1,029

    Question [wxPython/wxWidegts] AboutDialogInfo/AboutBox Isn't Modal

    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__(selfparentidtitle):
            
    wx.Frame.__init__(selfparentidtitle)
            
            
    self.bg wx.Panel(self, -1)
            
            
    about_button wx.Button(self.bg, -1"About")
            
            
    wx.EVT_BUTTON(about_button, -1self.ShowAbout)
            
            
    self.about wx.AboutDialogInfo()
            
        
    def ShowAbout(selfevent):
            
    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 wxStringtitle);
        
    void ShowAbout(wxCommandEventevent);
      private:
        
    wxAboutDialogInfo about;
    };

    MainWindow::MainWindow(const wxStringtitle) : wxFrame(NULL, -1title)
    {
        
    wxPanel *bg = new wxPanel(this);

        
    wxButton *about_button = new wxButton(bg, -1_T("About"));

        
    about_button->Connect(wxEVT_COMMAND_BUTTON_CLICKEDwxCommandEventHandler(MainWindow::ShowAbout), 0this);
    }

    void MainWindow::ShowAbout(wxCommandEventevent)
    {
        
    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;

    Last edited by dodle; August 23rd, 2010 at 08:45 AM. Reason: Add C++ code

  2. #2
    Join Date
    May 2008
    Beans
    1,029

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    *bump*

  3. #3
    Join Date
    Apr 2010
    Location
    Ohio
    Beans
    51

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    I'm pretty sure that's GTK's fault. The native about panels are never modal as far as I've seen (check any Gnome application.) Of course, plenty of them still manage to keep you from opening multiples, but I don't know how to do that either without creating a custom dialog in wx.

  4. #4
    Join Date
    May 2008
    Beans
    1,029

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    Thanks, I guess I will just create a custom info dialog.

  5. #5
    Join Date
    May 2008
    Beans
    1,029

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    Quote Originally Posted by robots.jpg View Post
    I'm pretty sure that's GTK's fault. The native about panels are never modal as far as I've seen (check any Gnome application.) Of course, plenty of them still manage to keep you from opening multiples, but I don't know how to do that either without creating a custom dialog in wx.
    I don't think the problem is GTK. The following code examples both create a GTK about dialog that is modal:

    pygtk:
    PHP Code:
    import gtk

    class MainWindow(gtk.Window):
        
    def __init__(self):
            
    super(MainWindowself).__init__()
            
            
    self.connect("destroy"gtk.main_quit)
            
    self.set_size_request(250150)
            
    self.set_position(gtk.WIN_POS_CENTER)
            
            
    about gtk.Button("About")
            
    about.set_size_request(8025)
            
    about.connect("clicked"self.OnAbout)
            
            
    self.add(about)
            
            
    self.show_all()
        
        
    def OnAbout(selfwidget):
            
    about gtk.AboutDialog()
            
    about.run()
            
    about.destroy()


    MainWindow()
    gtk.main() 
    gtkmm:
    PHP Code:
    // about.h

    #include <gtkmm.h>

    class MainWindow : public Gtk::Window
    {

    public:
      
    MainWindow();
      
    virtual ~MainWindow();

    protected:
      
    //Signal handlers:
      
    void OnAbout();

      
    //Member widgets:
      
    Gtk::Button button_about;
    }; 
    PHP Code:
    // about.cpp

    #include "about.h"

    MainWindow::MainWindow()
    button_about("about")   // creates a new button with label "Hello World".
    {
      
    // Sets the border width of the window.
      
    set_border_width(10);

      
    // When the button receives the "clicked" signal, it will call the
      // on_button_clicked() method defined below.
      
    button_about.signal_clicked().connect(sigc::mem_fun(*this,
                  &
    MainWindow::OnAbout));

      
    // This packs the button into the Window (a container).
      
    add(button_about);

      
    // The final step is to display this newly created widget...
      
    show_all();
    }

    MainWindow::~MainWindow()
    {
    }

    void MainWindow::OnAbout()
    {
      
    Gtk::AboutDialog about;
      
    about.run();

    PHP Code:
    // main.cpp

    #include "about.h"

    int main (int argcchar *argv[])
    {
      
    Gtk::Main kit(argcargv);

      
    MainWindow test;
      
    //Shows the window and returns when it is closed.
      
    Gtk::Main::run(test);

      return 
    0;

    So I think the problem is in wx/wxPython.

    Edit: I forgot to mention in my first post that I am using wxGtk 2.8.10.1

  6. #6
    Join Date
    Apr 2010
    Location
    Ohio
    Beans
    51

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    All I can tell you is that wx.AboutBox() does create a modal dialog under MS Windows whether it calls the native or wxPython version. Under Ubuntu, it's not modal either way, so I assumed the difference there was GTK. Whatever it is, it's platform-specific.

  7. #7
    Join Date
    May 2008
    Beans
    1,029

    Re: [wxPython/wxWidegts] AboutDialogInfo & Modal

    Yes, you are right about that. I'm trying to update to wxGtk 2.8.11 to see if there is any difference. I doubt there will be since it is doesn't appear to be a major update.

    Edit: I found a bug report on this issue: http://trac.wxwidgets.org/ticket/8845, which has a couple of patches that [sort of] fix the problem. Though I don't know if they have been applied in newer versions of wx.
    Last edited by dodle; August 28th, 2010 at 12:02 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •