| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -78,6 +78,23 @@ def new_figure_manager(num, *args, **kwargs): | |
| FigureClass = kwargs.pop('FigureClass', Figure) | ||
| figure = FigureClass(*args, **kwargs) | ||
| window = Tk.Tk() | ||
|
|
||
| if Tk.TkVersion >= 8.5: | ||
| # put a mpl icon on the window rather than the default tk icon. Tkinter | ||
| # doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto | ||
| # command which we call directly. Source: | ||
| # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html | ||
| icon_fname = os.path.join(rcParams['datapath'], 'images', 'matplotlib.gif') | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt looks like matplotlib.gif didn't get committed. I tried changing this to .png -- it appears that Tkinter doesn't support png, so we'll need to include a gif version of the regular matplotlib icon.
Sorry, something went wrong.
All reactions
|
||
| icon_img = Tk.PhotoImage(file=icon_fname) | ||
| try: | ||
| window.tk.call('wm', 'iconphoto', window._w, icon_img) | ||
| except (SystemExit, KeyboardInterrupt): | ||
| # re-raise exit type Exceptions | ||
| raise | ||
| except: | ||
| # log the failure, but carry on | ||
| verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1]) | ||
|
|
||
| canvas = FigureCanvasTkAgg(figure, master=window) | ||
| figManager = FigureManagerTkAgg(canvas, num, window) | ||
| if matplotlib.is_interactive(): | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,5 @@ | ||
| from __future__ import division, print_function | ||
| """ | ||
|
|
||
| backend_wx.py | ||
|
|
||
| A wxPython backend for matplotlib, based (very heavily) on | ||
| backend_template.py and backend_gtk.py | ||
|
|
||
| Expand All | @@ -18,14 +15,17 @@ | |
|
|
||
| """ | ||
|
|
||
| cvs_id = '$Id$' | ||
| import sys | ||
| import os | ||
| import os.path | ||
| import math | ||
| import StringIO | ||
| import weakref | ||
| import warnings | ||
|
|
||
|
|
||
| import sys, os, os.path, math, StringIO, weakref, warnings | ||
| import numpy as np | ||
|
|
||
|
|
||
|
|
||
| # Debugging settings here... | ||
| # Debug level set here. If the debug level is less than 5, information | ||
| # messages (progressively more info for lower value) are printed. In addition, | ||
| Expand Down Expand Up | @@ -188,7 +188,6 @@ def __init__(self, parent, *args, **kwargs): | |
|
|
||
| # Unbinding causes Wx to stop for some reason. Disabling for now. | ||
| # def __del__(self): | ||
| # import wx | ||
| # TimerBase.__del__(self) | ||
| # self.parent.Bind(wx.EVT_TIMER, None, self._timer) | ||
|
|
||
| Expand Down Expand Up | @@ -410,7 +409,6 @@ def get_gc(self): | |
| assert self.gc != None, "gc must be defined" | ||
| return self.gc | ||
|
|
||
|
|
||
| def get_wx_font(self, s, prop): | ||
| """ | ||
| Return a wx font. Cache instances in a font dictionary for | ||
| Expand Down Expand Up | @@ -448,14 +446,14 @@ def get_wx_font(self, s, prop): | |
|
|
||
| return font | ||
|
|
||
|
|
||
| def points_to_pixels(self, points): | ||
| """ | ||
| convert point measures to pixes using dpi and the pixels per | ||
| inch of the display | ||
| """ | ||
| return points*(PIXELS_PER_INCH/72.0*self.dpi/72.0) | ||
|
|
||
|
|
||
| class GraphicsContextWx(GraphicsContextBase): | ||
| """ | ||
| The graphics context provides the color, line styles, etc... | ||
| Expand Down Expand Up | @@ -627,6 +625,7 @@ def get_wxcolour(self, color): | |
| a *= 255 | ||
| return wx.Colour(red=int(r), green=int(g), blue=int(b), alpha=int(a)) | ||
|
|
||
|
|
||
| class FigureCanvasWx(FigureCanvasBase, wx.Panel): | ||
| """ | ||
| The FigureCanvas contains the figure and does event handling. | ||
| Expand Down Expand Up | @@ -1421,7 +1420,7 @@ def _create_wx_app(): | |
| # retain a reference to the app object so it does not get garbage | ||
| # collected and cause segmentation faults | ||
| _create_wx_app.theWxApp = wxapp | ||
|
|
||
|
|
||
| def draw_if_interactive(): | ||
| """ | ||
| Expand Down Expand Up | @@ -1512,6 +1511,15 @@ def __init__(self, num, fig): | |
| self.Fit() | ||
|
|
||
| self.canvas.SetMinSize((2, 2)) | ||
|
|
||
| # give the window a matplotlib icon rather than the stock one. | ||
| # This is not currently working on Linux and is untested elsewhere. | ||
| #icon_path = os.path.join(matplotlib.rcParams['datapath'], | ||
| # 'images', 'matplotlib.png') | ||
| #icon = wx.IconFromBitmap(wx.Bitmap(icon_path)) | ||
| # for xpm type icons try: | ||
| #icon = wx.Icon(icon_path, wx.BITMAP_TYPE_XPM) | ||
| #self.SetIcon(icon) | ||
|
|
||
| self.figmgr = FigureManagerWx(self.canvas, num, self) | ||
|
|
||
| Expand Down Expand Up | @@ -1559,15 +1567,14 @@ def Destroy(self, *args, **kwargs): | |
| wxapp.Yield() | ||
| return True | ||
|
|
||
|
|
||
| class FigureManagerWx(FigureManagerBase): | ||
| """ | ||
| This class contains the FigureCanvas and GUI frame | ||
|
|
||
| It is instantiated by GcfWx whenever a new figure is created. GcfWx is | ||
| responsible for managing multiple instances of FigureManagerWx. | ||
|
|
||
| NB: FigureManagerBase is found in _pylab_helpers | ||
|
|
||
| public attrs | ||
|
|
||
| canvas - a FigureCanvasWx(wx.Panel) instance | ||
| Expand Down Expand Up | @@ -1599,7 +1606,6 @@ def destroy(self, *args): | |
| DEBUG_MSG("destroy()", 1, self) | ||
| self.frame.Destroy() | ||
| #if self.tb is not None: self.tb.Destroy() | ||
| import wx | ||
| #wx.GetApp().ProcessIdle() | ||
| wx.WakeUpIdle() | ||
|
|
||
| Expand Down Expand Up | @@ -1939,11 +1945,6 @@ def set_history_buttons(self): | |
|
|
||
| class NavigationToolbarWx(wx.ToolBar): | ||
|
Comment thread
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityLooks like it was for an older interface or was a copy&paste error as it doesn't apply to this class.
Sorry, something went wrong.
All reactions
|
||
| def __init__(self, canvas, can_kill=False): | ||
| """ | ||
| figure is the Figure instance that the toolboar controls | ||
|
|
||
| win, if not None, is the wxWindow the Figure is embedded in | ||
| """ | ||
| wx.ToolBar.__init__(self, canvas.GetParent(), -1) | ||
| DEBUG_MSG("__init__()", 1, self) | ||
| self.canvas = canvas | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitywhy remove this exception handling? At the very least we could use the verbose.report() there to provide us information and then re-raise (or maybe add a message to the exception and let it bubble up?)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe comment needs removing, as far as I can see, this try block will never fail.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI actually agree that this exception handling is unnecessary -- it really shouldn't fail here, unless something is seriously wrong. This is different from the try/excepts above where if the icon can't be set we should continue along without an icon.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.