Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter: make X window & macOS recognize dialogs as such #87821

Closed
patrickmelix mannequin opened this issue Mar 29, 2021 · 12 comments
Closed

Tkinter: make X window & macOS recognize dialogs as such #87821

patrickmelix mannequin opened this issue Mar 29, 2021 · 12 comments
Assignees
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-IDLE topic-tkinter type-feature A feature request or enhancement

Comments

@patrickmelix
Copy link
Mannequin

patrickmelix mannequin commented Mar 29, 2021

BPO 43655
Nosy @terryjreedy, @taleinat, @serhiy-storchaka, @miss-islington, @E-Paine, @patrickmelix
PRs
  • bpo-43655: Tkinter Set _NET_WM_WINDOW_TYPE on FileDialog #25061
  • bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window #25187
  • [3.9] bpo-43655: Tkinter and IDLE dialog windows are now recognized a… #25588
  • [3.8] [3.9] bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window (GH-25187). (GH-25588) #25592
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2021-04-25.11:20:20.831>
    created_at = <Date 2021-03-29.08:53:43.635>
    labels = ['expert-tkinter', '3.9', '3.10', '3.8', 'expert-IDLE', 'type-feature']
    title = 'Tkinter: make X window & macOS recognize dialogs as such'
    updated_at = <Date 2021-04-25.11:20:20.831>
    user = 'https://github.com/patrickmelix'

    bugs.python.org fields:

    activity = <Date 2021-04-25.11:20:20.831>
    actor = 'serhiy.storchaka'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2021-04-25.11:20:20.831>
    closer = 'serhiy.storchaka'
    components = ['IDLE', 'Tkinter']
    creation = <Date 2021-03-29.08:53:43.635>
    creator = 'patrickmelix'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43655
    keywords = ['patch']
    message_count = 12.0
    messages = ['389676', '389681', '389683', '389862', '390204', '390209', '390210', '390215', '390216', '391847', '391854', '391855']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'taleinat', 'serhiy.storchaka', 'miss-islington', 'epaine', 'patrickmelix']
    pr_nums = ['25061', '25187', '25588', '25592']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue43655'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @patrickmelix
    Copy link
    Mannequin Author

    patrickmelix mannequin commented Mar 29, 2021

    While trying to fix window behaviour in a python project (ASE: https://wiki.fysik.dtu.dk/ase/), I came across this problem:

    Tkinter does not set the _NET_WM_WINDOW_TYPE when using the FileDialog class or it's derivatives. I could not find a reason for this and it leads to my window manager (i3) not automatically recognising the window as a dialogue (and thus not enabling floating). I think the window types are there exactly for that purpose, so I don't see why not to set this as the default for the FileDialog class.

    I was able to change this by adding the line
    self.top.wm_attributes('-type', 'dialog')
    to the initialization of the FileDialog class. See also MR on GitHub.

    Since I am an absolute beginner at this please do forgive if I missed something.

    @patrickmelix patrickmelix mannequin added 3.7 (EOL) end of life 3.10 only security fixes 3.8 only security fixes 3.9 only security fixes topic-tkinter type-feature A feature request or enhancement labels Mar 29, 2021
    @serhiy-storchaka
    Copy link
    Member

    Thank you for your report and PR Patrick.

    I agree, it would be better to to set the "type" attribute to "dialog" for the FileDialog window. Tk does it for its dialog windows. But it is more complex.

    • It should be set not only for FileDialog, but for other dialog windows implemented in Python too (including dialog windows specific for IDLE). I am in process of working on making dialog windows implemented in Python looking and behaving closer to dialog windows implemented in Tk. The hardest part is writing tests for this.

    • This code should be executed only on X Window. On macOS and Windows different code is needed. From Tk sources of ::tk::dialog::file::Create and ::tk::dialog::color:: :

      if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}

    And in ::tk_dialog and ::tk::MessageBox :

        if {$windowingsystem eq "aqua"} {
            ::tk::unsupported::MacWindowStyle style $w moveableModal {}
        } elseif {$windowingsystem eq "x11"} {
            wm attributes $w -type dialog
        }

    And ::tk::dialog::error::bgerror uses moveableAlert instead of moveableModal.

    @patrickmelix
    Copy link
    Mannequin Author

    patrickmelix mannequin commented Mar 29, 2021

    Thank you for your feedback Serhiy!

    I obviously totally forgot about compatibility issues with other OS... If you are already aware of this and working on a solution even better. Did I miss this during my search or is it not public anywhere yet?

    For now one can easily avoid the issue by always setting the type manually, will have to see how to avoid the OS issue you mention then.

    Perhaps you can point me to the place to watch for your progress on the matter so I can keep track of this?
    Thanks again!

    @serhiy-storchaka
    Copy link
    Member

    No, it is not ready for publishing yet. I'll try to work on it on the next weekend. Since it is a large change, there is a risk of breaking user code, so perhaps it would be worth to separate changes related to this issue which can be backported.

    @serhiy-storchaka serhiy-storchaka removed 3.7 (EOL) end of life labels Mar 30, 2021
    @serhiy-storchaka
    Copy link
    Member

    PR 25187 makes all Tkinter dialog windows and most IDLE dialog windows (except about and help windows) be recognized as dialogs by window managers on macOS and X Window. It conforms the behavior of standard Tk dialog windows.

    This change is harmless enough to be backported.

    @terryjreedy
    Copy link
    Member

    Epaine (or Tal?): please test PR-25187 on Mac.

    @terryjreedy terryjreedy changed the title Tkinter: Not setting _NET_WM_WINDOW_TYPE on FileDialog Tkinter: make X window & macOS recognize dialogs as such Apr 4, 2021
    @terryjreedy terryjreedy changed the title Tkinter: Not setting _NET_WM_WINDOW_TYPE on FileDialog Tkinter: make X window & macOS recognize dialogs as such Apr 4, 2021
    @terryjreedy
    Copy link
    Member

    I presume 'floatable' means 'can move dialog around on top of the parent window'. On my Mac Air, with 3.8 and 8.6.8, all the dialogs I checked, including About, are already floatable in this sense, not just the search boxes (which already had "::tk::unsupported::MacWindowsStyle" call). Since tk::unsupported is not listed on https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm, (nor on the 8.5 page) I wonder if it is obsolete, or just hidden.

    If no one knows, we might ask Kevin Walzer.

    @serhiy-storchaka
    Copy link
    Member

    See https://wiki.tcl-lang.org/page/MacWindowStyle . I suppose it affects window decoration.

    @terryjreedy
    Copy link
    Member

    Excuse me, it is the query boxes, not the search boxes, that already have the call. Unlike the other boxes I initially tested, they do not have the traffic lights. I believe that this, not movability, is the effect on mac of 'movableModal'. I tested a messagebox and it also had no traffic lights.

    What effect does the change have on Linux?

    On my MacBook, IDLE preferences is too tall, so that the bottom buttons are not visible and the only way to reliably cancel is to click the red button on the title bar. So remove the change for that at least until we have redesigned the dialog to be wide instead of tall. There is also an IDLE issue questioning whether Preferences (and Search) should even be modal.

    Currently, IDLE file open and save-as drop down from the center of title bar, have no traffic lights, and cannot be moved. Open is the entire width of the screen and could only go up and down. For Open, the underlying window is moved to the center. For Safari, Save as is the same, so I question whether it should be changed. Safari's Open is movable. Neither window for either app currently has traffic lights.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 3bb3fb3 by Serhiy Storchaka in branch 'master':
    bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window (bpo-25187)
    3bb3fb3

    @serhiy-storchaka
    Copy link
    Member

    New changeset 9a16539 by Serhiy Storchaka in branch '3.9':
    [3.9] bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window (GH-25187). (GH-25588)
    9a16539

    @serhiy-storchaka
    Copy link
    Member

    New changeset 6077efa by Miss Islington (bot) in branch '3.8':
    [3.9] bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window (GH-25187). (GH-25588) (GH-25592)
    6077efa

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-IDLE topic-tkinter type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants