1
1
""" Defines the PlotWindow class.
5
4
from enthought.enable.api import Window
6
5
from enthought.chaco.shell.scaly_plot import ScalyPlot
9
class PlotWindow(wx.Frame):
10
""" A window for holding top-level plot containers.
12
Contains many utility methods for controlling the appearance of the
13
window, which mostly pass through to underlying WX calls.
16
def __init__(self, is_image=False, bgcolor="white",
17
image_default_origin="top left", *args, **kw):
19
kw.setdefault("size", (600,600))
20
wx.Frame.__init__(self, None, *args, **kw )
22
# Some defaults which should be overridden by preferences.
23
self.bgcolor = bgcolor
24
self.image_default_origin = image_default_origin
26
# Create an empty top-level container
28
top_container = self._create_top_img_container()
30
top_container = self._create_top_container()
32
# The PlotSession of which we are a part. We need to know this in order
33
# to notify it of our being closed, etc.
37
# Create the Enable Window object, and store a reference to it.
38
# (This will be handy later.) The Window requires a WX parent object
39
# as its first argument, so we just pass 'self'.
40
self.plot_window = Window(self, component=top_container)
42
# We'll create a default sizer to put our plot_window in.
43
sizer = wx.BoxSizer(wx.HORIZONTAL)
45
# Since Window is an Enable object, we need to get its corresponding
46
# WX control. This is stored in its ".control" attribute.
47
sizer.Add(self.plot_window.control, 1, wx.EXPAND)
49
# Hook up event handlers for destroy, etc.
50
wx.EVT_WINDOW_DESTROY(self, self._on_window_close)
52
# More WX boilerplate.
54
self.SetAutoLayout(True)
58
def get_container(self):
59
return self.plot_window.component
61
def set_container(self, container):
62
self.plot_window.component = container
64
def iconize(self, iconize):
65
"""Iconizes the window if *iconize* is True.
69
def maximize(self, maximize):
70
""" If *maximize* is True, maximizes the window size; restores if False.
72
self.Maximize(maximize)
74
def set_size(self, width, height):
75
self.SetSize((width, height))
77
def set_title(self, title):
80
def raise_window(self):
81
"""Raises this window to the top of the window hierarchy.
88
# This is a Python property because this is not a HasTraits subclass.
89
container = property(get_container, set_container)
91
#------------------------------------------------------------------------
93
#------------------------------------------------------------------------
95
def _create_top_container(self):
104
def _create_top_img_container(self):
108
bgcolor=self.bgcolor,
110
default_origin=self.image_default_origin,
115
def _on_window_close(self, event):
118
ndx = self.session.windows.index(self)
119
self.session.del_window(ndx)
7
from enthought.etsconfig.api import ETSConfig
9
if ETSConfig.toolkit == "wx":
12
class PlotWindow(wx.Frame):
13
""" A window for holding top-level plot containers.
15
Contains many utility methods for controlling the appearance of the
16
window, which mostly pass through to underlying WX calls.
19
def __init__(self, is_image=False, bgcolor="white",
20
image_default_origin="top left", *args, **kw):
22
kw.setdefault("size", (600,600))
23
wx.Frame.__init__(self, None, *args, **kw )
25
# Some defaults which should be overridden by preferences.
26
self.bgcolor = bgcolor
27
self.image_default_origin = image_default_origin
29
# Create an empty top-level container
31
top_container = self._create_top_img_container()
33
top_container = self._create_top_container()
35
# The PlotSession of which we are a part. We need to know this in order
36
# to notify it of our being closed, etc.
40
# Create the Enable Window object, and store a reference to it.
41
# (This will be handy later.) The Window requires a WX parent object
42
# as its first argument, so we just pass 'self'.
43
self.plot_window = Window(self, component=top_container)
45
# We'll create a default sizer to put our plot_window in.
46
sizer = wx.BoxSizer(wx.HORIZONTAL)
48
# Since Window is an Enable object, we need to get its corresponding
49
# WX control. This is stored in its ".control" attribute.
50
sizer.Add(self.plot_window.control, 1, wx.EXPAND)
52
# Hook up event handlers for destroy, etc.
53
wx.EVT_WINDOW_DESTROY(self, self._on_window_close)
55
# More WX boilerplate.
57
self.SetAutoLayout(True)
61
def get_container(self):
62
return self.plot_window.component
64
def set_container(self, container):
65
self.plot_window.component = container
67
def iconize(self, iconize):
68
"""Iconizes the window if *iconize* is True.
72
def maximize(self, maximize):
73
""" If *maximize* is True, maximizes the window size; restores if False.
75
self.Maximize(maximize)
77
def set_size(self, width, height):
78
self.SetSize((width, height))
80
def set_title(self, title):
83
def raise_window(self):
84
"""Raises this window to the top of the window hierarchy.
91
# This is a Python property because this is not a HasTraits subclass.
92
container = property(get_container, set_container)
94
#------------------------------------------------------------------------
96
#------------------------------------------------------------------------
98
def _create_top_container(self):
102
bgcolor=self.bgcolor,
107
def _create_top_img_container(self):
111
bgcolor=self.bgcolor,
113
default_origin=self.image_default_origin,
118
def _on_window_close(self, event):
121
ndx = self.session.windows.index(self)
122
self.session.del_window(ndx)
126
elif ETSConfig.toolkit == "qt4":