Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99133
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | eryksun <eryksun@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: non-blocking getkey? |
| Date | Fri, 20 Nov 2015 02:43:13 -0600 |
| Lines | 43 |
| Message-ID | <mailman.509.1448009036.16136.python-list@python.org> (permalink) |
| References | <n2hdfn$b1d$1@news2.informatik.uni-stuttgart.de> <n2hfe1$n3l$1@dont-email.me> <n2hkho$d1j$1@news2.informatik.uni-stuttgart.de> <n2hlr7$d1j$2@news2.informatik.uni-stuttgart.de> <n2ia83$icf$2@news2.informatik.uni-stuttgart.de> <mailman.419.1447869376.16136.python-list@python.org> <n2kqvn$8de$1@news2.informatik.uni-stuttgart.de> <564DF94E.8020302@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de zvVKgHusMPEsRtFIpixaCgcYhMqwmSM0Jc703MixDghw== |
| Return-Path | <eryksun@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'win32': 0.03; 'root': 0.04; 'importerror:': 0.05; 'sys': 0.05; '__name__': 0.07; 'filename': 0.07; 'sys.platform': 0.07; 'url:msdn': 0.07; 'api': 0.09; "%s'": 0.09; '[1]:': 0.09; '[2]:': 0.09; 'filename)': 0.09; 'def': 0.13; 'thu,': 0.15; "'__main__':": 0.16; "'win32':": 0.16; '[2].': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:non': 0.16; 'wrote:': 0.16; 'skip:u 30': 0.18; 'try:': 0.18; 'input': 0.18; 'windows': 0.20; '2015': 0.20; 'ctypes': 0.22; 'tkinter': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'switch': 0.27; 'message-id:@mail.gmail.com': 0.27; 'windows,': 0.29; 'window': 0.30; '[1]': 0.32; 'michael': 0.33; 'except': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'nov': 0.35; 'received:209.85': 0.36; 'possible': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'skip:o 20': 0.38; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'url:en-us': 0.72 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=pnZxDSPKosR1db25V0wLJNtQHm5Xd5pi1wMOm9Ycfr8=; b=NsL5ub7Yw2kzOjlyWJkyVcCDOVn2TR0WjBOBkgJxjkYS7cMLKo3YC7F4BmlSPH9/72 rpBj2C2AaLlHNopkxqK5/Bx4nOOEJLWZbeIjPfwGAxRh/dd2JdVDF8EEXi6r2RKM2/xv nX/YmME9wzApby3CXeHqgZMWDI/nJquUtAPEM515Ue2oaSatvaaaQGsZp1x0kceW9y+j rCjKMBokeut1TBDETPD+KdiTf8N8E36kOrW0FzjsKvFn1RIJyc/Hiqme+TH2g9De7ycF wtvG3WyYqmWFJUmiPYWepjYrTVrDu6JyyTKAdbrWVPrXWNj+EtcsOxCTDmjKgDZCktRd Cqxw== |
| X-Received | by 10.107.137.226 with SMTP id t95mr12535890ioi.188.1448009032809; Fri, 20 Nov 2015 00:43:52 -0800 (PST) |
| In-Reply-To | <564DF94E.8020302@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:99133 |
Show key headers only | View raw
On Thu, Nov 19, 2015 at 10:31 AM, Michael Torrie <torriem@gmail.com> wrote:
> One windows it might be possible to use the win32 api to enumerate the
> windows, find your console window and switch to it.
You can call GetConsoleWindow [1] and then SetForegroundWindow [2].
import os
import sys
try:
import tkinter
from tkinter import filedialog
except ImportError:
import Tkinter as tkinter
import tkFileDialog as filedialog
input = raw_input
if sys.platform == 'win32':
import ctypes
kernel32 = ctypes.WinDLL('kernel32')
user32 = ctypes.WinDLL('user32')
def setfgwin():
hcon = kernel32.GetConsoleWindow()
if hcon and user32.SetForegroundWindow(hcon):
return True
return False
def get_filename():
filename = filedialog.askopenfilename()
setfgwin()
return os.path.normpath(filename)
if __name__ == '__main__':
root = tkinter.Tk()
root.withdraw()
filename = get_filename()
print('filename: %s' % filename)
input('press enter...')
[1]: https://msdn.microsoft.com/en-us/library/ms683175
[2]: https://msdn.microsoft.com/en-us/library/ms633539
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 08:39 +0000
Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-18 10:14 +0100
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 10:39 +0000
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 11:01 +0000
Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-18 12:17 +0100
Re: non-blocking getkey? Terry Reedy <tjreedy@udel.edu> - 2015-11-18 07:26 -0500
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:06 +0000
Re: non-blocking getkey? Chris Angelico <rosuav@gmail.com> - 2015-11-19 00:24 +1100
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:57 +0000
Re: non-blocking getkey? Steven D'Aprano <steve@pearwood.info> - 2015-11-19 00:38 +1100
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 13:51 +0000
Re: non-blocking getkey? Chris Angelico <rosuav@gmail.com> - 2015-11-19 01:01 +1100
Re: non-blocking getkey? Jussi Piitulainen <harvesting@makes.invalid> - 2015-11-18 16:13 +0200
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 16:50 +0000
Re: non-blocking getkey? Terry Reedy <tjreedy@udel.edu> - 2015-11-18 12:55 -0500
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-19 15:48 +0000
Re: non-blocking getkey? Michael Torrie <torriem@gmail.com> - 2015-11-19 09:31 -0700
Re: non-blocking getkey? eryksun <eryksun@gmail.com> - 2015-11-20 02:43 -0600
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-23 17:01 +0000
askopenfilename() (was: Re: non-blocking getkey?) Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 10:29 +0000
Re: askopenfilename() Christian Gollwitzer <auriocus@gmx.de> - 2015-11-28 12:45 +0100
Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 12:48 +0000
Re: askopenfilename() Christian Gollwitzer <auriocus@gmx.de> - 2015-11-28 14:34 +0100
Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 16:45 +0000
Re: askopenfilename() Laura Creighton <lac@openend.se> - 2015-11-28 17:02 +0100
Re: askopenfilename() Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-28 16:05 +0000
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 08:28 +0000
Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-12-10 09:54 +0100
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 10:26 +0000
Re: non-blocking getkey? Christian Gollwitzer <auriocus@gmx.de> - 2015-12-10 09:57 +0100
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 10:40 +0000
Re: non-blocking getkey? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-10 15:52 +0000
Re: non-blocking getkey? eryksun <eryksun@gmail.com> - 2015-11-18 12:24 -0600
csiph-web