[Idle-dev] IDLE getpass?

Douglas S. Blank dblank at brynmawr.edu
Sat Sep 1 14:18:17 CEST 2007


On Sat, September 1, 2007 4:20 am, Tal Einat said:
> I have two ideas, but not the time to try them out:
>
> One is to embed an entry in the text widget - just like the Squeezer
> extension embeds a button. I think this would be the cleanest approach.

That would work for the specific getpass functionality, but in general the
problem of windows coming up behind IDLE is a real issue for newbies and
experts alike: it is just confusing.

> The other is to try making the getpass window transient to the main
> window,
> and/or to give its entry widget focus before calling deiconify and
> tkraise.

I have tried many dozens of combinations of things, including going down
to the Windows handle and using Windows system calls to try to force it
up, but nothing works. How would I make a "transient" window?

Thanks for keeping this in the back of your mind, Tal, but I think this
may be a lower-level Windows bug. I'm just telling students to put IDLE in
the right hand side of the screen so they'll see new windows. I've also
made new windows flash the docked window title (by a couple of
raises/lowers). So, I've learned to live with it...

Thanks again,

-Doug

> - Tal
>
> On 8/17/07, Douglas S. Blank <dblank at brynmawr.edu> wrote:
>>
>> Tal,
>>
>> Thanks for looking at this and giving feedback.
>>
>> Unfortunately, this doesn't seem to work for me when running with
>> subprocesses.
>>
>> Maybe it has to have to do with Tkinter running in the background
>> thread,
>> and tkraise not knowing about the IDLE window in the other thread (which
>> is on top).
>>
>> If there were a global ontop function, that would do it. I'm starting to
>> think that it isn't even possible in WindowsXP with IDLE with
>> processes...
>>
>> -Doug
>>
>> On Thu, August 16, 2007 10:18 pm, Tal Einat said:
>> > On 8/16/07, Douglas S. Blank <dblank at brynmawr.edu> wrote:
>> >> Ok, I can't find anything to fix this. I've tried combinations of
>> lower,
>> >> lift, deiconify, iconify, update, overridedirect, ... but nothing I
>> do
>> >> can get a new Tk window to appear on top of IDLE.
>> >>
>> >> This is very confusing for new students (and experts). I'll do
>> whatever
>> >> is necessary even it requires plugin or whatever. Can I lower IDLE?
>> >>
>> >> Any ideas?
>> >>
>> >> -Doug
>> >>
>> >> Here's some code to help anyone see the problem:
>> >>
>> >> # in IDLE on Windows XP:
>> >> import Tkinter
>> >> tl = Tkinter.Toplevel()
>> >> tl.update()
>> >> tl.raise()
>> >> ...
>> >>
>> >> I can't get the tl window to appear on top of IDLE.
>> >>
>> >
>> > Well, I ran into trouble at first too when trying to do this. In the
>> > end I realized that deiconify(), tkraise() and focus() need to be
>> > called once the Tk object's mainloop is already running. And that they
>> > must be called from the same thread that the mainloop is running in,
>> > so threads must be avoided.
>> >
>> > This seems to do the trick:
>> >
>> > def raised():
>> >        top = Tk()
>> >        text = Text(top)
>> >        text.pack(expand=True)
>> >        top.after(50, top.deiconify)
>> >        top.after(50, top.tkraise)
>> >        top.after(50, text.focus)
>> >        top.mainloop()
>> >
>> >
>> > Of course, using 'after' like this is an ugly hack. If the call to
>> > mainloop is delayed somehow, then the window will not be raised
>> > (that's why I used a 50 millisecond delay). I played around with
>> > cleaner possibilities but ran into some difficulties... It's too late
>> > at night, I'll give it another look tomorrow.
>> >
>> > - Tal
>> >
>>
>>
>> --
>> Douglas S. Blank
>> Associate Professor, Bryn Mawr College
>> http://cs.brynmawr.edu/~dblank/
>> Office: 610 526 6501
>>
>>
>


-- 
Douglas S. Blank
Associate Professor, Bryn Mawr College
http://cs.brynmawr.edu/~dblank/
Office: 610 526 6501



More information about the IDLE-dev mailing list