Blender's GPU Accelerated UI, Decoupled from it's original codebase. Supports Rust, Python, JS, React, C & C++. Twice as good as GPUI
fix(tkinter): default menu tearoff to off on macos
Krish Kalaria2ef2de94417b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ab7aaaf..555e888 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -203,6 +203,7 @@ The newest work. Details for some items follow in the sections below.- **`WindowHandle::update`:** `cx.notify()` inside the closure didn't re-render that window.- **Python, hidden Tk root:** BUI's hidden Tk root (started before the first window on macOS, and by the Tk host) became `tkinter._default_root`, so a real tkinter program's `StringVar()` bound to the hidden interpreter and its widgets never saw the value.- **tkinter on HiDPI:** a window fitting its content (and `simpledialog` windows) was scaled twice, so it came out twice too large on Retina displays and other scaled screens.+- **tkinter on macOS:** `Menu` defaults to `tearoff=0`, like Tk on Aqua.### Changed- **Text looks like Blender's:** Inter, Blender's UI font, is embedded and is the default face on every platform. The portable stb_truetype engine is now the default on Windows too. `-DBUI_TEXT_GDI=ON` (Rust: the `gdi-text` feature) restores GDI and system fonts. `BUI_TEXT_STB` and `portable-text` are now no-ops.diff --git a/SYNTAX_COVERAGE.md b/SYNTAX_COVERAGE.mdindex 7fa8844..fdb6237 100644--- a/SYNTAX_COVERAGE.md+++ b/SYNTAX_COVERAGE.md@@ -74,8 +74,8 @@ overrides `text` (also in `cget`), `Scale` commands and`<<TreeviewSelect>>` run when idle, `validatecommand` sees programmatic`insert`/`delete`, generated key events go to the focus widget, bindings runper bindtag (widget, class, toplevel, `all`) and stop on `"break"`, a-`Notebook` requests its largest page, menus keep Tk's tearoff index 0,-`Text` keeps the trailing newline (`"end-1c"`), `edit_undo` is a no-op while+`Notebook` requests its largest page, menus keep Tk's tearoff index 0 (off by+default on macOS, like Aqua), `Text` keeps the trailing newline (`"end-1c"`), `edit_undo` is a no-op while`undo` is off, ttk `item()` converts integers.| Area | What runs where |diff --git a/bindings/python/bui/tksyntax/_widgets.py b/bindings/python/bui/tksyntax/_widgets.pyindex bc91614..625d07b 100644--- a/bindings/python/bui/tksyntax/_widgets.py+++ b/bindings/python/bui/tksyntax/_widgets.py@@ -11,6 +11,7 @@ from __future__ import annotationsimport mathimport re+import sysimport buipy@@ -2914,7 +2915,9 @@ class Menu(Widget):a popup (post / tk_popup)."""_KIND = None- _DEFAULTS = {"tearoff": 1, "type": "normal", "title": "", "postcommand": ""}+ # Tk's default: a tearoff entry at index 0, except on Aqua+ _DEFAULTS = {"tearoff": 0 if sys.platform == "darwin" else 1, "type": "normal", "title": "",+ "postcommand": ""}def __init__(self, master=None, cnf={}, **kw): # noqa: B006self._entries = []@@ -2922,8 +2925,8 @@ class Menu(Widget):self._bar = Noneself._active = NoneWidget.__init__(self, master, "menu", cnf, kw)- if "tearoff" not in self._opts: # Tk's default: a tearoff entry at index 0- self._apply("tearoff", 1)+ if "tearoff" not in self._opts:+ self._apply("tearoff", self._DEFAULTS["tearoff"])def _apply(self, key, value):if key == "tearoff":diff --git a/bindings/python/tests/test_tk_compat.py b/bindings/python/tests/test_tk_compat.pyindex 6750601..844b563 100644--- a/bindings/python/tests/test_tk_compat.py+++ b/bindings/python/tests/test_tk_compat.py@@ -178,7 +178,7 @@ def prog_editor(tk, ttk):filemenu.add_command(label="Quit", command=lambda: log.append("quit"))menubar.add_cascade(label="File", menu=filemenu)wrap = tk.BooleanVar(value=False)- view = tk.Menu(menubar) # with the default tearoff entry+ view = tk.Menu(menubar) # with the default tearoff entry (none on Aqua)view.add_checkbutton(label="Wrap", variable=wrap)menubar.add_cascade(label="View", menu=view)root.config(menu=menubar)diff --git a/docs/tkinter.md b/docs/tkinter.mdindex 9787548..a89ffbc 100644--- a/docs/tkinter.md+++ b/docs/tkinter.md@@ -212,7 +212,8 @@ BUI follows Tk's semantics, checked against the stdlib by- `validatecommand` also sees programmatic `insert` / `delete`.- Generated key events (`event_generate("<Control-q>")`) go to the widgetwith keyboard focus.-- Menus keep Tk's tearoff entry at index 0 unless you pass `tearoff=0`.+- Menus keep Tk's tearoff entry at index 0 unless you pass `tearoff=0`. On macOS+ the default is `tearoff=0`, as in Tk on Aqua.- `Text` keeps the trailing newline: `get("1.0", "end")` ends with `"\n"`,so use `"end-1c"`.- `edit_undo()` does nothing while `undo` is off.