Visitar URL original
wm_attributes doesn't take keyword arguments · Issue #43457 · python/cpython · GitHub
Skip to content

wm_attributes doesn't take keyword arguments #43457

Closed

Description

@gregcouch
mannequin
BPO 1500773
Nosy @loewis, @asvetlov
Files
  • Tkinter.patch: wm_attributes patch
  • issue1500773.diff
  • 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/loewis'
    closed_at = None
    created_at = <Date 2006-06-05.06:35:26.000>
    labels = ['type-feature', 'expert-tkinter']
    title = "wm_attributes doesn't take keyword arguments"
    updated_at = <Date 2012-03-21.19:45:52.695>
    user = 'https://bugs.python.org/gregcouch'

    bugs.python.org fields:

    activity = <Date 2012-03-21.19:45:52.695>
    actor = 'asvetlov'
    assignee = 'loewis'
    closed = False
    closed_date = None
    closer = None
    components = ['Tkinter']
    creation = <Date 2006-06-05.06:35:26.000>
    creator = 'gregcouch'
    dependencies = []
    files = ['7311', '10548']
    hgrepos = []
    issue_num = 1500773
    keywords = ['patch']
    message_count = 4.0
    messages = ['50427', '50428', '50429', '67668']
    nosy_count = 5.0
    nosy_names = ['loewis', 'gregcouch', 'klappnase', 'gpolo', 'asvetlov']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1500773'
    versions = ['Python 3.2']

    Linked PRs

    Activity

    1. gregcouch commented on Jun 5, 2006

      gregcouchmannequin
      MannequinAuthor

      The Tk wm attributes command takes option arguments
      (from the Tk wm manual page):

         wm attributes window ?option value option value...?

      And option arguments are normally given with keyword
      arguments in Tkinter (most if not all widget creation
      functions and widget commands). The attached patch
      changes the wm_attributes method to take keyword
      arguments, so top.wm_attributes(alpha=.8) will work as
      expected (on Windows XP and Mac OS X).

    2. loewis commented on Jun 17, 2006

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      This is an incompatible change. I also don't see the point;

      top.wm_attributes('alpha',.8)

      should work just fine, no?

    3. klappnase commented on Jul 20, 2006

      klappnasemannequin
      Mannequin

      Logged In: YES
      user_id=797929

      I do not have winXP or OSX available to actually test it,
      but I doubt that

          top.wm_attributes('alpha',.8)

      will work; from Tk documentation it looks like you will have
      to write

          top.wm_attributes('-alpha',.8)

      which is in fact not what one would expect.
      Maybe a better solution than Greg's patch was to change
      wm_attributes() to accept both ways, like:

      def wm_attributes(self, *args, **kw):
          args = ('wm', 'attributes', self._w) + args +
      self._options({}, kw)
          return self.tk.call(args)

      so that old code will not break and the more intuitive
      version that Greg suggested is also legal.

    4. gpolo commented on Jun 3, 2008

      gpolomannequin
      Mannequin

      I'm adding my own version, this was done against python-trunk

    5. transferred this issue fromon Apr 10, 2022
    6. added a commit that references this issue on Oct 27, 2023
    7. serhiy-storchaka commented on Oct 27, 2023

      @serhiy-storchaka
      Member

      The proposed PR contains the following changes:

      1. w.wm_attributes() without arguments returns a dict instead of a tuple or a str.
        E.g. it returns {'alpha': 1.0, 'topmost': 0, 'zoomed': 0, 'fullscreen': 0, 'type': ''} instead of ('-alpha', 1.0, '-topmost', 0, '-zoomed', 0, '-fullscreen', 0, '-type', ''), and, when wantobjects is 0, it returns {'alpha': '1.0', 'topmost': '0', 'zoomed': '0', 'fullscreen': '0', 'type': ''} instead of '-alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}'.
        This is a breaking change!
        You still can get the old result when pass None as argument: w.wm_attributes(None).
      2. When called with a single argument to get a value, it allow to omit the minus prefix. E.g. w.wm_attributes('alpha'). w.wm_attributes('-alpha') also supported, but is now silently deprecated.
      3. It can be called with keyword arguments to set attributes. E.g. w.wm_attributes(alpha=0.5). Old way w.wm_attributes('-alpha', 0.5) also works, but it is now silently deprecated.
    8. serhiy-storchaka commented on Oct 28, 2023

      @serhiy-storchaka
      Member
    9. serhiy-storchaka commented on Nov 14, 2023

      @serhiy-storchaka
      Member

      My request for unconditional changing the returned value was rejected: python/steering-council#211. Instead it was proposed to add an optional argument return_python_dict=False.

    10. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 23, 2023
    11. added a commit that references this issue on Feb 5, 2024
    12. added a commit that references this issue on Feb 14, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions