before: <wx._controls.Button; proxy of <Swig Object of type 'wxButton *' at 0x26adc58> >
after: <__main__.MyPanel; proxy of <Swig Object of type 'wxPanel *' at 0x365d420> >
Win7/64, Python 2.7.5, 3.0.0.0 Classic
Michael
···
On Thu, 29 Jan 2015 22:41:17 +0100, Leockard <diegote142@gmail.com> wrote:
In a medium sized app, I'm having problems with panels and can't rely on
SetFocusIgnoringChildren(). Attached is example code.
Output after pressing the button is always:
before: wx._controls.Button; proxy of ...
after: wx._controls.TextCtrl; proxy of ...
Well, what I want to do is kill focus on any control that can take input from the user. For example, if the user presses ESC, any text controls should hide the caret and selection and no button should have its label surrounded by a selection rect. I thought that focusing the underlying panel would be the way to do that.
···
On Fri, Jan 30, 2015 at 12:59 PM, Tim Roberts timr@probo.com wrote:
Leockard wrote:
Thank you for your attention.
What is the course of action here then? I am running Ubuntu 14.10, and it looks like this should be a platform issue.
What does it mean for a “panel” to have the focus? A panel doesn’t
why not SetFocus on the Frame, or on the object returned by [GetTopLevelParent](http://www.wxpython.org/docs/api/wx.Window-class.html#GetTopLevelParent)()
?
···
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Well, what I want to do is kill focus on any control that can take input from the user. For example, if the user presses ESC, any text controls should hide the caret and selection and no button should have its label surrounded by a selection rect. I thought that focusing the underlying panel would be the way to do that.
This almost works. The only thing that bothers me is that if the focus is inside a TextCtrl, there’s an active selection and I then use myWin.GetTopLevelParent.SetFocus(), the selection background AND foreground become white. ???
···
On Fri, Feb 6, 2015 at 4:49 PM, Nathan McCorkle nmz787@gmail.com wrote:
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Well, what I want to do is kill focus on any control that can take input from the user. For example, if the user presses ESC, any text controls should hide the caret and selection and no button should have its label surrounded by a selection rect. I thought that focusing the underlying panel would be the way to do that.
why not SetFocus on the Frame, or on the object returned by [GetTopLevelParent](http://www.wxpython.org/docs/api/wx.Window-class.html#GetTopLevelParent)()
?
–
You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.
Well, what I want to do is kill focus on any control that can take
input from the user. For example, if the user presses ESC, any text
controls should hide the caret and selection and no button should
have its label surrounded by a selection rect. I thought that
focusing the underlying panel would be the way to do that.
The typical way it is done is to disable the widgets you don't want to allow to have focus. Even though that changes their appearance in most themes, having a visual change that notifies the user that they can't interact with the widgets is actually a good thing, otherwise you'll have users that think it is broken. If you want to enable/disable all widgets in a panel then you should be able to just call the panel's Enable/Disable methods.
···
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Thanks for the answer, Robin. Disabling all the controls will not do for my application. No matter, I have solved it in a (very hacky) way.
Is there any known reason why calling Panel.SetFocusIgnoringChildren() wasn’t working in my system?
On Wed, Feb 11, 2015 at 12:14 AM, Robin Dunn robin@alldunn.com wrote:
Nathan McCorkle wrote:
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Well, what I want to do is kill focus on any control that can take
input from the user. For example, if the user presses ESC, any text
controls should hide the caret and selection and no button should
have its label surrounded by a selection rect. I thought that
focusing the underlying panel would be the way to do that.
why not SetFocus on the Frame, or on the object returned by
The typical way it is done is to disable the widgets you don’t want to allow to have focus. Even though that changes their appearance in most themes, having a visual change that notifies the user that they can’t interact with the widgets is actually a good thing, otherwise you’ll have users that think it is broken. If you want to enable/disable all widgets in a panel then you should be able to just call the panel’s Enable/Disable methods.
Earlier you mentioned trying to SetFocus() on a Panel, which seems like it will have no effect in general.
···
On Wednesday, February 11, 2015 at 10:53:15 AM UTC-8, Leonardo Torres wrote:
Thanks for the answer, Robin. Disabling all the controls will not do for my application. No matter, I have solved it in a (very hacky) way.
Is there any known reason why calling Panel.SetFocusIgnoringChildren() wasn’t working in my system?
I meant SetFocusIgnoringChildren(), not just SetFocus()
···
On Wednesday, February 11, 2015 at 1:43:02 PM UTC-8, Nathan McCorkle wrote:
On Wednesday, February 11, 2015 at 10:53:15 AM UTC-8, Leonardo Torres wrote:
Thanks for the answer, Robin. Disabling all the controls will not do for my application. No matter, I have solved it in a (very hacky) way.
Is there any known reason why calling Panel.SetFocusIgnoringChildren() wasn’t working in my system?
On Wed, Feb 11, 2015 at 4:43 PM, Nathan McCorkle nmz787@gmail.com wrote:
On Wednesday, February 11, 2015 at 1:43:02 PM UTC-8, Nathan McCorkle wrote:
On Wednesday, February 11, 2015 at 10:53:15 AM UTC-8, Leonardo Torres wrote:
Thanks for the answer, Robin. Disabling all the controls will not do for my application. No matter, I have solved it in a (very hacky) way.
Is there any known reason why calling Panel.SetFocusIgnoringChildren() wasn’t working in my system?
I just tried GetTopLevelParent().SetFocus() in the button handler in your example and that also seems to work for me here:
before: <wx._controls.Button; proxy of <Swig Object of type ‘wxButton *’ at 0x222ee88> >
after: <main.Test; proxy of <Swig Object of type ‘wxFrame *’ at 0x1f6b760> >
I don’t recommend doing this though, as if you ever import this Frame from another file, the top-level parent won’t be the same as when you use this GUI standalone.
I’ve attached a modified version of your code, which also works for me (I wanted to try it with everything on a Panel, rather than some widgets being directly on the Frame). Supposedly having widget (drawn things) on panels is better for cross-platform, idk if that could be your issue.
On Friday, February 6, 2015 at 1:49:37 PM UTC-8, Nathan McCorkle wrote:
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Well, what I want to do is kill focus on any control that can take input from the user. For example, if the user presses ESC, any text controls should hide the caret and selection and no button should have its label surrounded by a selection rect. I thought that focusing the underlying panel would be the way to do that.
why not SetFocus on the Frame, or on the object returned by [GetTopLevelParent](http://www.wxpython.org/docs/api/wx.Window-class.html#GetTopLevelParent)()
Nathan, thank you for the response.
As I said in a previous post, I have since solved my problem with a hacky work-around.
My only question is: is there a known reason that Panel.SetFocusIgnoringChildren() won’t work in my system? And, if so many users are expecting it not to do anything, then why have it at all?
···
On Wednesday, February 11, 2015 at 4:54:24 PM UTC-5, Nathan McCorkle wrote:
On Friday, February 6, 2015 at 1:49:37 PM UTC-8, Nathan McCorkle wrote:
On Sunday, February 1, 2015 at 6:29:57 AM UTC-8, Leonardo Torres wrote:
Well, what I want to do is kill focus on any control that can take input from the user. For example, if the user presses ESC, any text controls should hide the caret and selection and no button should have its label surrounded by a selection rect. I thought that focusing the underlying panel would be the way to do that.
why not SetFocus on the Frame, or on the object returned by [GetTopLevelParent](http://www.wxpython.org/docs/api/wx.Window-class.html#GetTopLevelParent)()
I just tried GetTopLevelParent().SetFocus() in the button handler in your example and that also seems to work for me here:
before: <wx._controls.Button; proxy of <Swig Object of type ‘wxButton *’ at 0x222ee88> >
after: <main.Test; proxy of <Swig Object of type ‘wxFrame *’ at 0x1f6b760> >
I don’t recommend doing this though, as if you ever import this Frame from another file, the top-level parent won’t be the same as when you use this GUI standalone.
I’ve attached a modified version of your code, which also works for me (I wanted to try it with everything on a Panel, rather than some widgets being directly on the Frame). Supposedly having widget (drawn things) on panels is better for cross-platform, idk if that could be your issue.
Nathan, thank you for the response.
As I said in a previous post, I have since solved my problem with a
hacky work-around.
My only question is: is there a known reason that
Panel.SetFocusIgnoringChildren() won't work in my system? And, if so
many users are expecting it not to do anything, then why have it at all?
I haven't heard of any issues with it, and I would expect it to work, but I suppose it's possible that some style settings or some other component in the application is interfering with it. It basically just bypasses the code in wxPanel that looks for a child that will accept focus and falls back to calling the SetFocus in the parent class.
As I said in a previous post, I have since solved my problem with a
hacky work-around.
My only question is: is there a known reason that
Panel.SetFocusIgnoringChildren() won’t work in my system? And, if so
many users are expecting it not to do anything, then why have it at all?
I haven’t heard of any issues with it, and I would expect it to work, but I suppose it’s possible that some style settings or some other component in the application is interfering with it. It basically just bypasses the code in wxPanel that looks for a child that will accept focus and falls back to calling the SetFocus in the parent class.