【问题标题】:Having two different Frames into two different tabs in Tkinter Notbook [closed]在 Tkinter Notbook 中将两个不同的框架放入两个不同的选项卡 [关闭]
【发布时间】:2015-12-15 10:17:31
【问题描述】:

我试图在我的程序中将两个不同的框架放入两个不同的选项卡中。我怎样才能做到这一点。每次我执行程序时,我只会得到一种颜色。似乎 frame2 覆盖了另一个框架。谢谢

from Tkinter import *
from ttk import *


class Application:
    def __init__(self, master):
        self.create_widgets()
        self.trip = {}
        self.frameinMaintabA()

    def create_widgets(self):
      self.notebook = Notebook()   # Widgets

      self.tabA = Frame(self.notebook)
      self.tabB = Frame(self.notebook)
      self.tab3 = Frame(self.notebook)
      self.mainA = Notebook(self.tabA)
      self.tabA1 = Frame(self.mainA)
      self.tabA2 = Frame(self.mainA)

      self.mainA.add(self.tabA1, text = "tabA1")
      self.mainA.add(self.tabA2, text = "tabA2")
      self.mainA.pack(fill = 'both', expand = 1, padx = 10, pady = 10)

      self.notebook.add(self.tabA, text = "tabA")
      self.notebook.add(self.tabB,  text= "tabB")
      self.notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)



    def frameinMaintabA(self):

        self.style = Style()
        self.style.configure('frame.TFrame', background='grey')
        self.frame = Frame( self.tabA1,style='frame.TFrame')
        self.frame.place(height=40, width=70, x=158, y=109)


        self.style2 = Style()
        self.style2.configure('frame.TFrame', background='blue')
        self.frame2 = Frame( self.tabA2,style='frame.TFrame')
        self.frame2.place(height=40, width=70, x=158, y=109)




root = Tk()
root.title("Test")
root.geometry("400x400")
app = Application(root)
root.mainloop()

【问题讨论】:

    标签: python python-2.7 user-interface tkinter


    【解决方案1】:

    没关系,伙计们,我能够找出我的错误。 我注意到代码中缺少“frame2.Tframe”

        self.style2 = Style()
        self.style2.configure('frame2.TFrame', background='blue')
        self.frame2 = Frame( self.tabA2,style='frame2.TFrame')
        self.frame2.place(height=40, width=70, x=158, y=109)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-28
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多