- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想创建一个全屏面板,在视觉上阻止访问屏幕上的所有内容(Ubuntu (11.10) 中的桌面、菜单、Unity 面板等),但保持在其他应用程序打开的窗口下方。
这主要是为了让笔记本电脑 child 安全。我希望 child (4 岁)能够访问某些选定的应用程序,即。 gcompris、childs play、tux math 等,但不是真正的其他应用程序和设置。诸如自定义桌面 + 启动器面板之类的东西,没有任何可破坏的东西,无法访问文件等。
我希望面板包含一些可以启动其他应用程序的按钮(使用 subprocess.call),但面板本身需要保留在从它启动的任何内容之下,或者为了让事情变得更容易,所以它保留在任何打开的全屏游戏之下,并且每个打开的窗口(即使面板获得焦点)。
Python tkinter 的全屏 overrideredirect(True) 将是完美的(带有密码保护的关闭按钮),如果不是因为它不允许其他应用程序出现在它上面,我不确定是否可以让它保留在一切的底部。
如果可能的话,知道如何改变这种行为,或者有任何其他工具可以让我在 python 或其他方式中做到这一点吗?
编辑:附加信息:
我几乎可以正常工作了,但另一个奇怪的行为是 overrideredirect(True)。我可以在开始时降低()该应用程序并且它没问题,但是当我使用 overrideredirect(True) 执行此操作时,该应用程序完全消失了。非全屏测试代码如下:
from tkinter import *
def btn1_click():app.quit();app.destroy()
def btn2_click():app.lower()
def handler():
if tkinter.messagebox.askyesno("Quit?", "Are you sure you want to quit?"):
app.quit();app.destroy()
app = Tk()
app.title("Testing...")
app.geometry('300x100+200+100')
#app.overrideredirect(True)
#app.lower()
b1 = Button(app, text = "Exit!", width = 10, command = btn1_click);b1.pack()
b2 = Button(app, text = "Lower", width = 10, command = btn2_click);b2.pack()
app.protocol("WM_DELETE_WINDOW", handler)
app.mainloop()
当你按原样运行它时,它会打开新窗口并按下“下”按钮会将它发送到后面,但如果你取消注释 app.overrideredirect(True) 行并按下按钮,应用程序仍会运行但将不再可见。
编辑...好的,我想我明白了:
>>>help(tkinter)
...
| overrideredirect = wm_overrideredirect(self, boolean=None)
| Instruct the window manager to ignore this widget
| if BOOLEAN is given with 1. Return the current value if None
| is given.
...
所以,首先我要求窗口管理器忽略我的窗口,但后来我仍然希望 wm 对我的窗口做一些事情......炒作 :)
在不要求 wm 忽略窗口的情况下,还有其他方法可以剥离窗口装饰吗?
编辑。使用不同的工具 - wxPython 再看问题
这次我尝试使用简单的方法 - 使用 Boa Constructor。虽然窗口框架上的 app.lower() 在 Tkinter 上运行良好,但出于某种原因,我现在在使用 wxPython 时遇到了问题。在下面的代码中——按下按钮在框架上打开一个 gedit 窗口,2 秒后框架被带到顶部,再过 2 秒后它应该落到窗口堆栈的底部,但这不会发生,至少不在我的 Ubuntu 上。
def OnButton3Button(self, event):
subprocess.call("gedit") #opens gedit above the Frame
time.sleep(2) #waits for 2 seconds
self.Raise() #brings the Frame to the top
time.sleep(2) #waits for another 2 seconds
self.Lower() #should Lower the Frame to the bottom, but it doesn't
如果我能让 Lower() 以某种方式工作,那将很容易通过 ie.:
def OnFrame1Activate(self, event):
self.ShowFullScreen(True)
def OnFrame1EnterWindow(self, event):
self.Lower()
现在我的想法用完了,可能我会按照建议坚持使用 guest 帐户。
最佳答案
这就是我在 pygame on windows 中设置窗口位置的方式。这样,它将覆盖所有其他窗口,如果将 -1 更改为 1,它将位于其他窗口后面,我只知道它在 Windows 中有效。
import pygame, time, datetime, ctypes
from pygame.locals import *
from ctypes import windll
pygame.init()
set_window_pos = windll.user32.SetWindowPos
monitorsize = ctypes.windll.user32
resolution_X = monitorsize.GetSystemMetrics(0)
resolution_Y = monitorsize.GetSystemMetrics(1)
screen = pygame.display.set_mode((255, 242), pygame.NOFRAME)
set_window_pos(pygame.display.get_wm_info()['window'], -1, (resolution_X - 255), 50, 0, 0, 0x0001)
制作全屏窗口是通过以下方式完成的:
screen = pygame.display.set_mode((800, 350), FULLSCREEN) # this works in linux
关于python - 全屏 Python TKinter 或 wxPython 窗口,但所有窗口的 'stay at the bottom'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8553418/
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!