Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On windows, mass import modal window is not closed upon import completion #281

Closed
DarkFenX opened this issue May 3, 2015 · 4 comments
Closed

Comments

@DarkFenX
Copy link
Member

DarkFenX commented May 3, 2015

Windows 8.1 x64
wxPython 3.0.2.0

I tracked it down to following code: https://github.com/DarkFenX/Pyfa/blob/wx3/gui/mainFrame.py#L587

    def fileImportCallback(self, info, fits=None):
        if info == -1:
            # Done processing
            self.progressDialog.Hide()
            self._openAfterImport(fits)
        elif info != self.progressDialog.message and info is not None:
            # New message, overwrite cached message and update
            self.progressDialog.message = info
            self.progressDialog.Pulse(info)
        else:
            # Simply Pulse() if we don't have anything else to do
            self.progressDialog.Pulse()

Hide() doesn't work on windows for some reason. I tried alternative functions (like Show(False)) and making window non-modal before closing, neither worked. Works as expected on linux. Might be some wx3 bug.

from time import sleep

import wxversion

wxversion.select('3.0')

import wx


class MainFrame(wx.Frame):

    def __init__(self):
        title = "test app"
        wx.Frame.__init__(self, None, wx.ID_ANY, title)
        self.button = wx.Button(self, label="MODAL", pos=(200, 325))
        self.Bind(wx.EVT_BUTTON, self.popModal, self.button)
        self.Show()

    def popModal(self, event):
        self.progressDialog = wx.ProgressDialog(
            "Test modal window",
            " "*100,
            parent=self,
            style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME
        )
        self.progressDialog.ShowModal()
        sleep(1)
        self.progressDialog.Hide()

app = wx.App(False)
MainFrame()
app.MainLoop()

This example doesn't work on linux, on both wx2.8 and wx3.0.1. Maybe i am not grasping concept of how wx should work.

@DarkFenX DarkFenX added the wx3 label May 3, 2015
@blitzmann
Copy link
Collaborator

This happens with any ProgressDialog issue. I believe I also was having compatibility issues with getting ride of it, which is why I went with Hide(). I think Destroy() didn't work on either Windows or Linux. I don't remember...

@blitzmann
Copy link
Collaborator

Destroy()ing rather than Hide()ing the progress dialog works great in windows on 2.8 and 3.0. The issue is that on Linux it tends to crash with IA__gtk_window_set_modal: assertion 'GTK_IS_WINDOW (window)' failed

This seems to be a problem that has been noted with people using a thread to callback to the progress dialog to update (such as we're doing here). I'll continue to look into it, but we might just use one or the other depending on platform. I have no idea how OS X handles it either...

ref: https://forums.wxwidgets.org/viewtopic.php?t=40764

@blitzmann
Copy link
Collaborator

http://stackoverflow.com/questions/30959844/wx-progressdialog-causing-seg-fault-and-or-gtk-is-window-failure-when-being-dest

https://groups.google.com/forum/#!topic/wxpython-users/dCuyi7pH9io

If these go to dead ends, I think we'll just switch off between Destroy and Hide depending on platform cause fuck it

blitzmann added a commit that referenced this issue Jun 25, 2015
@blitzmann
Copy link
Collaborator

Went ahead and made the commit. Haven't tested it on os x yet, though I assume it will work just as well

EDIT: Tested on OS X, works, but it's doing some funky things, see #306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants