本文介绍了使用按钮 tkinter 删除选定的笔记本选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 tkinter 中删除选定笔记本选项卡的功能是什么?我在网上找不到任何关于此的信息?

whats the function for deleting selected notebook tab in tkinter?I couldn't find anything about this on the web?

这是我写的代码,我只需要函数:

This is the code that I wrote, i only need function:

from tkinter import *
from tkinter import ttk
import math
import sys

myApp = Tk()
myApp.title(" Program ")
myApp.geometry("1000x1200")

tasktabs=ttk.Notebook(myApp)

TabOne=ttk.Frame(tasktabs)
tasktabs.add(TabOne,text="Tab One")

TabOne=ttk.Frame(tasktabs)
tasktabs.add(TabOne,text="Tab Two")

def deletetab():

    # whats the function for deleting tab?

    pass

DelButton=Button(myApp,text=' Delete  ', command=deletetab)
DelButton.grid(row=0,column=3, sticky="W")


tasktabs.grid(row=0,column=0,sticky="W")

myApp.mainloop()

推荐答案

def deletetab():
    tasktabs.forget(tasktabs.select())

删除当前选择的标签.

这篇关于使用按钮 tkinter 删除选定的笔记本选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 02:08