Tkinter checkbutton - text won't show up

后端 未结 1 1982
攒了一身酷
攒了一身酷 2020-12-22 02:28

When I try to use a checkbutton it works fine but the text won\'t appear. I can\'t understand why. Below is my code

from tkinter import *
a = Tk()
var1 = Int         


        
相关标签:
1条回答
  • 2020-12-22 02:52

    Try using themed tk (ttk) checkbutton widget:

    import tkinter as tk
    from tkinter import ttk
    
    a = tk.Tk()
    
    var1 = tk.IntVar()
    
    check_btn = ttk.Checkbutton(a, text="checkbutton", variable=var1)
    check_btn.grid(row=1,sticky='w')
    
    # set foreground color to blue
    check_btn_style = ttk.Style()
    check_btn_style.configure('TCheckbutton', foreground='blue')
    
    a.mainloop()
    
    0 讨论(0)
提交回复
热议问题