简体   繁体   中英

python tkinter Label ++1

Hi I have this code:

from tkinter import *
import random

class calculation_game:
    def __init__(self):
        self.screen_user = Tk()
        self.screen_user.title("חישובים - מסך משתמש")
        self.screen_user.geometry("400x400+600+200")
        self.screen_user.resizable(False, False)

        self.x = 0

        self.points_user = Label(self.screen_user, text="הניקוד שלך הוא: ")
        self.points_user.place(x=290, y=370)
        self.points_text = Label(self.screen_user, text=self.x)
        self.points_text.place(x=252, y=370)


        self.button = Button(self.screen_user, text="שלח", command=lambda :self.select_lvl())
        self.button.place(x=180, y=230)

        self.text_name = StringVar()
        self.text_name = Entry(self.screen_user, justify='center')
        self.text_name.place(x=100, y=200)



        self.screen_user.mainloop()

I have this var: self.x = 0

I want add 1 to self.x if something good after I add 1 to var self.x

I want show this on the software with self.points_text

sorry in my English

I dont quite understand your question but I believe you're trying to increment self.x by one if an event occurs

try using

self.x += 1

instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM