Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

NavigationToolbar2Tk init not documented in html docs #26720

Closed
@AntiLibrary5

Description

@AntiLibrary5

Bug summary

Using matplotlib backend for a navigation toolbar in tkinter withgrid package manager gives the error:

_tkinter.TclError: cannot use geometry manager pack inside .!frame which already has slaves managed by grid

One should be able to use either package managerspack orgrid ideally.

Code for reproduction

importtkinterimporttkinterastkfrommpl_toolkits.mplot3dimportAxes3Dfrommpl_toolkits.mplot3dimportproj3dfrommatplotlib.backends.backend_tkaggimport (FigureCanvasTkAgg,NavigationToolbar2Tk)window=tkinter.Tk()window.wm_title("MRI in Tk")frame=ttk.Frame(window)frame.grid(row=0,column=0,sticky="nsew")fig=Figure(figsize=(8,8))pc_label=FigureCanvasTkAgg(fig,master=frame)pc_label.get_tk_widget().grid(row=0,column=1)pc_toolbar_label=NavigationToolbar2Tk(pc_label,frame)pc_toolbar_label.grid(row=0,column=1,sticky="s")

Actual outcome

Traceback (most recent call last):  File "/home/varora/PythonProjects/gui/tmp.py", line 16, in <module>    pc_toolbar_label = NavigationToolbar2Tk(pc_label, frame)  File "/home/varora/anaconda3/envs/nnunet_venv/lib/python3.10/site-packages/matplotlib/backends/_backend_tk.py", line 657, in __init__    self.pack(side=tk.BOTTOM, fill=tk.X)  File "/home/varora/anaconda3/envs/nnunet_venv/lib/python3.10/tkinter/__init__.py", line 2425, in pack_configure    self.tk.call(_tkinter.TclError: cannot use geometry manager pack inside .!frame which already has slaves managed by grid

Expected outcome

image

Additional information

This script uses amatplotlib backend fortkinter for displaying the navigation toolbar which natively implements
the package managerpack() fortkinter. Since we usegrid() package manager, this creates a conflict and hence
you need to change theLine: 657 in[PYTHON-DIR]/site-packages/matplotlib/backends/_backend_tk.py.

One should be able to use either package managers ideally.

Operating system

Ubuntu

Matplotlib Version

3.7.2

Matplotlib Backend

module://backend_interagg

Python version

3.10

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp