How to force application to be active?

Hi all,

On win32, I'm dragging and dropping stuff from another application, which is
the active application, into my wxPython app, which is NOT the active app.

Is there a way to make the wxPython app become active when it receives the
drag and drop event? I'm looking for some sort of MakeActive() function, but
having trouble finding something suitable.

thanks in advance,
Ant Wiese

Hello Anthony,

Is there a way to make the wxPython app become active when it
receives the drag and drop event? I'm looking for some sort
of MakeActive() function, but having trouble finding
something suitable.

May:

My_Main_Frame.Raise()

Or:

My_Main_Frame.RequestUserAttention()

Do what you are asking for?

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Hi Andrea,

Thanks very much - Raise() was exactly what I was looking for.

Best regards,
Ant

···

On Fri, 8 Sep 2006 10:49:58 +0100, Gavana, Andrea wrote:

Hello Anthony,

Is there a way to make the wxPython app become active when it
receives the drag and drop event? I'm looking for some sort of
MakeActive() function, but having trouble finding something
suitable.

May:

My_Main_Frame.Raise()

Or:

My_Main_Frame.RequestUserAttention()

Do what you are asking for?

Andrea.

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

···

On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:

Thanks very much - Raise() was exactly what I was looking for.

--
Grant Edwards grante Yow! I think I am an
                                  at overnight sensation right
                               visi.com now!!

What if you only raised yourself when you were the potential target of a
drag and drop operation? On some systems, that behavior is automatic,
but I could see the utility in making it happen faster (having waited 3
seconds for Windows to raise the destination window more times than I
care to count).

- Josiah

···

Grant Edwards <grante@visi.com> wrote:

On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:

> Thanks very much - Raise() was exactly what I was looking for.

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

>
> > Thanks very much - Raise() was exactly what I was looking for.
>
> Applications that raise themselves are evil, Evil, EVIL, _EVIL_!
>
> If I wanted that window on top, I would have _put_ it there.

What if you only raised yourself when you were the potential target of a
drag and drop operation? On some systems, that behavior is automatic,
but I could see the utility in making it happen faster (having waited 3
seconds for Windows to raise the destination window more times than I
care to count).

I was about to write exactly the same thing :smiley:

Andrea.

···

Grant Edwards <grante@visi.com> wrote:
> On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:

--
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.virgilio.it/infinity77/

My personal opinion?

I never want a window to raise itself. Never. If I put a
window on the bottom, I want it to stay there until I raise it.
Just because I enter some text into a window, click a button in
a window , or drop something onto a window that doesn't mean I
want it to be raised. If I want it raised, I'll raise it.

···

On 2006-09-08, Josiah Carlson <jcarlson@uci.edu> wrote:

Grant Edwards <grante@visi.com> wrote:

On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:

> Thanks very much - Raise() was exactly what I was looking for.

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

What if you only raised yourself when you were the potential target of a
drag and drop operation? On some systems, that behavior is automatic,
but I could see the utility in making it happen faster (having waited 3
seconds for Windows to raise the destination window more times than I
care to count).

--
Grant Edwards grante Yow! I'm ZIPPY!! Are we
                                  at having FUN yet??
                               visi.com

If I want a window raised, I'll raise it. I don't need an
applications or OS programmer overriding my window arrangement
and messing up my workspace.

···

On 2006-09-08, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Grant Edwards <grante@visi.com> wrote:
> On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:
>
> > Thanks very much - Raise() was exactly what I was looking for.
>
> Applications that raise themselves are evil, Evil, EVIL, _EVIL_!
>
> If I wanted that window on top, I would have _put_ it there.

What if you only raised yourself when you were the potential
target of a drag and drop operation? On some systems, that
behavior is automatic, but I could see the utility in making
it happen faster (having waited 3 seconds for Windows to raise
the destination window more times than I care to count).

I was about to write exactly the same thing :smiley:

--
Grant Edwards grante Yow! ... Blame it on the
                                  at BOSSA NOVA!!!
                               visi.com

Grant Edwards wrote:

Thanks very much - Raise() was exactly what I was looking for.

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!
If I wanted that window on top, I would have _put_ it there.

Your stupid, Stupid, STUPID, STUPID

David

···

ant@dogmelon.com.au

No, just fed up with programmers and programs that think they
know better than I what needs to be on top on my screen. Why
not just add a maximize and raise operation to the idle loop?
Nobody else's application cold be as important as the one
you're writing...

···

On 2006-09-09, David H <bluepaul@earthlink.net> wrote:

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

Your stupid, Stupid, STUPID, _STUPID_

--
Grant Edwards grante Yow! I will establish
                                  at the first SHOPPING MALL in
                               visi.com NUTLEY, New Jersey...

i think that you have build your own event ,
i had the same problem ,
on GTK i wrote a little gtk event manager
on OSX i use Apple Event via Applescript

Best Regards , -Plum

···

Grant Edwards <grante@visi.com> wrote:

On 2006-09-08, Anthony Wiese <ant@dogmelon.com.au> wrote:

Thanks very much - Raise() was exactly what I was looking for.

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

What if you only raised yourself when you were the potential target of a
drag and drop operation? On some systems, that behavior is automatic,
but I could see the utility in making it happen faster (having waited 3
seconds for Windows to raise the destination window more times than I
care to count).
- Josiah

Grant Edwards wrote:

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

Your stupid, Stupid, STUPID, _STUPID_

No, just fed up with programmers and programs that think they
know better than I what needs to be on top on my screen. Why
not just add a maximize and raise operation to the idle loop?
Nobody else's application cold be as important as the one
you're writing...

I agree that apps that intrude on your desktop are very rude, but I wouldn't be so absolute about it. Suppose you were writing an app that was part of a lab control system. The computer was bought and installed to run that app. In our case, we frequently walk past the computer with our hands full and want to see the status display, and finding some update reminder or some grad student's music player blocking the view is not acceptable. Having my app raise itself is absolutely the right thing in this case. My question is, how do I make my app feed an electric shock to the grad student that clicks on the music player?

Paul Probert
University of Wisconsin

···

On 2006-09-09, David H <bluepaul@earthlink.net> wrote:

Grant Edwards wrote:

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

Your stupid, Stupid, STUPID, _STUPID_

No, just fed up with programmers and programs that think they
know better than I what needs to be on top on my screen. Why
not just add a maximize and raise operation to the idle loop?
Nobody else's application cold be as important as the one
you're writing...

I agree that apps that intrude on your desktop are very rude, but I wouldn't be so absolute about it. Suppose you were writing an app that was part of a lab control system. The computer was bought and installed to run that app. In our case, we frequently walk past the computer with our hands full and want to see the status display, and finding some update reminder or some grad student's music player blocking the view is not acceptable. Having my app raise itself is absolutely the right thing in this case. My question is, how do I make my app feed an electric shock to the grad student that clicks on the music player?

Paul Probert
University of Wisconsin

the only word i could say (I agree)
that an app must respect the environment
(and to follow its logics and its behaviors )
  where it is deployed

Best Regards, -plum

···

On 2006-09-09, David H <bluepaul@earthlink.net> wrote:

Grant Edwards wrote:

Applications that raise themselves are evil, Evil, EVIL, _EVIL_!

If I wanted that window on top, I would have _put_ it there.

Your stupid, Stupid, STUPID, _STUPID_

No, just fed up with programmers and programs that think they
know better than I what needs to be on top on my screen. Why
not just add a maximize and raise operation to the idle loop?
Nobody else's application cold be as important as the one
you're writing...

I agree that apps that intrude on your desktop are very rude,
but I wouldn't be so absolute about it. Suppose you were
writing an app that was part of a lab control system. The
computer was bought and installed to run that app. In our
case, we frequently walk past the computer with our hands full
and want to see the status display, and finding some update
reminder or some grad student's music player blocking the view
is not acceptable.

If the computer is supposed to be dedictated to one app, why
even allow others to run?

Having my app raise itself is absolutely the right thing in
this case.

Keeping a particular window on top is the responsibility of the
window manager, not the application. Under XFCE you just click
on the window menu and select "keep on top". You can generally
make that attribute permanent for that application if you want.
I don't know what window manager you're using, but they pretty
much have all have that feature for 15 years.

My question is, how do I make my app feed an electric shock to
the grad student that clicks on the music player?

You should prevent unauthorized people from using the computer
at all.

···

On 2006-09-10, Paul Probert <pprobert@wisc.edu> wrote:

On 2006-09-09, David H <bluepaul@earthlink.net> wrote:

--
Grant Edwards grante Yow! All this time I've
                                  at been VIEWING a RUSSIAN
                               visi.com MIDGET SODOMIZE a HOUSECAT!

> Having my app raise itself is absolutely the right thing in
> this case.

Keeping a particular window on top is the responsibility of the
window manager, not the application. Under XFCE you just click
on the window menu and select "keep on top". You can generally
make that attribute permanent for that application if you want.
I don't know what window manager you're using, but they pretty
much have all have that feature for 15 years.

That depends on the OS and on the OS version. Not all the platforms
have this ability, Mine doesn't, for example :smiley:

> My question is, how do I make my app feed an electric shock to
> the grad student that clicks on the music player?

You should prevent unauthorized people from using the computer
at all.

You may want to try the latest wxPython pre-release, in which Robin
has implemented wx.Window.SendShockWave() :smiley:

If you are on Windows, try that (WARNING: highly terrorist-Python code :smiley: ):

import win32gui
import win32process
import win32con
import win32api

def windowEnumerationHandler(hwnd, resultList):
    resultList.append((hwnd, win32gui.GetWindowText(hwnd)))

topWindows =
win32gui.EnumWindows(windowEnumerationHandler, topWindows)

for wins in topWindows:
    if wins[1].find("Windows Media Player") >= 0:
        hwnd = wins[0]
        # Get the window's process id's
        t, p = win32process.GetWindowThreadProcessId(hwnd)
        # Ask window nicely to close
        win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
        # Allow some time for app to close
        time.sleep(2)
        # If app didn't close, force close
        try:
            handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p)
            if handle:
                win32api.TerminateProcess(handle,0)
  win32api.CloseHandle(handle)
        except:
            pass:

Hihihihihihihi. :smiley:

Andrea.

···

--
"Imagination Is The Only Weapon In The War Against Reality."

http://xoomer.virgilio.it/infinity77/

Grant Edwards wrote:
clip..

You should prevent unauthorized people from using the computer
at all.

Well, there are complex issues. For one, the grad students who work all night and get a lot of results are often the ones that like the music. Its a small price to pay. The fix of least resistance is to put an app.Raise() call in every once in a while. Thus my objection to the absolute statement that such an act is evil.

Paul Probert

What platform? That seems like such a basic feature. I'm a
bit surprised that there are windowed GUI systems that don't
allow the user to control the positioning of windows.

···

On 2006-09-10, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Keeping a particular window on top is the responsibility of the
window manager, not the application. Under XFCE you just click
on the window menu and select "keep on top". You can generally
make that attribute permanent for that application if you want.
I don't know what window manager you're using, but they pretty
much have all have that feature for 15 years.

That depends on the OS and on the OS version. Not all the platforms
have this ability, Mine doesn't, for example :smiley:

--
Grant Edwards grante Yow! Catsup and Mustard
                                  at all over the place! It's
                               visi.com the Human Hamburger!