Note that there are some explanatory texts on larger screens.

plurals
  1. POSignifying unsaved changes by prepending * in window title - how to add a black dot in the window close button on Mac OS X?
    primarykey
    data
    text
    <p> I am writing a text editor in Tkinter, using a <code>TopLevel</code> window that includes a <code>Text</code> widget. Currently, when a document/buffer contains unsaved changes, I prepend the title of the window with an asterisk as in <code>MyDocument</code> -> <code>*MyDocument</code> , as customary under *nix environments. For that purpose, I am using the <code>edit_modified</code> method of <code>Text</code> as follows:</p> <pre class="lang-py prettyprint-override"><code>import Tkinter as tk class EditingWindow(tk.Toplevel): # [...] self.text = tk.Text(...) # track modifications of the text: self.text.bind("&lt;&lt;Modified&gt;&gt;", self.modified) def modified(self, event=None): if self.text.edit_modified(): title=self.title() if title[0] != '*': self.title("*" + title) else: title=self.title() if title[0] == '*': self.title(title[1:]) def save(self, event=None): # [... saving under a filename kept in the variable self.filename ...] self.text.edit_modified(False) self.title(os.path.basename(self.filename)) </code></pre> <p><b>My question is:</b> On Mac OS X, rather than prepending the window title with an asterisk, a black dot appears in the window close button (the red circular button on the topleft corner) to signify unsaved changes. Is it possible to access this feature from Tkinter (or, more generally, from Tcl/Tk)?</p> <p><b> Edit 2: </b> After initial suggestions to use applescript, Kevin Walzer came up with the solution: setting <code>tkinter</code>'s <code>wm_attributes</code>. Above, that amounts to using</p> <pre class="lang-py prettyprint-override"><code>self.wm_attributes("-modified", 1) # sets black dot in toplevel's close button (mac) </code></pre> <p>and</p> <pre class="lang-py prettyprint-override"><code>self.wm_attributes("-modified", 0) # unsets black dot in toplevel's close button (mac) </code></pre> <p>in <code>self.modified</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload