Show Frame without Activating

Hi everybody,
Because of the buggy nature of wx.PopupWindow, I'm attempting to recode my TextCtrlAutoComplete widget ( go to http://wiki.wxpython.org/index.cgi/TextCtrlAutoComplete for a complete code listing so far ) to use a borderless Frame. TextCtrlAutoComplete is a TextCtrl that drops down values that let you choose which one to autocomplete with. PopupWindow would have been ideal, but it does not work consistently across Linux and Windows with a ListBox on it.

So the question is can I Show() a frame without activating it (I need to retain the focus in the TextCtrl)?

I really appreciate your help everyone. Thanks in advance.

Edward Flick

frame.Show(1)
textctrl.SetFocus()

- Josiah

···

Edward Flick <eddy@cdf-imaging.com> wrote:

So the question is can I Show() a frame without activating it (I need to
retain the focus in the TextCtrl)?

Josiah Carlson wrote:

···

Edward Flick <eddy@cdf-imaging.com> wrote:

So the question is can I Show() a frame without activating it (I need to retain the focus in the TextCtrl)?
   
frame.Show(1)
textctrl.SetFocus()

Doesn't work for me.

Edward

Am I going down the wrong path using a wx.Frame instead of a wx.PopupWindow. I would use wx.PopupWindow if the ListCtrl would receive any mouse events running on Windows. Is there another Window type that would be better suited to a dropdown ListBox that doesn't capture focus?

Edward Flick wrote:

···

Josiah Carlson wrote:

Edward Flick <eddy@cdf-imaging.com> wrote:

So the question is can I Show() a frame without activating it (I need to retain the focus in the TextCtrl)?
  
frame.Show(1)
textctrl.SetFocus()

Doesn't work for me.

Edward

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

What part doesn't work? Are you not seeing the frame? Is the text
control not getting focus? Have you forgotten to use the
wx.FRAME_FLOAT_ON_PARENT style?

- Josiah

···

Edward Flick <eddy@cdf-imaging.com> wrote:

Josiah Carlson wrote:
>Edward Flick <eddy@cdf-imaging.com> wrote:
>>So the question is can I Show() a frame without activating it (I need to
>>retain the focus in the TextCtrl)?
>
>frame.Show(1)
>textctrl.SetFocus()

Doesn't work for me.

Josiah Carlson wrote:

Josiah Carlson wrote:
   

So the question is can I Show() a frame without activating it (I need to retain the focus in the TextCtrl)?
       

frame.Show(1)
textctrl.SetFocus()
     

Doesn't work for me.
   
What part doesn't work? Are you not seeing the frame? Is the text
control not getting focus? Have you forgotten to use the
wx.FRAME_FLOAT_ON_PARENT style?

Well, the TextCtrlAutoComplete class is a TextCtrl descendant in the constructor I initialize the popup list like this:
        ...
        self . dropdown = wx.Frame( None, style=wx.NO_BORDER|wx.STAY_ON_TOP|wx.NO_3D|wx.FRAME_NO_TASKBAR )
        self . dropdownlistbox = wx.ListBox( self.dropdown, style=wx.LB_SINGLE|wx.LB_NEEDED_SB, pos=wx.Point( 0, 0) )
        ...
And the code I have to display the dropdown (without the positioning and resizing code) is:
        ...
        self . dropdown . Show ( show )
        self . SetFocus() #Since self is the textbox

When I call the method that shows the dropdown, it apparently gives the dropdown window focus, because the titlebar on the other window is greyed out, and if I turn on the border on the dropdown it is highlited.

The full code listing is exactly as I have at the URL stated in my previous e-mail except for the line above which creates a wx.Frame instead of a wx.PopupWindow (and also in this version I had to disable the KILL_FOCUS event handler otherwise I would never see the popup at all).

Edward

···

Edward Flick <eddy@cdf-imaging.com> wrote:

Edward Flick <eddy@cdf-imaging.com> wrote:

Well, the TextCtrlAutoComplete class is a TextCtrl descendant in the
constructor I initialize the popup list like this:
        ...
        self . dropdown = wx.Frame( None,
style=wx.NO_BORDER|wx.STAY_ON_TOP|wx.NO_3D|wx.FRAME_NO_TASKBAR )
        self . dropdownlistbox = wx.ListBox( self.dropdown,
style=wx.LB_SINGLE|wx.LB_NEEDED_SB, pos=wx.Point( 0, 0) )
        ...
And the code I have to display the dropdown (without the positioning and
resizing code) is:
        ...
        self . dropdown . Show ( show )
        self . SetFocus() #Since self is the textbox

Ugh, "self . dropdown . ", please reformat the code to follow the Python
style guide (or the wxPython style guide, as it expands the rules to be
applicable to wxPython programming).

When I call the method that shows the dropdown, it apparently gives the
dropdown window focus, because the titlebar on the other window is
greyed out, and if I turn on the border on the dropdown it is highlited.

Have you tried wx.CallAfter(self.SetFocus) ?

The full code listing is exactly as I have at the URL stated in my
previous e-mail except for the line above which creates a wx.Frame
instead of a wx.PopupWindow (and also in this version I had to disable
the KILL_FOCUS event handler otherwise I would never see the popup at all).

Were you using a PopupWindow, or a PopupTransientWindow?

···

Edward Flick <eddy@cdf-imaging.com> wrote:

Edward Flick wrote:

Hi everybody,
Because of the buggy nature of wx.PopupWindow, I'm attempting to recode my TextCtrlAutoComplete widget ( go to http://wiki.wxpython.org/index.cgi/TextCtrlAutoComplete for a complete code listing so far ) to use a borderless Frame. TextCtrlAutoComplete is a TextCtrl that drops down values that let you choose which one to autocomplete with. PopupWindow would have been ideal, but it does not work consistently across Linux and Windows with a ListBox on it.

So the question is can I Show() a frame without activating it (I need to retain the focus in the TextCtrl)?

Try creating the frame with a style of wx.FRAME_TOOL_WINDOW|wx.FRAME_FLOAT_ON_PARENT and then when you show it immediately Raise the current frame again. Something like this:

  otherFrame.Show()
  thisFrame.Raise()

If you don't know what thisFrame is because of context then you can use wx.GetTopLevelWindow(someWidget) to find it, where presumably someWidget is the parent of your TextCtrlAutoComplete widget.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Josiah Carlson wrote:

Well, the TextCtrlAutoComplete class is a TextCtrl descendant in the constructor I initialize the popup list like this:
       ...
       self . dropdown = wx.Frame( None, style=wx.NO_BORDER|wx.STAY_ON_TOP|wx.NO_3D|wx.FRAME_NO_TASKBAR )
       self . dropdownlistbox = wx.ListBox( self.dropdown, style=wx.LB_SINGLE|wx.LB_NEEDED_SB, pos=wx.Point( 0, 0) )
       ...
And the code I have to display the dropdown (without the positioning and resizing code) is:
       ...
       self . dropdown . Show ( show )
       self . SetFocus() #Since self is the textbox
   
Ugh, "self . dropdown . ", please reformat the code to follow the Python
style guide (or the wxPython style guide, as it expands the rules to be
applicable to wxPython programming).

Sorry, I haven't read Python style guide, and I just emulated the style as provided by another example Widget on the Wiki. This is my first python and first wxPython project (Not at all new to programming though, just python). That format is not exactly my cup of tea either, which is why I didn't adhere to it 100%. Will fix later though.

When I call the method that shows the dropdown, it apparently gives the dropdown window focus, because the titlebar on the other window is greyed out, and if I turn on the border on the dropdown it is highlited.
   
Have you tried wx.CallAfter(self.SetFocus) ?

Doesn't work. Could it be because the control still has the focus, only in the other window?

The full code listing is exactly as I have at the URL stated in my previous e-mail except for the line above which creates a wx.Frame instead of a wx.PopupWindow (and also in this version I had to disable the KILL_FOCUS event handler otherwise I would never see the popup at all).
   
Were you using a PopupWindow, or a PopupTransientWindow?

PopupWindow and it worked perfectly on Linux. It wouldn't call the EVT_LISTBOX events on Windows though. Hence, my dilemma.

Edward

···

Edward Flick <eddy@cdf-imaging.com> wrote:

Josiah Carlson wrote:
>Ugh, "self . dropdown . ", please reformat the code to follow the Python
>style guide (or the wxPython style guide, as it expands the rules to be
>applicable to wxPython programming).
>
Sorry, I haven't read Python style guide, and I just emulated the style
as provided by another example Widget on the Wiki. This is my first
python and first wxPython project (Not at all new to programming though,
just python). That format is not exactly my cup of tea either, which is
why I didn't adhere to it 100%. Will fix later though.

You are doing good so far. Two references are:
http://wiki.wxpython.org/index.cgi/wxPython_20Style_20Guide
http://www.python.org/doc/essays/styleguide.html

>>When I call the method that shows the dropdown, it apparently gives the
>>dropdown window focus, because the titlebar on the other window is
>>greyed out, and if I turn on the border on the dropdown it is highlited.
>>
>
>Have you tried wx.CallAfter(self.SetFocus) ?
>
>
Doesn't work. Could it be because the control still has the focus, only
in the other window?

If you type, does it go into the text control? If not, then the text
control doesn't have the focus. Also, if a different window has the
focus, then the text control necessarily cannot have the focus.

PopupWindow and it worked perfectly on Linux. It wouldn't call the
EVT_LISTBOX events on Windows though. Hence, my dilemma.

Strange. There is also the little problem that PopupWindow doesn't
exist on Macs.

- Josiah

···

Edward Flick <eddy@cdf-imaging.com> wrote: