Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Segfault while (probably incorrectly) using Tkinter #122005

Copy link
Copy link
Open
@RLH-2110

Description

@RLH-2110
Issue body actions

Crash report

What happened?

I am still learning python and then found out that this gives me a segmentation fault.

To reproduce, it should be enough to just run the python file. I commented what line leads to the segmentation fault.

I'm on an Ubuntu vm, used python 3.10, upgraded to 3.12 after I encountered the segfault.
tkinter version is 8.6

I attached the python file and the core dump, as well as the error file thing that Ubuntu creates instead of core dumps
I dont think I can be of much help with additional information, I know nothing.

import tkinter

root = tkinter.Tk()

# Create a Canvas widget inside a Frame to hold your scrollable content
canvas = tkinter.Canvas(root)
scrollbar = tkinter.Scrollbar(root, orient="vertical", command=canvas.yview)
rootS = tkinter.Frame(canvas)

rootS.bind(
    "<Configure>",
    lambda e: canvas.configure(
        scrollregion=canvas.bbox("all")
    )
)

canvas.create_window((0, 0), window=rootS, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)

# Pack the scrollbar and canvas
scrollbar.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand=True)

def center_rootS(event):
	# Center the scrollable_frame within the canvas
	rootS.update_idletasks()
	canvas_width = canvas.winfo_width()
	canvas_height = canvas.winfo_height()
	scrollable_frame_width = rootS.winfo_reqwidth()
	scrollable_frame_height = rootS.winfo_reqheight()
	x_offset = (canvas_width - scrollable_frame_width) // 2
	y_offset = (canvas_height - scrollable_frame_height) // 2
	canvas.create_window((x_offset, y_offset), window=rootS, anchor="nw") # <---- this line creates a segfault

root.bind("<Configure>", center_rootS)
root.mainloop();

attachments.zip

CPython versions tested on:

3.10, 3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.4 (main, Jul 18 2024, 13:27:24) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-tkintertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.