FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/user_interfaces/embedding_in_wx2.py at master · feisuo/matplotlib · GitHub
feisuo
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
user_interfaces
/
embedding_in_wx2.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (55 loc) · 2.12 KB
Breadcrumbs
matplotlib
/
examples
/
user_interfaces
/
embedding_in_wx2.py
Copy path
File metadata and controls
74 lines (55 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
An example of how to use wx or wxagg in an application with the new
toolbar - comment out the setA_toolbar line for no toolbar
"""
# matplotlib requires wxPython 2.8+
# set the wxPython version in lib\site-packages\wx.pth file
# or if you have wxversion installed un-comment the lines below
#import wxversion
#wxversion.ensureMinimal('2.8')
from
numpy
import
arange
,
sin
,
pi
import
matplotlib
# uncomment the following to use wx rather than wxagg
#matplotlib.use('WX')
#from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
# comment out the following to use wx rather than wxagg
matplotlib
.
use
(
'WXAgg'
)
from
matplotlib
.
backends
.
backend_wxagg
import
FigureCanvasWxAgg
as
FigureCanvas
from
matplotlib
.
backends
.
backend_wx
import
NavigationToolbar2Wx
from
matplotlib
.
figure
import
Figure
import
wx
import
wx
.
lib
.
mixins
.
inspection
as
WIT
class
CanvasFrame
(
wx
.
Frame
):
def
__init__
(
self
):
wx
.
Frame
.
__init__
(
self
,
None
,
-
1
,
'CanvasFrame'
,
size
=
(
550
,
350
))
self
.
figure
=
Figure
()
self
.
axes
=
self
.
figure
.
add_subplot
(
111
)
t
=
arange
(
0.0
,
3.0
,
0.01
)
s
=
sin
(
2
*
pi
*
t
)
self
.
axes
.
plot
(
t
,
s
)
self
.
canvas
=
FigureCanvas
(
self
,
-
1
,
self
.
figure
)
self
.
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
sizer
.
Add
(
self
.
canvas
,
1
,
wx
.
LEFT
|
wx
.
TOP
|
wx
.
EXPAND
)
self
.
SetSizer
(
self
.
sizer
)
self
.
Fit
()
self
.
add_toolbar
()
# comment this out for no toolbar
def
add_toolbar
(
self
):
self
.
toolbar
=
NavigationToolbar2Wx
(
self
.
canvas
)
self
.
toolbar
.
Realize
()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
self
.
sizer
.
Add
(
self
.
toolbar
,
0
,
wx
.
LEFT
|
wx
.
EXPAND
)
# update the axes menu on the toolbar
self
.
toolbar
.
update
()
# alternatively you could use
#class App(wx.App):
class
App
(
WIT
.
InspectableApp
):
def
OnInit
(
self
):
'Create the main window and insert the custom frame'
self
.
Init
()
frame
=
CanvasFrame
()
frame
.
Show
(
True
)
return
True
app
=
App
(
0
)
app
.
MainLoop
()
Back
|
FazBrowse Home
|
New Git URL