Python + TKinter + OMXPlayer window on top - python

I own a raspberry pi 2 and i start learning Python. I would like to do something very basic : the window of my Python program on top of omxplayer window like a notification system.
I have been able to make an "always on top" window with TKinter but when i launch omxplayer my window is no more on top.
I would apreciate some help !
Thanks

Try:
from Tkinter import *
root = Tk()
root.wm_attributes('-topmost', 1)
Source: http://tkinter.unpythonic.net/wiki/always_on_top

My solution is to used Hello_font from the hello_pi examples on the raspberry pi.

Related

How to disable resizing in Python Tkinter but keep the taskbar?

I write an app in python, using Tkinter. I want it to be zoomed and not resizable, but when i do this, it hides the taskbar, which I want to keep. Is there any way with that can be done?
from tkinter import *
root=Tk()
root.state('zoomed')
root.resizable(False, False)
Python 3.8
Windows 10

How to open a root window, close it and then open another window in tkinter after a few seconds?

I have made a GUI using Tkinter for my Python script for a Voice Assistant. It is working pretty well. But I want to add an animation window to display an animation that I have created using After Effects as an intro to the app. I want it to open without the default close(x), maximize and minimize buttons. The window should stay till the animation is completed, and then it would disappear. The main window would then open normally to launch the GUI. To disable the close, maximize and minimize buttons I have used the root.overrideredirect(True) method. But I am not being able to simultaneously open the two windows one after the other as mentioned. I would be highly obliged if somebody would help me out with this! I have tested it with a code on a simple GUI. I am providing the code below for help with the problem!
from tkinter import *
import time
root = Tk()
root.geometry('500x300')
root.overrideredirect(True) # To disable the default Window decoration
time.sleep(5) # Assuming that the animation runs for 5 seconds
root.destroy() # This window destroys after being on screen for 5 seconds
root.mainloop()
root2 = Tk() # After the previous window is destroyed, this window opens up. Assume that this is the main window
root2.geometry('500x300')
root.mainloop()
Please help me out!
The thing you call "animation window" is actually called "splash". There is a way to do what you want. You need to create a root window for the app (a Tk instance), and then you should hide (root.withdraw()) it. Now create a Toplevel for the splash, wait for 5 seconds, destroy it, and show (root.deiconify()) the Tk window again.
Note: time.sleep(5) should never be used with Tkinter, use root.after(ms, func) instead.
from tkinter import *
def show_splash():
splash = Toplevel()
splash.geometry('500x300')
splash.overrideredirect(True) # To disable the default Window decoration
splash.after(5000, splash.destroy) # This window destroys after being on screen for 5 seconds
splash.wait_window()
root = Tk()
root.withdraw()
show_splash()
root.deiconify()
root.mainloop()
PS: Procedural programming is not a good idea for pretty complex Tkinter-based apps. You should consider using OOP instead.
PPS: Take a look at this and this answers.

Simple turtle commands to bring turtle graphics window to the foreground? (python 3 on OS X El Capitan)

I've been trying to work through some beginner python turtle graphics turtorials in python 3.7 on Mac OS X El Capitan.
One of the things that seems annoying is that the turtle graphics window is opening up underneath the other windows.
I don't know if there is something wrong with my configuration, or whether it is typical of turtle graphics, but it would be nice if there an easy way to bring the window to the foreground. I have searched and found out that turtle graphics is based on tkinter, and found a couple of post on bringing tkinter windows to thr foreground.
I was able to get the following code to work with IDLE, but it doesn't work when running the program from the terminal.
import turtle
# works in IDLE, but not in OS X terminal
root = turtle.getscreen()._root
root.attributes("-topmost", true)
turtle.forward(100)
turelt.left(120)
I have tried looking through the turtle graphics documentation, but I didn't find any commands to bring a window to the foreground, and I am not fond of the idea of having to do a deep read through tkinter documentation just to be able to run a beginner turtle graphics tutorial.
That being said, knowing the right commands to get a tkinter-able reference to the turtle window, and knowing the correct tkinter commands would seem like an acceptable workaround.
Are there any basic turtle commands to bring the window to the foreground, or is there a way to get a reference to the root tkinter window in order to bring it to ther foreground??
Thanks in advance for any help or suggestions!!
Sincerely,
Bryan Pierce

Tkinter Gui does not appear

I'm trying to learning Python following a video Tutorial found on You Tube.
The version of Python is 2.6.4 and the OS is Windows 10 64.bit.
Yesterday the tutorial face the creation of GUI.
The miminum instracion set is in a file:
from Tkinter import *
top = Tk()
Running this file in the Python shell of Windows a little window appares.
Yestreday all was running correctly.
The tutorial adds labels and button.
Today I restarted but running the same example the window does not apper.
Could you help me to understand what is wrong?
Ther are some process open?
I have to to some kind of restet.
Thank you
You forgot to start the Tkinter GUI. You should add .mainloop() for that. So:
from Tkinter import *
top = Tk()
top.mainloop()

How to intercept WM_DELETE_WINDOW on OSX using Tkinter

I'm trying to keep a Toplevel window from being closed in OSX by intercepting window manager WM_DELETE_WINDOW event.
#!/usr/bin/env python
from Tkinter import *
def speak():
print "woof"
root = Tk()
root.title("root")
win = Toplevel()
win.title("win")
win.protocol('WM_DELETE_WINDOW', speak)
root.mainloop()
When I run this I get two pop up windows titled "root" and "win". If I click on the red "x" close button on "win" to close the window, prints "woof" and then closes. However, if I run this same code on windows "win" stays open and keeps printing "woof" every time I click the red "x" close button.
How can I keep the Toplevel window from closing on OSX when I click the red "x" close button?
See the reply to Python Issue 12584. It appears to be a bug in the very buggy Cocoa Tcl/Tk 8.5 that Apple shipped with OS X 10.6. Don't use it or the Apple-supplied Pythons in 10.6 if you are using Tkinter or anything that uses Tkinter, like IDLE. More info here.

Categories

Resources