-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
wx backend changes for wxPython Phoenix #1974
New issue
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
Changes from all commits
d4f9392
18f8ef6
165f2a2
4d5ae20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,8 +666,6 @@ class FigureCanvasWx(FigureCanvasBase, wx.Panel): | |
wx.WXK_DELETE : 'delete', | ||
wx.WXK_HOME : 'home', | ||
wx.WXK_END : 'end', | ||
wx.WXK_PRIOR : 'pageup', | ||
wx.WXK_NEXT : 'pagedown', | ||
wx.WXK_PAGEUP : 'pageup', | ||
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. Looks like these don't exist any more in wx? 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. Hi, On 07/05/2013 12:58, Phil Elson wrote:
Werner |
||
wx.WXK_PAGEDOWN : 'pagedown', | ||
wx.WXK_NUMPAD0 : '0', | ||
|
@@ -690,8 +688,6 @@ class FigureCanvasWx(FigureCanvasBase, wx.Panel): | |
wx.WXK_NUMPAD_RIGHT : 'right', | ||
wx.WXK_NUMPAD_DOWN : 'down', | ||
wx.WXK_NUMPAD_LEFT : 'left', | ||
wx.WXK_NUMPAD_PRIOR : 'pageup', | ||
wx.WXK_NUMPAD_NEXT : 'pagedown', | ||
wx.WXK_NUMPAD_PAGEUP : 'pageup', | ||
wx.WXK_NUMPAD_PAGEDOWN : 'pagedown', | ||
wx.WXK_NUMPAD_HOME : 'home', | ||
|
@@ -735,7 +731,10 @@ def do_nothing(*args, **kwargs): | |
|
||
|
||
# Create the drawing bitmap | ||
self.bitmap =wx.EmptyBitmap(w, h) | ||
if 'phoenix' in wx.PlatformInfo: | ||
self.bitmap =wx.Bitmap(w, h) | ||
else: | ||
self.bitmap =wx.EmptyBitmap(w, h) | ||
DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w,h), 2, self) | ||
# TODO: Add support for 'point' inspection and plot navigation. | ||
self._isDrawn = False | ||
|
@@ -781,11 +780,11 @@ def Copy_to_Clipboard(self, event=None): | |
bmp_obj.SetBitmap(self.bitmap) | ||
|
||
if not wx.TheClipboard.IsOpened(): | ||
open_success = wx.TheClipboard.Open() | ||
if open_success: | ||
wx.TheClipboard.SetData(bmp_obj) | ||
wx.TheClipboard.Close() | ||
wx.TheClipboard.Flush() | ||
open_success = wx.TheClipboard.Open() | ||
if open_success: | ||
wx.TheClipboard.SetData(bmp_obj) | ||
wx.TheClipboard.Close() | ||
wx.TheClipboard.Flush() | ||
|
||
def Printer_Init(self): | ||
""" | ||
|
@@ -1056,7 +1055,10 @@ def start_event_loop(self, timeout=0): | |
bind(self, wx.EVT_TIMER, self.stop_event_loop, id=id) | ||
|
||
# Event loop handler for start/stop event loop | ||
self._event_loop = wx.EventLoop() | ||
if 'phoenix' in wx.PlatformInfo: | ||
self.event_loop = wx.GUIEventLoop() | ||
else: | ||
self._event_loop = wx.EventLoop() | ||
self._event_loop.Run() | ||
timer.Stop() | ||
|
||
|
@@ -1106,10 +1108,13 @@ def gui_repaint(self, drawDC=None): | |
if drawDC is None: | ||
drawDC=wx.ClientDC(self) | ||
|
||
drawDC.BeginDrawing() | ||
drawDC.DrawBitmap(self.bitmap, 0, 0) | ||
drawDC.EndDrawing() | ||
#wx.GetApp().Yield() | ||
if 'phoenix' in wx.PlatformInfo: | ||
drawDC.DrawBitmap(self.bitmap, 0, 0) | ||
else: | ||
drawDC.BeginDrawing() | ||
drawDC.DrawBitmap(self.bitmap, 0, 0) | ||
drawDC.EndDrawing() | ||
#wx.GetApp().Yield() | ||
else: | ||
pass | ||
|
||
|
@@ -1160,7 +1165,10 @@ def _print_image(self, filename, filetype, *args, **kwargs): | |
width = int(math.ceil(width)) | ||
height = int(math.ceil(height)) | ||
|
||
self.bitmap = wx.EmptyBitmap(width, height) | ||
if 'phoenix' in wx.PlatformInfo: | ||
self.bitmap = wx.Bitmap(width, height) | ||
else: | ||
self.bitmap = wx.EmptyBitmap(width, height) | ||
renderer = RendererWx(self.bitmap, self.figure.dpi) | ||
|
||
gc = renderer.new_gc() | ||
|
@@ -1221,7 +1229,10 @@ def _onSize(self, evt): | |
DEBUG_MSG("_onSize()", 2, self) | ||
# Create a new, correctly sized bitmap | ||
self._width, self._height = self.GetClientSize() | ||
self.bitmap =wx.EmptyBitmap(self._width, self._height) | ||
if 'phoenix' in wx.PlatformInfo: | ||
self.bitmap =wx.Bitmap(self._width, self._height) | ||
else: | ||
self.bitmap =wx.EmptyBitmap(self._width, self._height) | ||
self._isDrawn = False | ||
|
||
if self._width <= 1 or self._height <= 1: return # Empty figure | ||
|
@@ -1238,8 +1249,10 @@ def _onSize(self, evt): | |
FigureCanvasBase.resize_event(self) | ||
|
||
def _get_key(self, evt): | ||
|
||
keyval = evt.m_keyCode | ||
if 'phoenix' in wx.PlatformInfo: | ||
keyval = evt.KeyCode | ||
else: | ||
keyval = evt.m_keyCode | ||
if keyval in self.keyvald: | ||
key = self.keyvald[keyval] | ||
elif keyval < 256: | ||
|
@@ -1412,11 +1425,11 @@ def _onEnter(self, evt): | |
|
||
def _create_wx_app(): | ||
""" | ||
Creates a wx.PySimpleApp instance if a wx.App has not been created. | ||
Creates a wx.App instance if a wx.App has not been created. | ||
""" | ||
wxapp = wx.GetApp() | ||
if wxapp is None: | ||
wxapp = wx.PySimpleApp() | ||
wxapp = wx.App() | ||
wxapp.SetExitOnFrameDelete(True) | ||
# retain a reference to the app object so it does not get garbage | ||
# collected and cause segmentation faults | ||
|
@@ -1813,13 +1826,29 @@ def _init_toolbar(self): | |
if text is None: | ||
self.AddSeparator() | ||
continue | ||
self.wx_ids[text] = wx.NewId() | ||
if text in ['Pan', 'Zoom']: | ||
self.AddCheckTool(self.wx_ids[text], _load_bitmap(image_file + '.png'), | ||
shortHelp=text, longHelp=tooltip_text) | ||
self.wx_ids[text] = int(wx.NewId()) | ||
if 'phoenix' in wx.PlatformInfo: | ||
if text in ['Pan', 'Zoom']: | ||
self.AddTool(self.wx_ids[text], label=text, | ||
bitmap=_load_bitmap(image_file + '.png'), | ||
bmpDisabled=wx.NullBitmap, | ||
shortHelpString=text, | ||
longHelpString=tooltip_text, | ||
kind=wx.ITEM_CHECK) | ||
else: | ||
self.AddTool(self.wx_ids[text], label=text, | ||
bitmap=_load_bitmap(image_file + '.png'), | ||
bmpDisabled=wx.NullBitmap, | ||
shortHelpString=text, | ||
longHelpString=tooltip_text, | ||
kind=wx.ITEM_NORMAL) | ||
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. Looks like "kind" is the only difference here - probably worth putting "kind" in a variable and having the AddTool outside of the if statement. |
||
else: | ||
self.AddSimpleTool(self.wx_ids[text], _load_bitmap(image_file + '.png'), | ||
text, tooltip_text) | ||
if text in ['Pan', 'Zoom']: | ||
self.AddCheckTool(self.wx_ids[text], _load_bitmap(image_file + '.png'), | ||
shortHelp=text, longHelp=tooltip_text) | ||
else: | ||
self.AddSimpleTool(self.wx_ids[text], _load_bitmap(image_file + '.png'), | ||
text, tooltip_text) | ||
bind(self, wx.EVT_TOOL, getattr(self, callback), id=self.wx_ids[text]) | ||
|
||
self.Realize() | ||
|
@@ -1878,7 +1907,10 @@ def save_figure(self, *args): | |
error_msg_wx(str(e)) | ||
|
||
def set_cursor(self, cursor): | ||
cursor =wx.StockCursor(cursord[cursor]) | ||
if 'phoenix' in wx.PlatformInfo: | ||
cursor = wx.Cursor(cursord[cursor]) | ||
else: | ||
cursor = wx.StockCursor(cursord[cursor]) | ||
self.canvas.SetCursor( cursor ) | ||
|
||
def release(self, event): | ||
|
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.
Does this work with v2.8?
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.
On 07/05/2013 12:52, Phil Elson wrote:
2.8.9.2
Added the wx.lib.agw package ........
So, only as of 2.8.9+ will it work, if that is not acceptable that one
could do:
Werner
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.
A more general way to handle it would be