python win32api.LoadKeyboardLayout(),不更改IDLE外壳中的语言吗? [英] python win32api.LoadKeyboardLayout(), doesnt change language in IDLE shell?

查看:165
本文介绍了python win32api.LoadKeyboardLayout(),不更改IDLE外壳中的语言吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮我...我正在尝试启动我的第一个编程项目.它将在python中实现.

Can someone help me out please...I'm trying to start my first programming project. It will be implemented in python.

我需要有一个文本框(我使用的是wxpython).如果用户在此文本框中输入任何文本,那么我希望它显示为阿拉伯语.我想通过在光标停留在给定的文本框中时自动将用户的键盘更改为阿拉伯语布局来实现此目的.

I need to have a textbox (which i am using wxpython for). If the user enters any text into this text box, then I want it to appear as arabic. I wanted to this by automagically changing the users Keyboard to an arabic layout when the cursor lands in the given text box.

所以我找到了这个pywin32模块,它具有一个功能LoadKeyboardLayout() 因此,我试图在IDLE中对此进行测试,以查看是否可以使其接受IDLE中的阿拉伯文本,以查看其是否有效.所以我进入IDLE:

So i found this pywin32 module, which has a function LoadKeyboardLayout() So i am trying to test this in IDLE, to see if I can make it accept arabic text into IDLE, to see if it works. So I enter, into IDLE:

win32api.LoadKeyboardLayout('00000401',1)

然后返回67175425,即十六进制的十进制等效值:"4010401",我认为这是阿拉伯语的语言环境ID.所以我想哇!我已经完成了,但是当我尝试在此之后输入时,在IDLE窗口中,它将继续输入普通的英文字符.

This then returns, 67175425, the decimal equivalent of hex:'4010401' whcih I believe is the locale ID for Arabic. SO I think wow! I've done it, but when I try typing after this, in the IDLE window, it continues to type normal english characters.

有人可以解释我的错误,并指导我寻求一个好的解决方案.

Can someone please explain my errors and guide me towards a good solution.

好的,自发布该死的问题以来,我一直在尝试解决此问题. 没运气. 然后,我想:好吧,拧紧它,而不是在IDLE中对其进行快速测试,我将在项目的源代码中就地试用它." WTF-它第一次起作用,给出了我想要的确切行为. 然后,我在另一个IDE的解释窗口中进行了尝试,然后又一次尝试了!

Okay, I've been trying to solve this problem ever since posting the damn question. No luck. Then, I thought, "ok, screw it, instead of testing it quicly in IDLE, I will just try it out, in situ, in my source code for the project." WTF - it worked first time, giving exact behaviour that I wanted. Then I tried it in a different IDE, in the interpreted window, and again, IT WORKED straight away!

很明显,我的问题是在IDLE的解释模式下. 谁能解释为什么它在IDLE shell中不起作用???

So clearly my issue is with IDLE, in its interpreting mode. Can anyone explain why it doesn't work in the IDLE shell???

推荐答案

  1. Windows中的键盘布局设置是按进程(并从父进程继承)
  2. IDLE在其GUI之外的后台进程中运行Python脚本

因此,您已经成功更改了正在运行脚本的后台Python进程的键盘布局,但没有更改IDLE的GUI.

So you have successfully changed the keyboard layout of the background Python process that is running your script, but not of IDLE's GUI.

这篇关于python win32api.LoadKeyboardLayout(),不更改IDLE外壳中的语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆