AttributeError : 'str'개체에 tkinter에 'set'속성이 없습니다.

Baskerville 씨

tkinter를 사용하여 Python에서 간단한 양식을 만들고 구현하려고합니다. 양식 자체는 PAGE를 사용하여 작성되었으므로 이제 양식과 상호 작용하는 코드를 작성하려고합니다 (아직 Python을 배우는 중이므로 참아주세요).

레이블이 정의 된 클래스 외부에서 레이블의 텍스트를 동적으로 설정하려고 할 때 AttributeError : 'str'개체에 'set'속성이 없습니다. 내가 온라인에서 읽은 모든 것은 이것이 내가 원하는 결과를 얻는 방법임을 나타내지 만이 오류로 인해 난처합니다. 도움을 주시면 감사하겠습니다.

setTimerString 함수 (Pulse 클래스의 일부)에서 오류가 발생합니다.

다음은 내 주요 코드 파일입니다.

#! /usr/bin/env python
#
# GUI module generated by PAGE version 4.8.5
# In conjunction with Tcl version 8.6
#    Feb 10, 2017 09:38:24 AM
import sys

try:
    from Tkinter import *
except ImportError:
    from tkinter import *

try:
    import ttk
    py3 = 0
except ImportError:
    import tkinter.ttk as ttk
    py3 = 1

import pulse_support

def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root, top
    root = Tk()
    top = Pulse (root)
    pulse_support.init(root, top)
    root.mainloop()

w = None
def create_Pulse(root, *args, **kwargs):
    '''Starting point when module is imported by another program.'''
    global w, w_win, rt
    rt = root
    w = Toplevel (root)
    top = Pulse (w)
    pulse_support.init(w, top, *args, **kwargs)
    return (w, top)

def destroy_Pulse():
    global w
    w.destroy()
    w = None

def startTimer():
    global count
    count = 0 # Reset it evert time the user starts the program
    top.setTimerString("12")


def runProgram():
    # Run the main program
    startTimer()

def closeProgram():
    exit()


class Pulse:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''

        self._bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        self._fgcolor = '#000000'  # X11 color: 'black'
        self._compcolor = '#d9d9d9' # X11 color: 'gray85'
        self._ana1color = '#d9d9d9' # X11 color: 'gray85' 
        self._ana2color = '#d9d9d9' # X11 color: 'gray85' 

        top.geometry("320x344+599+249")
        top.title("Pulse")
        top.configure(background="#d9d9d9")

        # Set the strings to use for the form
        self.countString = StringVar()
        self.timerString = StringVar()
        self.countString = "0"
        self.timerString = "0"

        self.btnExit = Button(top)
        self.btnExit.place(relx=0.84, rely=0.03, height=24, width=39)
        self.btnExit.configure(activebackground="#d9d9d9")
        self.btnExit.configure(activeforeground="#000000")
        self.btnExit.configure(background="#d9d9d9")
        self.btnExit.configure(command=closeProgram)
        self.btnExit.configure(disabledforeground="#a3a3a3")
        self.btnExit.configure(foreground="#000000")
        self.btnExit.configure(highlightbackground="#d9d9d9")
        self.btnExit.configure(highlightcolor="black")
        self.btnExit.configure(pady="0")
        self.btnExit.configure(text='''Exit''')
        self.btnExit.configure(width=39)

        self.btnStart = Button(top)
        self.btnStart.place(relx=0.31, rely=0.17, height=104, width=125)
        self.btnStart.configure(activebackground="#d9d9d9")
        self.btnStart.configure(activeforeground="#000000")
        self.btnStart.configure(background="#d9d9d9")
        self.btnStart.configure(command=runProgram)
        self.btnStart.configure(disabledforeground="#a3a3a3")
        self.btnStart.configure(foreground="#000000")
        self.btnStart.configure(highlightbackground="#d9d9d9")
        self.btnStart.configure(highlightcolor="black")
        self.btnStart.configure(pady="0")
        self.btnStart.configure(text='''Start''')
        self.btnStart.configure(width=125)

        self.Label1 = Label(top)
        self.Label1.place(relx=0.31, rely=0.58, height=21, width=54)
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(text='''Timer:''')
        self.Label1.configure(width=54)

        self.lblTimer = Label(top)
        self.lblTimer.place(relx=0.5, rely=0.58, height=21, width=32)
        self.lblTimer.configure(background="#a8aeff")
        self.lblTimer.configure(disabledforeground="#a3a3a3")
        self.lblTimer.configure(foreground="#000000")
        self.lblTimer.configure(textvariable=self.countString)
        self.lblTimer.configure(width=32)

        self.Label3 = Label(top)
        self.Label3.place(relx=0.33, rely=0.67, height=21, width=43)
        self.Label3.configure(background="#d9d9d9")
        self.Label3.configure(disabledforeground="#a3a3a3")
        self.Label3.configure(foreground="#000000")
        self.Label3.configure(text='''Count:''')

        self.lblCount = Label(top)
        self.lblCount.place(relx=0.5, rely=0.67, height=21, width=32)
        self.lblCount.configure(activebackground="#f9f9f9")
        self.lblCount.configure(activeforeground="black")
        self.lblCount.configure(background="#ffa8a8")
        self.lblCount.configure(disabledforeground="#a3a3a3")
        self.lblCount.configure(foreground="#000000")
        self.lblCount.configure(highlightbackground="#d9d9d9")
        self.lblCount.configure(highlightcolor="black")
        self.lblCount.configure(textvariable=self.countString)

        self.Label4 = Label(top)
        self.Label4.place(relx=0.13, rely=0.84, height=36, width=237)
        self.Label4.configure(background="#d9d9d9")
        self.Label4.configure(disabledforeground="#a3a3a3")
        self.Label4.configure(foreground="#000000")
        self.Label4.configure(text='''Press the start button to start the program.
Every time your pulse beats, press the P key.''')

    def setTimerString(self, newVal):
        self.timerString.set(newVal)


if __name__ == '__main__':
    vp_start_gui()
폴 루니
self.countString = StringVar()
self.countString = "0"

를 버리고 StringVar일반 str, 즉 set방법 이없는 종류로 교체합니다 .

대신

self.countString.set("0")

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

AttributeError : 'str'개체에 'flow_from_directory'속성이 없습니다.

분류에서Dev

attributeError : 'str'개체에 'dbname'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'values'속성이 없습니다.

분류에서Dev

xlsxwriter AttributeError : 'str'개체에 'add_worksheet'속성이 없습니다.

분류에서Dev

Django migrate AttributeError : 'str'개체에 '_meta'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'description'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'float'속성이 없습니다.

분류에서Dev

AttributeError 'str'개체에 'path'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 속성이 없습니다.

분류에서Dev

Python AttributeError : 'str'개체에 'append'속성이 없습니다.

분류에서Dev

DRF 1.7.1 'str'개체에 'resolve'AttributeError 속성이 없습니다.

분류에서Dev

Python-AttributeError : 'str'개체에 'isDigit'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'to_datetime'속성이 없습니다.

분류에서Dev

Socket, AttributeError : 'str'개체에 'send'속성이 없습니다.

분류에서Dev

Pandas : AttributeError : 'str'개체에 'iloc'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'name'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 '__name__'속성이 없습니다.

분류에서Dev

HTML 설치 : AttributeError : 'str'개체에 'decode'속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'read'Python 속성이 없습니다.

분류에서Dev

AttributeError : 'str'개체에 'keys'속성이 없습니다.

분류에서Dev

AttributeError : 'DataFrame'개체에 'set_value'속성이 없습니다.

분류에서Dev

attributeerror 'str'개체에는 boto3에 'tags'속성이 없습니다.

분류에서Dev

Python AttributeError : 'str'객체에 'items'속성이 없습니다.

분류에서Dev

table.decompose () : AttributeError : 'str'객체에 'decompose'속성이 없습니다.

분류에서Dev

Python-AttributeError : 'str'객체에 'append'속성이 없습니다.

분류에서Dev

Python : AttributeError : 'str'객체에 'readlines'속성이 없습니다.

분류에서Dev

AttributeError : '_tkinter.tkapp'개체에 'TclError'속성이 없습니다.

분류에서Dev

Seaborn 제목 오류-AttributeError : 'FacetGrid'개체에 'set_title 속성이 없습니다.

분류에서Dev

AttributeError : 'tuple'개체에 'set_author'속성이 없습니다 .discord.py

Related 관련 기사

  1. 1

    AttributeError : 'str'개체에 'flow_from_directory'속성이 없습니다.

  2. 2

    attributeError : 'str'개체에 'dbname'속성이 없습니다.

  3. 3

    AttributeError : 'str'개체에 'values'속성이 없습니다.

  4. 4

    xlsxwriter AttributeError : 'str'개체에 'add_worksheet'속성이 없습니다.

  5. 5

    Django migrate AttributeError : 'str'개체에 '_meta'속성이 없습니다.

  6. 6

    AttributeError : 'str'개체에 'description'속성이 없습니다.

  7. 7

    AttributeError : 'str'개체에 'float'속성이 없습니다.

  8. 8

    AttributeError 'str'개체에 'path'속성이 없습니다.

  9. 9

    AttributeError : 'str'개체에 속성이 없습니다.

  10. 10

    Python AttributeError : 'str'개체에 'append'속성이 없습니다.

  11. 11

    DRF 1.7.1 'str'개체에 'resolve'AttributeError 속성이 없습니다.

  12. 12

    Python-AttributeError : 'str'개체에 'isDigit'속성이 없습니다.

  13. 13

    AttributeError : 'str'개체에 'to_datetime'속성이 없습니다.

  14. 14

    Socket, AttributeError : 'str'개체에 'send'속성이 없습니다.

  15. 15

    Pandas : AttributeError : 'str'개체에 'iloc'속성이 없습니다.

  16. 16

    AttributeError : 'str'개체에 'name'속성이 없습니다.

  17. 17

    AttributeError : 'str'개체에 '__name__'속성이 없습니다.

  18. 18

    HTML 설치 : AttributeError : 'str'개체에 'decode'속성이 없습니다.

  19. 19

    AttributeError : 'str'개체에 'read'Python 속성이 없습니다.

  20. 20

    AttributeError : 'str'개체에 'keys'속성이 없습니다.

  21. 21

    AttributeError : 'DataFrame'개체에 'set_value'속성이 없습니다.

  22. 22

    attributeerror 'str'개체에는 boto3에 'tags'속성이 없습니다.

  23. 23

    Python AttributeError : 'str'객체에 'items'속성이 없습니다.

  24. 24

    table.decompose () : AttributeError : 'str'객체에 'decompose'속성이 없습니다.

  25. 25

    Python-AttributeError : 'str'객체에 'append'속성이 없습니다.

  26. 26

    Python : AttributeError : 'str'객체에 'readlines'속성이 없습니다.

  27. 27

    AttributeError : '_tkinter.tkapp'개체에 'TclError'속성이 없습니다.

  28. 28

    Seaborn 제목 오류-AttributeError : 'FacetGrid'개체에 'set_title 속성이 없습니다.

  29. 29

    AttributeError : 'tuple'개체에 'set_author'속성이 없습니다 .discord.py

뜨겁다태그

보관