Skip to content

Idle: require tk 8.5 and ttk widgets, and drop unneeded code. #68947

Closed

Description

@terryjreedy
BPO 24759
Nosy @terryjreedy, @ncoghlan, @ned-deily, @roseman, @serhiy-storchaka
Files
  • require85.diff
  • require85-v2.diff
  • require85-v3.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/terryjreedy'
    closed_at = <Date 2016-06-10.22:41:41.175>
    created_at = <Date 2015-07-30.22:18:35.616>
    labels = ['expert-IDLE', 'type-feature']
    title = 'Idle: require tk 8.5 and ttk widgets, and drop unneeded code.'
    updated_at = <Date 2019-03-23.04:15:36.380>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-03-23.04:15:36.380>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-06-10.22:41:41.175>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2015-07-30.22:18:35.616>
    creator = 'terry.reedy'
    dependencies = []
    files = ['43149', '43210', '43254']
    hgrepos = []
    issue_num = 24759
    keywords = ['patch']
    message_count = 31.0
    messages = ['247701', '247702', '247703', '247721', '247722', '247810', '247811', '247816', '247843', '247845', '247854', '247860', '247862', '247896', '247963', '247993', '248031', '266743', '266803', '267077', '267080', '267108', '267145', '267154', '267156', '267180', '267311', '267313', '267502', '268073', '268074']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'ncoghlan', 'ned.deily', 'markroseman', 'python-dev', 'Al.Sweigart', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue24759'
    versions = ['Python 3.6']

    Activity

    1. terryjreedy commented on Jul 30, 2015

      @terryjreedy
      MemberAuthor

      PyShell currently has this code

      try:
      from tkinter import *
      except ImportError:
      print("** IDLE can't import Tkinter.\n"
      "Your Python may not be configured for Tk. **", file=sys.__stderr__)
      sys.exit(1)
      import tkinter.messagebox as tkMessageBox

      When Idle is started from an icon, there is no place for the error message to go, so it appears than nothing happens. But this is the best we can do without invoking system specific error message functions. (This, if possible, would be another issue.) The second import assumes that messagebox is available, which is should be without modification of the tkinter package since long ago. But I think we should guard against someone trying to start Idle on pre 8.5. The following seems to work nicely. This is a prerequisite for any ttk patches. Any comment before I apply?

      try:
      from tkinter import ttk
      except:
      root = Tk()
      root.withdraw()
      tkMessageBox.showerror("Fatal Idle Import Error",
      "Idle cannot import required module tkinter.ttk.\n"
      "Click OK to exit.",
      parent=root)
      sys.exit(1)

    2. self-assigned this
      on Jul 30, 2015
    3. added
      type-feature
      on Jul 30, 2015
    4. terryjreedy commented on Jul 30, 2015

      @terryjreedy
      MemberAuthor

      I tested by renaming installed 3.5 ttk, editing 3.5 PyShell with 3.4, and clicking 3.5 icon.

    5. roseman commented on Jul 30, 2015

      rosemanmannequin
      Mannequin

      Sounds good. Only suggestion, given it's user facing, is to have the error message point them towards a solution. Off the top of my head, maybe something like "IDLE requires Python be configured to use Tk 8.5 or newer (you have Tk x.x)" with a title of "IDLE Cannot be Started"

    6. python-dev commented on Jul 31, 2015

      python-devmannequin
      Mannequin

      New changeset 8203fc75b3d2 by Terry Jan Reedy in branch '2.7':
      bpo-24759: Gracefull exit Idle if ttk import fails.
      https://hg.python.org/cpython/rev/8203fc75b3d2

      New changeset 13a8782a775e by Terry Jan Reedy in branch '3.4':
      bpo-24759: Gracefull exit Idle if ttk import fails.
      https://hg.python.org/cpython/rev/13a8782a775e

    7. terryjreedy commented on Jul 31, 2015

      @terryjreedy
      MemberAuthor

      Improved message. Thanks. Should be good enough for the extremely few times it should ever be triggered.

    8. serhiy-storchaka commented on Aug 1, 2015

      @serhiy-storchaka
      Member

      IMHO Tcl and Tk should be in title case (as Python or Django) or at least all in upper case (as APL or SDL).

    9. serhiy-storchaka commented on Aug 1, 2015

      @serhiy-storchaka
      Member

      I don't see any mentions of ttk in IDLE source code except added check. Is ttk really required for IDLE?

    10. terryjreedy commented on Aug 1, 2015

      @terryjreedy
      MemberAuthor

      Re-opened for tweak.

      This patch, to exit gracefully if ttk is not available, is the first step before using ttk in Idle. Mark, a long-time tk/ttk expert and site/book author, has volunteered to help upgrade Idle with ttk. Please see "ttk in idle" on Idle-Sig list for general discussion and bpo-24750 for the first substantive patches. The only reason I have not applied the ttk.Scrollbar patch, on that issue, is because Ned mentioned, on that issue, that the OS 8.5 python requires tcl/tk 8.4. I strongly feel that this should not stop the use of ttk, but I an first doing a few non-ttk patches, including Mark's patch for bpo-24745, before continuing.

    11. terryjreedy commented on Aug 2, 2015

      @terryjreedy
      MemberAuthor

      Re-reading PEP-434, I was mistaken to apply this patch to 2.7 and 3.4 without further discussion. The PEP says "The PEP would apply to minor ..., but not necessarily to possible major re-writes such as switching to themed widgets ... ."

      Nick, should I post something on python-ideas or pydev, or continue here (moved from bpo-24750) about making the switch also in 2.7 and 3.4?

      I believe it would be best overall to at upgrade Idle 2.7, but I will not cry if we stop patching it now. Ditto for 3.4, which will soon get security fixes only anyway. I am ok with using ttk starting with 3.5.

    12. changed the title [-]Idle: require 8.5 / ttk[/-] [+]Idle: require ttk (and tcl/tk 8.5)[/+] on Aug 2, 2015
    13. roseman commented on Aug 2, 2015

      rosemanmannequin
      Mannequin

      Got it re: 2.7/3.4. So the only stumbling block left to 8.5/ttk in 3.5 would be the current Mac build that is ok with Tcl/Tk 8.4...?

    14. 11 remaining items

    15. terryjreedy commented on Jun 3, 2016

      @terryjreedy
      MemberAuthor

      Given what Serhiy said, the core of this patch is the original patch with a test of TkVersion instead of importing ttk. Code that only ran for 8.4- is removed. Some minimal new tests are added, and I may add some more. None of the changes should depend on OS. I want to apply this in a few days as it is a prerequisite for ttk patches.

    16. serhiy-storchaka commented on Jun 3, 2016

      @serhiy-storchaka
      Member

      Do you forgot to attach a patch?

    17. terryjreedy commented on Jun 3, 2016

      @terryjreedy
      MemberAuthor

      Trying again. And yes, I would like a review. I don't think there is anything system specific, but some deletions required a minor rewrite.

    18. serhiy-storchaka commented on Jun 3, 2016

      @serhiy-storchaka
      Member

      Did you try to run tests with Tk 8.4?

    19. terryjreedy commented on Jun 3, 2016

      @terryjreedy
      MemberAuthor

      No, 3.4 is security fixes only and this is a 3.6 only issue.

    20. serhiy-storchaka commented on Jun 3, 2016

      @serhiy-storchaka
      Member

      I meant Tk 8.4, not Python 3.4.

      Tests should be either passed or skipped, no errors raised.

    21. terryjreedy commented on Jun 3, 2016

      @terryjreedy
      MemberAuthor

      I saw the review comment about adding lines.

      I do not have 8.4 either, but I get the point: the startup version check does not not guard the unittests. After test.text_idle imports unittest and tkinter (as tk) (line 6), I will add

      if tk.TkVersion < 8.5:
          raise unittest.SkipTest("IDLE requires tk 8.5 or later.")

      I will add a 'private API' and version-required notice to idlelib.idle_test.__init__. I will add version required to the notice already in idlelib.__init__.

      For similar reasons, the proposed interface module (bpo-27162) would also need an explicit check. (Note added there.)

    22. python-dev commented on Jun 4, 2016

      python-devmannequin
      Mannequin

      New changeset e6560f018845 by Terry Jan Reedy in branch '2.7':
      Issue bpo-24759: Add 'private' notice for idlelib.idle_test.
      https://hg.python.org/cpython/rev/e6560f018845

      New changeset d75a25b3abe1 by Terry Jan Reedy in branch '3.5':
      Issue bpo-24759: Add 'private' notice for idlelib.idle_test.
      https://hg.python.org/cpython/rev/d75a25b3abe1

    23. terryjreedy commented on Jun 4, 2016

      @terryjreedy
      MemberAuthor

      I believe require85-v2.diff adds everything specified in my last post.

    24. terryjreedy commented on Jun 6, 2016

      @terryjreedy
      MemberAuthor

      Fixed whitespace and added comment.

    25. python-dev commented on Jun 10, 2016

      python-devmannequin
      Mannequin

      New changeset 81927f86fa3a by Terry Jan Reedy in branch 'default':
      Issue bpo-24759: Add test for IDLE syntax colorizoer.
      https://hg.python.org/cpython/rev/81927f86fa3a

    26. python-dev commented on Jun 10, 2016

      python-devmannequin
      Mannequin

      New changeset 76f831e4b806 by Terry Jan Reedy in branch 'default':
      Issue bpo-24759: IDLE requires tk 8.5 and availability ttk widgets.
      https://hg.python.org/cpython/rev/76f831e4b806

    27. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    topic-IDLEtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions