2

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. Example

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:

  1. Creating a self-signed certificate
  2. Building with PyInstaller using --uac-uiaccess
  3. Signing the executable
  4. 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.

8
  • Can you add a screenshot? If the buttons are in the top left corner, where is the root window? Commented May 20 at 19:06
  • @8349697 added. The root window can also be moved around anywhere - the buttons don't move at all. Commented May 20 at 19:37
  • Tried your code on Windows 10, Python 3.11, and PyInstaller 6.11.1. Works without problems. Build: pyinstaller app.py --uac-uiaccess. I skipped signing the executable(properties). You are using the latest versions of Python and PyInstaller. Try older versions. Commented May 20 at 20:48
  • @8349697 i downgraded pyinstaller and the same thing happens when i place it in Program Files. according to microsoft, uiaccess requires it to be put there otherwise windows doesn't honor uiaccess. Commented May 21 at 0:25
  • Tried this with Python 3.13.3 and PyInstaller 6.13.0. Tkinter works properly on my system. The result you are getting is not something common or a known bug. Commented May 21 at 8:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.