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 - Unexpected behavior after creating around 10000 widgets #85798

Closed
jlahav mannequin opened this issue Aug 25, 2020 · 3 comments
Closed

Tkinter - Unexpected behavior after creating around 10000 widgets #85798

jlahav mannequin opened this issue Aug 25, 2020 · 3 comments
Labels
3.8 only security fixes topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@jlahav
Copy link
Mannequin

jlahav mannequin commented Aug 25, 2020

BPO 41632
Nosy @serhiy-storchaka, @E-Paine
Files
  • ten_k.py: code sample
  • ten_k.tcl
  • 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 = None
    closed_at = <Date 2020-08-26.11:22:15.315>
    created_at = <Date 2020-08-25.12:23:41.559>
    labels = ['3.8', 'expert-tkinter', 'type-crash']
    title = 'Tkinter - Unexpected behavior after creating around 10000 widgets'
    updated_at = <Date 2020-08-26.11:22:15.314>
    user = 'https://bugs.python.org/jlahav'

    bugs.python.org fields:

    activity = <Date 2020-08-26.11:22:15.314>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-08-26.11:22:15.315>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2020-08-25.12:23:41.559>
    creator = 'j.lahav'
    dependencies = []
    files = ['49426', '49427']
    hgrepos = []
    issue_num = 41632
    keywords = []
    message_count = 3.0
    messages = ['375888', '375889', '375899']
    nosy_count = 4.0
    nosy_names = ['gpolo', 'serhiy.storchaka', 'epaine', 'j.lahav']
    pr_nums = []
    priority = 'normal'
    resolution = 'third party'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue41632'
    versions = ['Python 3.8']

    @jlahav
    Copy link
    Mannequin Author

    jlahav mannequin commented Aug 25, 2020

    Observation:
    After creating around 10000 widgets (verified with ttk.Label), no more widgets get created, and sometimes graphical artifacts appear outside the application window.

    No error message or exception is raised.

    Expected:
    Either the limit can be removed (having dynamically created 10000 widgets in data heavy applications is sometimes desired), or at least document and return runtime errors to prevent the weird behavior.

    Reproduction:
    This is the problematic part:
    for _ in range(10000):
    ttk.Label(root, text='problematic')

    A full minimal example code is attached, though a better effect can be seen when running the above two lines in the context of a more advanced Tkinter application.

    @jlahav jlahav mannequin added 3.8 only security fixes topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 25, 2020
    @E-Paine
    Copy link
    Mannequin

    E-Paine mannequin commented Aug 25, 2020

    I am struggling to reproduce. On Linux the window shows exactly as expected (it does take a while to close, though, which is understandable) and on Windows the window never shows (it gets stuck before the mainloop). This is, however, not a tkinter problem as I get exactly the same result on each platform running the following equivalent Tcl in Wish:

    for {set i 0} {$i < 10000} {incr i} {
        ttk::label ".l$i" -text problematic
    }
    grid [ttk::label .lb -text {now you see me}]

    A similar issue was reported in bpo-37673. If you *need* lots of widgets (e.g. a large table) I would suggest lazy loading them instead of trying to render them all at load. Thank you for reporting this issue but it should be closed as third-party.

    A note for future: please could you include information about your environment (Python version, Tk patchlevel, OS, etc.) so it is easier for the problem to be narrowed down (again, thank you for reporting this issue).

    @jlahav
    Copy link
    Mannequin Author

    jlahav mannequin commented Aug 25, 2020

    Thank you for checking it so quickly, and answering nicely.

    I indeed forgot to mention that it happened to me on Windows. Sorry for that.

    The issue seems similar to the one you linked. I will try and take this to the TCL community since it impacts our product. Thank you for translating the code to TCL.

    If the python community has no interest in trying to push TCL to fix it, this issue can be closed.

    Thanks!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant