在另一个TabControl中添加新的TabControls
我有一个主要的TabControl(Cronaca)。内部我有第二个TabControl(事件)。
我想将第三个名为“示例”的新标签插入事件中。新的TABCONTROL“示例”必须包含诸如组合蛋白(以前包含在事件中的组合,然后将其从事件中删除)等元素。我该怎么办?
你能告诉我这个简单的代码吗?我知道,我已经将TabControl插入了另一个TabControl,但是我目前感到困惑,并且在Pyhon的早期阶段。帮助对我有用
ps:可选:我的代码可能以无序的方式编写。如果可能的话,有些好人还可以在养蜂的养蜂中订购吗? (前面的五线养殖和之后的五线夫)。谢谢
from tkinter import *
from tkinter import ttk
import tkinter as tk
window=Tk()
window.attributes('-zoomed', True)
window.configure(bg='#f3f2f2')
style = ttk.Style(window)
style.theme_use('clam')
#######################
tabControl = ttk.Notebook(window, style='Custom.TNotebook', width=700, height=320)
cronaca = ttk.Notebook(tabControl)
politica = ttk.Notebook(tabControl)
gossip = ttk.Notebook(tabControl)
tabControl.add(cronaca, text ='Cronaca')
tabControl.add(politica, text ='Politica')
tabControl.add(gossip, text ='Gossip')
tabControl.place(x=1, y=1)
#CRONACA
a = ttk.Frame(cronaca)
canvas = tk.Canvas(a)
scrollbar = ttk.Scrollbar(a, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas, width = 500, height = 500)
scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
#Incidente
a.pack()
cronaca.add(a, text="Incidente")
combo1=ttk.Combobox(scrollable_frame, width = 18)
combo1.place(x=20, y=20)
combo1['value'] = ["text1", "text2"]
combo2=ttk.Combobox(scrollable_frame, width = 18)
combo2.place(x=20, y=80)
combo2['value'] = ["text1", "text2"]
combo3=ttk.Combobox(scrollable_frame, width = 18)
combo3.place(x=20, y=140)
combo3['value'] = ["text1", "text2"]
combo4=ttk.Combobox(scrollable_frame, width = 18)
combo4.place(x=20, y=200)
combo4['value'] = ["text1", "text2"]
canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")
b = ttk.Frame(cronaca)
cronaca.add(b, text="Microcriminalità")
c = ttk.Frame(cronaca)
cronaca.add(c, text="Criminalità")
d = ttk.Frame(cronaca)
cronaca.add(d, text="Disagi")
#tab 2
c = ttk.Frame(politica)
d = ttk.Frame(politica)
window.mainloop()
I have a Main TabControl (Cronaca). Inside I have a second TabControl (Incident).
I would like to insert a third new TabControl called "Example" into Incident. The new Tabcontrol "Example" will have to contain elements such as those comboboxes (those that were previously contained in Incident, then remove them from Incident). How can I do?
Can you show me this simple code? I know, I have already plugged a Tabcontrol into another Tabcontrol, but I am currently confused and in the early stages of Pyhon. Help will be useful to me
P.S: OPTIONAL: My code is probably written in an unordered way. If it is possible, can some good person also make order in the staves? (the staves that come before and the staves that come after). Thank you
from tkinter import *
from tkinter import ttk
import tkinter as tk
window=Tk()
window.attributes('-zoomed', True)
window.configure(bg='#f3f2f2')
style = ttk.Style(window)
style.theme_use('clam')
#######################
tabControl = ttk.Notebook(window, style='Custom.TNotebook', width=700, height=320)
cronaca = ttk.Notebook(tabControl)
politica = ttk.Notebook(tabControl)
gossip = ttk.Notebook(tabControl)
tabControl.add(cronaca, text ='Cronaca')
tabControl.add(politica, text ='Politica')
tabControl.add(gossip, text ='Gossip')
tabControl.place(x=1, y=1)
#CRONACA
a = ttk.Frame(cronaca)
canvas = tk.Canvas(a)
scrollbar = ttk.Scrollbar(a, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas, width = 500, height = 500)
scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
#Incidente
a.pack()
cronaca.add(a, text="Incidente")
combo1=ttk.Combobox(scrollable_frame, width = 18)
combo1.place(x=20, y=20)
combo1['value'] = ["text1", "text2"]
combo2=ttk.Combobox(scrollable_frame, width = 18)
combo2.place(x=20, y=80)
combo2['value'] = ["text1", "text2"]
combo3=ttk.Combobox(scrollable_frame, width = 18)
combo3.place(x=20, y=140)
combo3['value'] = ["text1", "text2"]
combo4=ttk.Combobox(scrollable_frame, width = 18)
combo4.place(x=20, y=200)
combo4['value'] = ["text1", "text2"]
canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")
b = ttk.Frame(cronaca)
cronaca.add(b, text="Microcriminalità")
c = ttk.Frame(cronaca)
cronaca.add(c, text="Criminalità")
d = ttk.Frame(cronaca)
cronaca.add(d, text="Disagi")
#tab 2
c = ttk.Frame(politica)
d = ttk.Frame(politica)
window.mainloop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在“事故”选项卡中创建另一个
笔记本
,然后将可滚动框架放入新的笔记本
中的“示例”选项卡中。以下是更新的代码:
You can create another
Notebook
inside "Incidente" tab and put the scrollable frame inside a "Example" tab inside the newNotebook
.Below is the updated code: