Issues transitioning application from 2.8.10 to 3.0.2.0

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

testFrame.py (3.38 KB)

This is probably not that helpful, but I migrated from 2.8.12.1 to 3.0.2.0 a while back and didn’t find any changes needed to the menu handling. My menu item bindings are similar to yours except I’m using the item ID, so in your test code instead of menuExit in the Bind call I’d have id=wx.ID_EXIT. I tried making a change to my code though to bind using the item instead of its ID and it didn’t seem to have any effect - the event was still fired.

···

On Saturday, 26 January 2019 20:47:44 UTC, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Ed is working with
version 4.0.4 which is very different than working with 3.0.2.x

    Johnf
···

On 01/28/2019 12:15 AM, Jill Holliday
wrote:

  This

is probably not that helpful, but I migrated from 2.8.12.1 to
3.0.2.0 a while back and didn’t find any changes needed to the
menu handling. My menu item bindings are similar to yours except
I’m using the item ID, so in your test code instead of menuExit in
the Bind call I’d have id=wx.ID_EXIT. I tried making a change to
my code though to bind using the item instead of its ID and it
didn’t seem to have any effect - the event was still fired

I have tried binding using the item ID, but it didn’t help. I even added a method to re-issue all the menu bind calls after the application has fully initialized, thinking that something in my code had wiped out the bindings. This didn’t help either. I now think the issue is not the binding, but that the menus themselves are just not firing the events??? I’m still stuck.

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Your sample code looks fine so I’m not sure what’s going on either. What platform are you on? The best I can suggest is to build up your sample one chunk at a time towards your main application’s features, and see when it starts having the problem again.

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Robin

Thanks
for your response. I am running Windows
10, my Python environment is the Enthought Python Distribution Python 2.7.13
(x86_64). My application uses Matplotlib
for interactive graphs and wxPython for GUI, menus, dialogs, and text display. I’ll continue to stub out my application in
the sample code and see if I can reproduce the behavior.

Barry Nayler

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Issue identified! My application defines a PopupMenu. When I added the definition for this menu into my sample code, the events stopped firing. Comment out the definition, events fire. I’ve included sample code testFrame2.py that demonstrates the problem.

Barry Nayler

testFrame2.py (1.44 KB)

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Don’t reuse the self.fileMenu object. Make a new instance that is a duplicate for use in the other menu.

···

On Monday, January 28, 2019 at 4:01:50 PM UTC-8, Barry Nayler wrote:

Issue identified! My application defines a PopupMenu. When I added the definition for this menu into my sample code, the events stopped firing. Comment out the definition, events fire. I’ve included sample code testFrame2.py that demonstrates the problem.

Robin

Thanks! I came to the same conclusion and successfully tested using a Popupmenu and a copy of the fileMenu. Good to know.

Barry

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Oops! I celebrated too soon. What I did that worked was not create a copy of the fileMenu, but rather create a new menu and then added a duplicate “Exit” element, like this:

Popup menu

self.popupMenu = wx.Menu()

self.popupfileMenu = wx.Menu()

popupmenuExit = self.popupfileMenu.Append(wx.ID_EXIT, “Exit\tCtrl-Q”, “Exit this plot window”)

self.popupMenu.AppendMenu(wx.ID_ANY, “&File”, self.popupfileMenu)

I just tired to instead create a copy of self.fileMenu and assign it to self.popupfileMenu using copy.copy. This did not fix the problem, menu commands still fail to fire.

So I then tried the copy using copy.deepcopy. This caused a crash because Swig objects can not be pickled.

So as of now, my work around requires me to recreate the menu structure if I want to use it from a popup. :frowning:

···

On Saturday, January 26, 2019 at 12:47:44 PM UTC-8, Barry Nayler wrote:

I have a working application in version 2.8.10, it builds a menu in the traditional manner. Menu commands are bound using the normal wx.Bind. When I run my application using 3.0.2.0, my menu commands fail to fire events. My application is huge, so I pasted the menu calls from my app into the attached test code. Of course when I run this in 3.0.2.0, it works fine. So I can’t reproduce the problem for you.

To attempt to isolate the problem, I build a test event that I can call from anywhere in my app. I attached the call to a button and I can successfully fire a menu Exit command. However the Menu File/Exit does not fire an event. Has anyone experienced this issue? I can’t find any other reports about similar behavior, so I assume something is wrong with my application. I have no idea what the issue is.

Yes, that is what I meant. The wx classes do not implement the necessary APIs for the Python copy module to be able to make true copies. Even if they did, the native C++ and the UI objects do not support being copied like that, they need to have completely new instances created.

···

On Tuesday, January 29, 2019 at 12:02:21 PM UTC-8, Barry Nayler wrote:

Oops! I celebrated too soon. What I did that worked was not create a copy of the fileMenu, but rather create a new menu and then added a duplicate “Exit” element, like this:

Popup menu

self.popupMenu = wx.Menu()

self.popupfileMenu = wx.Menu()

popupmenuExit = self.popupfileMenu.Append(wx.ID_EXIT, “Exit\tCtrl-Q”, “Exit this plot window”)

self.popupMenu.AppendMenu(wx.ID_ANY, “&File”, self.popupfileMenu)

Robin