如何使用tkin删除python中的按钮

2024-10-05 12:17:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我想删除/隐藏手电筒按钮,如果我以后指定手电筒显示“隐藏”。但我不知道怎么做。我到处找,就是找不到答案

healthKit_show = "show"
flashlight_show = "show"
def supplies_buttons():
    supplies_showing = 1
    flashlight_var = Button(Supplies, text = "Flashlight", command=flashlight)
    healthKit_var =  Button(Supplies, text = "healthKit", command=healthKit)
    if flashlight_show == "show":
        flashlight_var.grid(row=supplies_showing, column=0, sticky=W)
        supplies_showing = supplies_showing + 1
    if not flashlight_show == "show":
        flashlight_var.pack_forget()
    if healthKit_show == "show":
        healthKit_var.grid(row=supplies_showing, column=0, sticky=W)
        supplies_showing = supplies_showing + 1
    if not flashlight_show == "show":
        healthKit_var.pack_forget()
supplies_buttons()
flashlight_show = "hide"
supplies_buttons()

Tags: textifvarshowbuttoncommandgridrow

热门问题