この単純なTkinterチュートリアルスクリプトがRaspberryPiで正常に実行されるのに、MacOSでは実行されないのはなぜですか?

estephan500

以下は、Tkinterを使用してプルダウンメニューバーを作成する方法を示すWebチュートリアルの小さなpython3スクリプトです。

https://www.tutorialspoint.com/python3/tk_menu.htmから直接コピーされ、変更はありません。

  • ラズベリーパイで実行すると正常に動作します(3つの異なるIDEを使用)
  • しかし、Mac(2つの異なるIDE)で実行すると、白いウィンドウが作成され、メニュー要素は配置されません。

  • このMacは、Tkinterを学習しようとしているときに、私が作成してきた他の単純なTkinterスクリプトを実行できることに注意してください...ボタン、ポップアップを作成します。問題はありません。

新しい編集:これが失敗しているMacに移動すると、次のようになります。

    >>> import tkinter
    >>> tkinter._test()

...テストは小さなボタンなどで正常に機能し、v8.5であることを示す小さなウィンドウが表示されます。

このスクリプトがマックを窒息させているのは何ですか(他のコンピューターはそうではありません)?どうもありがとう!

Macで失敗するtkinterスクリプトは次のとおりです。

# !/usr/bin/python3
from tkinter import *
def donothing():
   filewin = Toplevel(root)
   button = Button(filewin, text="Do nothing button")
   button.pack()

root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff = 0)
filemenu.add_command(label="New", command = donothing)
filemenu.add_command(label = "Open", command = donothing)
filemenu.add_command(label = "Save", command = donothing)
filemenu.add_command(label = "Save as...", command = donothing)
filemenu.add_command(label = "Close", command = donothing)

filemenu.add_separator()

filemenu.add_command(label = "Exit", command = root.quit)
menubar.add_cascade(label = "File", menu = filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label = "Undo", command = donothing)

editmenu.add_separator()

editmenu.add_command(label = "Cut", command = donothing)
editmenu.add_command(label = "Copy", command = donothing)
editmenu.add_command(label = "Paste", command = donothing)
editmenu.add_command(label = "Delete", command = donothing)
editmenu.add_command(label = "Select All", command = donothing)

menubar.add_cascade(label = "Edit", menu = editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label = "Help Index", command = donothing)
helpmenu.add_command(label = "About...", command = donothing)
menubar.add_cascade(label = "Help", menu = helpmenu)

root.config(menu = menubar)
root.mainloop()
ジェイソンハーパー

しかし、Mac(2つの異なるIDE)で実行すると、白いウィンドウが作成され、メニュー要素は配置されません。

素晴らしい、それは完璧に機能しています!

ウィンドウ自体は、Macでメニューが表示される場所ではありません。他のすべてのMacアプリケーションと同じように、画面の上部を見てください。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ