I'm developing an accessibility application using Python and Tkinter where I need to use PyInstaller's --uac-uiaccess flag to ensure proper access to UI automation features.
The Problem
When I compile my application with PyInstaller using the --uac-uiaccess flag AND set my Tkinter window to be always-on-top (topmost=True), all my UI elements (buttons) appear misplaced at the top-left corner of the screen instead of within my application window.
If I keep decorations enabled but use topmost, I can see that the UI elements are being rendered completely outside the root window's bounds.

Minimal Reproducible Example
import tkinter as tk
# Create the main window
root = tk.Tk()
root.title("Simple Buttons")
root.attributes('-topmost', True) # Keep the window on top
# Create a frame to hold the buttons
button_frame = tk.Frame(root)
button_frame.pack(padx=10, pady=10)
# Create 8 buttons
button_texts = ["ON/OFF", "LEFT", "DOUBLE", "DRAG", "RIGHT", "SETUP", "MOVE", "EXIT"]
buttons = []
for text in button_texts:
button = tk.Button(button_frame, text=text, width=8, height=2)
button.pack(side=tk.LEFT, padx=2)
buttons.append(button)
# Start the main loop
root.mainloop()
My build process includes:
- Creating a self-signed certificate
- Building with PyInstaller using
--uac-uiaccess - Signing the executable
- Installing to Program Files
When running the compiled executable, all buttons appear at the top-left of the screen instead of in the window.
What I've Tried
- Adding explicit root.update() calls
- Using update_idletasks()
- Adding frames as containers
- Different window configurations
- Testing without topmost (works correctly)
- Testing with overrideredirect(True) (same issue)
Environment
- Windows 11 24H2
- Python 3.13.3
- PyInstaller 6.13
- Tkinter (built-in)
This issue is critical for my accessibility application as I need both the elevated UAC access and the ability to create always-on-top windows.
UPDATE - RESOLVED
Switching to Qt6 (PySide6/PyQt6) resolved this issue completely.
The same always-on-top functionality works perfectly with Qt6 when using PyInstaller's --uac-uiaccess flag, without any UI element positioning problems. This appears to be a specific incompatibility between Tkinter's topmost attribute and PyInstaller's UAC access functionality.
For anyone experiencing similar issues, consider migrating from Tkinter to Qt6 for applications requiring UAC elevation and always-on-top windows.
pyinstaller app.py --uac-uiaccess. I skipped signing the executable(properties). You are using the latest versions of Python and PyInstaller. Try older versions.