Setup window before main window

I want my app to put up a setup window if it is not configured. When that window closes, it should up the regular window (which depends on the configuration).

Here is what I’m trying:

if options.configure:

app = SettingsApp(False)

app.MainLoop() # blocks until window closes

app.Destroy()

app = App(False)

app.MainLoop()

It basically works, but there is a weird bug. I redirect stdout to appear in the main window. But that doesn’t work if the setup window was used. The code sets up stdout like it should, but nothing gets redirected.

Is there App state left around that app.Destroy() wouldn’t clean up?

Is there a better way to do this?

Thanks,

-Dan

P.S. Here is the redirect code. It pretends to be a file, but posts to a text window.

class RedirectText(object):

def init(self, control):

self.out = control

def write(self, string):

wx.PostEvent(self.out, AppendConsoleEvent(text=string))

I want my app to put up a setup window if it is not configured. When that window closes, it should up the regular window (which depends on the configuration).

Here is what I’m trying:

if options.configure:

app = SettingsApp(False)

app.MainLoop() # blocks until window closes

app.Destroy()

app = App(False)

app.MainLoop()

I’m not sure why, but one App per python process is a good rule of thumb. So what I’d do is something like:

Create the app.

Create the main frame

Hide the main frame

Check for config

If config, Show() main frame

Else, create and show() config frame

App.MainLoop

Then have the config frame Show() the main frame when done.

Chris

···

On Aug 28, 2013, at 4:43 PM, Dan Christian dchristian@google.com wrote:

It basically works, but there is a weird bug. I redirect stdout to appear in the main window. But that doesn’t work if the setup window was used. The code sets up stdout like it should, but nothing gets redirected.

Is there App state left around that app.Destroy() wouldn’t clean up?

Is there a better way to do this?

Thanks,

-Dan

P.S. Here is the redirect code. It pretends to be a file, but posts to a text window.

class RedirectText(object):

def init(self, control):

self.out = control

def write(self, string):

wx.PostEvent(self.out, AppendConsoleEvent(text=string))

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Hi,

I would almost do the same thing as Chris, but I tend to be even more proactive. I would do something like the following:

Create the App
In the init for the frame (or even the panel class), check for the config. If no config, show a config dialog. Else, load config and load the frame/panel as appropriate.
app.MainLoop

I’ve used this approach with login dialogs and it works pretty well.

  • Mike