2017-05-14 5 views
0

labelwidgetオプションがエントリウィジェットであるlabelframeを構築するクラスを作成しようとしています。 Widgetクラスは、呼び出し元のスクリプトとは異なるファイルにあります。labelwidgetを割り当てるときのウィンドウパス名が正しくない

エントリウィジェットをlabelframeのlabelewidgetオプションに関連付けるときにエラーが発生しました。

これはエラーメッセージです:

_tkinter.TclError: bad window path name "<RtMaintWidgets.Entry object at 0x0000000003768080>" 

これは、呼び出し元のスクリプトのコードです:

# Create the frame 
    # self.FSrootF = rt.Frame.crt(self.FSwindow) 
    self.FSrootF = tk.Frame(self.FSwindow) 
    self.FSrootF.grid(sticky='nsew') 

    # Create the widgets 
    self.FScrtInfo() 

def FScrtInfo(self): 
    """ 
    """ 
    # Create the label frame 
    # " User Information:" 
    # "rasterToolGUI allows you to adjust \\n 
    # spot elevations in X_Plane scenery.\\n 
    # Select the file on which to work,\\n 
    # select the options and let the magic begin." 
    self.FSinfoLf = rt.LabelFrame(self.FSrootF, 
            self.FSparms['LF001']) 
    self.FSinfoLf.grid() 

..andこれは、ウィジェットスクリプト

class Entry(object): 
    def __init__(self, into, text, justify='left'): 
     """ 

     :param into: 
     :param text: 
     :param justify: 
     """ 
     self.__into = into 
     self.__text = text 
     self.__titlewidth = len(self.__text) + 3 
     self.__justify = justify 
     self.__entrysvar = tk.StringVar() 

     self.__entrysvar.set(self.__text) 
     self.__entry = tk.Entry(self.__into, 
           width=self.__titlewidth, 
           textvariable=self.__entrysvar, 
           justify=self.__justify) 


class LabelFrame(object): 
    " Class documentation" 
    def __init__(self, into, title, labelanchor='nw', relief='groove'): 
     """ 

     :param into: 
     :param title: 
     :param labelanchor: 
     :param relief: 
     """ 
     self.__into = into 
     self.__title = ' ' + title 
     self.__labelanchor = labelanchor 
     self.__relief = relief 

     # Create the lf 
     self.__lf = tk.LabelFrame(self.__into, 
            labelanchor=self.__labelanchor, 
            relief=self.__relief) 
     # create the entry 
     self.__entry = Entry(self.__lf, 
          self.__title) 

     self.__lf['labelwidget'] = self.__entry < Statement causing the error 
のコードです

私は自分が何をしているのか分かっていたと思ったが、明らかにそうではなかった。私は "自己"を変更しようとしましたが、呼び出しの構文を変更しましたが、私が間違っていることを理解することはできません。

テストでは、Pythonに割り当てられた名前はウィジェットスクリプトに転送されるようですので、実際のエラーの内容はわかりません。

どこが間違っていますか?

+0

この同じ状況に新しい問題を追加できますか? – Garry

答えて

1

labelwidgetは実際のウィジェットに設定する必要があります。 にカスタムクラスの1つを設定しています。にはウィジェットが含まれていますが、それ自体はウィジェットではありません。

+0

ありがとうブライアン。 – Garry

関連する問題