繁体   English   中英

全屏Python TKinter或wxPython窗口,但“停留在所有窗口的底部”?

[英]Fullscreen Python TKinter or wxPython window, but 'stay at the bottom' of all windows?

我想创建一个全屏面板,在视觉上阻止访问屏幕上的所有内容(桌面,菜单,Unity面板等在Ubuntu(11.10)中),但仍然低于其他应用程序打开的窗口。

这主要是为了让笔记本电脑儿童证明。 我希望孩子(4岁)可以访问一些选定的应用程序,即。 gcompris,儿童游戏,礼服数学等,但不是真正的其他应用程序和设置。 像自定义桌面+启动器面板,没有任何破坏,无法访问文件等。

我希望面板包含一些可以启动其他应用程序的按钮(使用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构造函数。 虽然窗口框架上的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窗口位置的方法。 有了这个,它将覆盖所有其他窗口,如果你将-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)

制作一个窗口FULLSCREEN完成:

screen = pygame.display.set_mode((800, 350), FULLSCREEN) # this works in linux

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM