2017-08-01 15 views
0

私は単純なプラットフォームゲームを作ろうとしていますが、tkinder、より具体的にはtkfontまたはtkinder.fontがモジュールであり、呼び出すことはできません。 コードはこちら。完全なトレースバックは、次のとおりです。tkinter.fontモジュールオブジェクトが呼び出し可能でない

Traceback (most recent call last): 
    File "C:\Users\iD Student\Desktop\Connor M\Endless platformer.py", line 
31, in <module> 
    helv36 = tkinter.font.Font(family="Helvetica",size=36,weight="bold") 
    File "C:\Python35\lib\tkinter\font.py", line 93, in __init__ 
    tk.call("font", "create", self.name, *font) 
AttributeError: 'NoneType' object has no attribute 'call' 

私はTkinterの自体が誤りであることを前提としています

Traceback (most recent call last): 
    File "C:\Users\iD Student\Desktop\Connor M\Endless platformer.py", line 
31, in <module> 
    helv36 = tkinter.font(family="Helvetica",size=36,weight="bold") 
TypeError: 'module' object is not callable 

tkinter.font.Fontは、このトレースバックをスローします。関連するコード:

import tkinter 
from tkinter.font import * 

helv36 = tkinter.font.Font(family="Helvetica",size=36,weight="bold") 

def draw_text(display_string, font, surface, x_pos, y_pos): 
    text_display = font.font(display_string, 1, (0, 0, 0)) 
    surface.blit(text_display, (x_pos, y_pos)) 

     #Ends the game if the player dies 
     if y >640: 
      endgame = True 
     if endgame: 
      draw_text("GAME OVER", helv36, screen, 50, 50) 
+2

完全なトレースバックを追加してください。エラーがどこで発生しているのか、正確なエラーは何かを知る必要があります。また、 '' tkinter.font.Font'' *は存在しますが、どういうことだと思いませんでしたか? –

+1

コードを[mcve]に減らしてください。 – ppperry

+0

エラーとコードが一致しません。コードは 'tkinter.font.Font(...)'を表示しますが、エラーメッセージは 'tkinter.font(...)'を表示します。 –

答えて

0

ルートウィンドウを作成するまで、フォントを作成することはできません。

関連する問題