コードが不足していることがわかります。すべてのゲームがメニューから呼び出されます。それは長くて、私の質問には必要ないので、私はそれを削除しました。私の問題は特定の機能、display_data
でのみです。私がメニューから呼び出すと、matplotが新しいウィンドウで開き、ただちにクラッシュします。私はちょうどテストのための基本的なプロットを設定しました。何か案は?matplotプログラムは実行時に応答しないウィンドウを表示します
import matplotlib.pyplot as plt
def display_data():
plt.plot([1,2,4],[2,7,9])
plt.show()
# (6) Save Progress ------------------------------------------------------------
# (7) Load Data ----------------------------------------------------------------
# (8) Quit Game ----------------------------------------------------------------
def quit_game():
print('\nThank you for playing!')
# Main Menu --------------------------------------------------------------------
def menu():
calculation_game = print("\nEnter 1 to play 'Calculation'")
bin_reader = print("Enter 2 to play 'Binary Reader'")
trifacto = print("Enter 3 to play 'Trifacto'")
statistics = print("Enter 4 to view your statistics")
display_data = print("Enter 5 to display data")
save_game = print("Enter 6 to save your progress")
load_data = print("Enter 7 to load data")
quit_game = print("Enter 8 to quit the game")
def main_menu():
print('Welcome to BrainAge!')
main_record = []
user_input = ''
while user_input != '8':
menu()
user_input = input('\nWhat would you like to do? ')
if user_input == '1':
calculation_game()
if user_input == '2':
binary_reader_game()
if user_input == '3':
trifacto_game()
if user_input == '4':
display_statistics()
if user_input == '5':
display_data()
if user_input == '8':
quit_game()
main_menu()
クラッシュするか、ただちに終了しますか?クラッシュした場合は、エラーメッセージを表示します。終了した場合は、すでに回答済みの質問を参照してください。 – Julien
Matplotウィンドウを開くだけで、白いままですぐに反応しなくなります。エラーメッセージもなく、ちょっとしたクラッシュです。 –
matplotlibがクラッシュすると思いますか?私にとっては*クラッシュしますが、バックエンドについては誤りがあります。このような場合は、インポートの前に、 'import matplotlib'と' matplotlib.use( 'Qt4Agg')またはそれに類似するものを追加してみてください。その変更を加えれば、プロットは必要に応じて表示されます。また、なぜ 'menu()'関数でこれらのローカル変数を 'None'にも定義していますか? –