1

コードを main.py から GameWindowManager.py と呼ばれる呼び出し可能なクラス/モジュールに移動しようとしています

メインで動作し、Buttons クラスを呼び出すことができますが、モジュール GameWindowManager を作成しようとすると、tlc is not an attribute エラーが発生します。

助けてください。できれば簡単に説明してください。ありがとうございました。

main.py

'''
main.py
Created on Oct 2, 2013

@author: noel

ChronoProjo Vesion 3.0
'''
from tkinter import *
from chrono.button import *
from chrono.GameWindowManager import *

class ChronoProjo(Frame):
    """self is the main programe"""

    def __init__(self,master=None):
        """Initialize your self"""

        """Display the curent Operating System"""
        print (sys.platform)


        """Initialise the base class"""

        Frame.__init__(self)

        ButtonManager.makeButton ( self, "new" )
        ButtonManager.makeButton ( self, "load" )
        ButtonManager.makeButton ( self, "quit" )
        ButtonManager.makeButton ( self, "save as" )

        """Set the Window Title and Icon"""
        self.master.title ( "Chrono Generic Toolbar" )
        if sys.platform == 'win32':
            #make an icon here
            pass
        self.pack ( side=TOP, fill=X )




root = Tk()

#create a toolbar

if __name__ == "__main__":
    ChronoProjo().mainloop()

ボタン.py

'''
button.py
Created on Oct 4, 2013

@author: noel

button Vesion 1.0
'''
from tkinter import *
#from tkinter.messagebox import *
class ButtonManager():



    def makeButton(self, name):

        if name == "new":
            menuButton = Button ( self, text = name, width = 11, command = ButtonManager.newGameCallback )
        elif name == "load":
            menuButton = Button(self, text = name, width = 11, command = ButtonManager.loadCallback)
        elif name == "quit":
            menuButton = Button(self, text = name, width = 11, command = ButtonManager.quitCallback)
        elif name == "save as":
            menuButton = Button(self, text = name, width = 11, command = ButtonManager.saveAsCallback)

        menuButton.pack(side=LEFT, padx=2, pady=2)

    def newGameCallback(self):
        print ("called the new callback!")

    def loadCallback(self):
        print ("called the load callback!")

    def quitCallback(self):
        print ("called the quit callback!")

    def saveAsCallback(self):
        print ("called the save as callback!")

GameWindowManager.py

'''
GameWindowManager.py
Created on Oct 14, 2013

@author: noel
'''
from tkinter import *
from chrono.button import *


class GameWindowManager(object):
    '''
    This is to manage the various game windows that will be used throughout the game
    '''

    def __init__(self,frame):
        """Initialize your self"""

        """Display the curent Operating System"""
        print (sys.platform)


        """Initialise the base class"""
        Frame.__init__(self)

        ButtonManager.makeButton ( self, "new" )
        ButtonManager.makeButton ( self, "load" )
        ButtonManager.makeButton ( self, "quit" )
        ButtonManager.makeButton ( self, "save as" )

        """Set the Window Title and Icon"""
        self.master.title ( "Chrono Generic Toolbar" )
        if sys.platform == 'win32':
            self.master.wm_iconbitmap ( './assets/img/NLFFace.ico' )    #haven't worked out how to do self in Linux yet
            pass
        self.pack ( side=TOP, fill=X )
4

1 に答える 1