Trying to replace the letters of a word to underscore

So as the title gives away, I wanna replace the letters of a word (That you input) to underscore ( _ ) or atleast to something different.

Now I have made a topic about this before and got some help, but I couldn’t figure out how to apply it to my code. So with his help and we both agreed it would be best if I made a new topic and also translated my code (Originally I am Dutch so) for better clarity.

So in the section “class ChooseMain(tk.Frame):” I have a user input a word that will be the word to guess.

The code in question for the input is:

self.woordEntry = tk.Entry(self, textvariable=self.controller.shared_data["chosenWord"])

Which in turn is sent to the next class called “ChosenMain” through this code:

btnContinue = tk.Button(self, text="Continue", command=lambda: controller.show_frame("ChosenMain"))

Now in the next class (“ChosenMain” in this case) it will show 3 things. 1 is word that was inputted on the previous screen and 2 buttons.

The word that was put in is displayed like this:

wordLabel = tk.Label(self, textvariable=self.controller.shared_data["chosenWord"], font=("futura"))
wordLabel.pack(side="top")

Now this shows the word that was input as normal but obviously I don’t want to show it as normal, preferably as _ _ _ _ or something similar. And that is where I am stuck.

Now as mentioned I did get help before this which was here: Trying to replace label text to underscore for a game of hangman

As mentioned there, I tried the solutions posted there but I just couldn’t get the wordLabel section to be changed to _ or * or anything really.

I’ll post my full code below this, and I hope I didn’t forget to translate something. Again if there is more information required or whatever. Feel free to comment here or message me and I will try my best to help!

#Hangman

import tkinter as tk

class Hangman(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        self.shared_data = {
            "chosenWord": tk.StringVar()
        }

        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, minsize=500,  weight=1)
        container.grid_columnconfigure(0, minsize=600, weight=1)

        self.frames = {}

        for F in (ChooseMain, ChosenMain):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("ChooseMain")

    def show_frame(self, page_name):
        for frame in self.frames.values():
            frame.grid_remove()
        frame = self.frames[page_name]
        frame.grid()

class ChooseMain(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        label = tk.Label(self, text="Choose your word")
        label.pack(side="top", fill="x", pady="10")
        self.wordEntry = tk.Entry(self, textvariable=self.controller.shared_data["chosenWord"])
        self.wordEntry.pack(pady=10)

        btnContinue = tk.Button(self, text="Continue", command=lambda: controller.show_frame("ChosenMain"))
        btnContinue.pack()


class ChosenMain(tk.Frame):    
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Guess the word!")
        label.pack(side="top", fill="x", pady=10)

        wordLabel = tk.Label(self, textvariable=self.controller.shared_data["chosenWord"], font=("futura"))
        
        wordLabel.pack(side="top")

        self.wentry = tk.Entry(self)
        self.wentry.pack(pady=10)
        GuessButton = tk.Button(self, text="Guess!", command=self.GuessWord)
        GuessButton.pack()
        NewWoord = tk.Button(self, text="Choose different word", command=self.ChangeWord)
        NewWoord.pack()

    def GuessWord(self):
        return True
        
    def ChangeWord(self):
        self.refresh()
        self.controller.show_frame("ChooseMain")

    def refresh(self):
        self.wentry.delete(0, "end")
        #self.text.delete("1.0", "end")
        self.wentry.focus_set()

if __name__ == "__main__":
    galgbord = Hangman()
    galgbord.mainloop()

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật