# Python3 not interacting with Tkinter

**URL:** <https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785>\
**Category:** Python Help\
**Created:** [April 12, 2024, 11:23am UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785 "2024-04-12T11:23:44Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 11:23am UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/1 "2024-04-12T11:23:44Z")

</div>

When I run the code below, Pyton ignores all references to Menu and produces a form with a single input box. It seems to load the window but none of the Menu items. Here is an example taken from the Python tutorial:

```python
from tkinter import *
from tkinter import ttk, messagebox
root = Tk()
ttk.Entry(root).grid()
m = Menu(root)
m_edit = Menu(m)
m.add_cascade(menu=m_edit, label="Edit")
m_edit.add_command(label="Paste", command=lambda: root.focus_get().event_generate("<<Paste>>"))
m_edit.add_command(label="Find...", command=lambda: root.event_generate("<<OpenFindDialog>>"))
root['menu'] = m

def launchFindDialog(*args):
    messagebox.showinfo(message="I hope you find what you're looking for!")
    
root.bind("<<OpenFindDialog>>", launchFindDialog)
root.mainloop()

```

This is the result when I run this code in IDLE:

![Menu test](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/d/a/da3393bfcec9282c52052533e6a146e3663ed837.png)

I would be grateful for any assistance.

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [April 12, 2024, 11:48am UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/2 "2024-04-12T11:48:22Z")

</div>

One macos, the `menu` gets placed in the menu bar at the top. You haven’t shown that it isn’t there in your screenshot.

`IDLE` is built ontop of tkinter, so since you are using it, the python-tkinter interaction works and it’s either a problem in your code, or, in this case I think, your expectations of what your code should be doing.

---

<div class="post-metadata">

**Author:** ![franklinvp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/franklinvp/32/11142_2.png) [@franklinvp](https://discuss.python.org/u/franklinvp)\
**Post date:** [April 12, 2024, 12:09pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/3 "2024-04-12T12:09:37Z")

</div>

On my side, the code works as it is. Although, I am not on Mac.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 12:24pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/4 "2024-04-12T12:24:15Z")

</div>

I expected to see a Menu showing “Edit” cascading to Paste etc. Am I wrong to expect this? The code is copied and pasted from the Python official documentation. It shouldn’t have any errors. Maybe it is because I am running on a Mac Mini M1 chip???

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 12:30pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/5 "2024-04-12T12:30:08Z")

</div>

Would you mind showing me the resultant window after you ran the code so that I can see what to expect? I am a beginner in Python programming, having only programmed in MS Visual Basic a long time ago.

---

<div class="post-metadata">

**Author:** ![franklinvp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/franklinvp/32/11142_2.png) [@franklinvp](https://discuss.python.org/u/franklinvp)\
**Post date:** [April 12, 2024, 12:32pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/6 "2024-04-12T12:32:59Z")

</div>

This is the image, after I clicked on the Edit to see what is inside.

![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/7/6/760548b502b3de3b84a5d49f90eaa925eef7d5b0.png)

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [April 12, 2024, 12:48pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/7 "2024-04-12T12:48:26Z")

</div>

Yes, this is the exact behavior that you will not see on macos. The menu will be put into the top bar, i.e. top of the desktop, as is standard for all macos apps. I am not on a macos, so I can’t share a screenshot.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 1:13pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/8 "2024-04-12T13:13:13Z")

</div>

Thank you Franklinvp. That is what I hoped to see.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 1:17pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/9 "2024-04-12T13:17:26Z")

</div>

Thank you Cornelius. You are 100% correct. I was looking for the menu in the window. I now see that it is in the top bar as you have pointed out. Apologies for wasting everyone’s time. I had no idea that this was classic mac behaviour though I have been using a Mac since 2012.

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [April 12, 2024, 5:28pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/10 "2024-04-12T17:28:28Z")

</div>

If you run IDLE, you will also see its main menu above the window instead of in the window as with \*nix and windows.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 12, 2024, 5:45pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/11 "2024-04-12T17:45:06Z")

</div>

Yes, thanks Terry. I should have realised all this with my long period of use of canned programs on my Mac, but I’ve never programmed anything on a Mac before; only on a PC. It’s a case of not seeing the elephant in the room because it has always been there!

---

<div class="post-metadata">

**Author:** ![TeamSpen210](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/teamspen210/32/1004_2.png) [@TeamSpen210](https://discuss.python.org/u/TeamSpen210)\
**Post date:** [April 12, 2024, 9:17pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/12 "2024-04-12T21:17:15Z")

</div>

It might also be useful to note that there’s some other special behaviours, activated by giving sub-menus [special names](https://www.tcl.tk/man/tcl8.6.13/TkCmd/menu.htm#M21). You can set `name="apple"`, `window` or `help` to add your items into those default menus.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 14, 2024, 7:41am UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/13 "2024-04-14T07:41:34Z")

</div>

Thank you Spencer. That is useful to know. I will look at the Tk documentation to learn more.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 16, 2024, 4:19pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/14 "2024-04-16T16:19:22Z")

</div>

Hi Spencer. I’ve just got back to this problem and, even after looking at the blurb in your link, it’s not clear to me how to get the “apple” part of it into the syntax. I don’t find that part of the Tk manual easy to follow.  
If you take the menu example I gave above, what would this extra line look like and where would I put it?

---

<div class="post-metadata">

**Author:** ![TeamSpen210](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/teamspen210/32/1004_2.png) [@TeamSpen210](https://discuss.python.org/u/TeamSpen210)\
**Post date:** [April 16, 2024, 10:08pm UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/15 "2024-04-16T22:08:51Z")

</div>

You’d just need to change the second menu construction to be `Menu(m, name="apple")`. All Tk widgets fundamentally have a name, which is composed of it and all its parents. The root `Tk()` widget is named `.`, then others get named like `.!frame5.!menu3.!menu8` by default. You can override the auto-name with the `name` option.

---

<div class="post-metadata">

**Author:** ![neilcamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilcamp/32/19120_2.png) [@neilcamp](https://discuss.python.org/u/neilcamp)\
**Post date:** [April 17, 2024, 9:19am UTC](https://discuss.python.org/t/python3-not-interacting-with-tkinter/50785/16 "2024-04-17T09:19:26Z")

</div>

Thank you very much Spencer. I will do that.
