How to create new toplevel TaskWindow?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to create new toplevel TaskWindow?

Rob McMullen
I'm trying to make a multi-window application but I can't figure out the correct way to create a new toplevel window. From a Task, I'm using

        window = self.window.application.create_window()
        task = FrameworkTask()
        window.add_task(task)
        window.activate_task(task)
        window.show(True)

which does show a new window on screen, but it doesn't add the window to the TasksApplication.windows Trait. This causes a problem when exiting the application because only the initial window (created at application start) is destroyed.

What's the recommended way to create a TaskWindow? I'm stumped.

Thanks,

Rob

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to create new toplevel TaskWindow?

Pietro Berkes
Hi Rob,

I think the main problem is that `window.show(True)` does not fire the events that surround the opening of a window. You should use `window.open()` instead.

Best,
Pietro


On Fri, Feb 7, 2014 at 5:22 AM, Rob McMullen <[hidden email]> wrote:
I'm trying to make a multi-window application but I can't figure out the correct way to create a new toplevel window. From a Task, I'm using

        window = self.window.application.create_window()
        task = FrameworkTask()
        window.add_task(task)
        window.activate_task(task)
        window.show(True)

which does show a new window on screen, but it doesn't add the window to the TasksApplication.windows Trait. This causes a problem when exiting the application because only the initial window (created at application start) is destroyed.

What's the recommended way to create a TaskWindow? I'm stumped.

Thanks,

Rob

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev




--
Pietro Berkes
Scientific software developer
Enthought UK


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to create new toplevel TaskWindow?

Rob McMullen
On Fri, Feb 7, 2014 at 2:44 AM, Pietro Berkes <[hidden email]> wrote:
I think the main problem is that `window.show(True)` does not fire the events that surround the opening of a window. You should use `window.open()` instead.

Thanks! That fixes it. The window shows up in the TasksApplication.windows Trait.

I did notice a problem where if I don't specify a layout for the new window and call Application.exit(), I get the following exception:

Traceback (most recent call last):
  File "/data/home/rob/src/enthought/envisage/envisage/ui/tasks/tasks_application.py", line 247, in exit
    self._prepare_exit()
  File "/data/home/rob/src/enthought/envisage/envisage/ui/tasks/tasks_application.py", line 303, in _prepare_exit
    self._save_state()
  File "/data/home/rob/src/enthought/envisage/envisage/ui/tasks/tasks_application.py", line 351, in _save_state
    window_layouts = [ w.get_window_layout() for w in self.windows ]
  File "/data/home/rob/src/enthought/pyface/pyface/tasks/task_window.py", line 306, in get_window_layout
    size_state=self.size_state)
AttributeError: 'TaskWindow' object has no attribute 'size_state'

But when I specify an empty layout, e.g.

        window = self.create_window(layout=TaskWindowLayout())

it works fine. Admittedly it's a degenerate case, but I'll submit a patch since the docstring for create_window says that the layout is optional.

Rob

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to create new toplevel TaskWindow?

Rob McMullen

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev