I want to get the split screen, where if i click a button in the left screen then frame should be shown in the right screen. So i used Panedwindow with 2 different frames (rightframe and leftframe). Gave buttons in the leftframe (button1 and button2). If i click the button1 then Frame1 (class Frame1) should be shown in the rightframe and if i click the button2 then Frame2 (class Frame2) should be shown in the rightframe so used raiseFrame to change the frame accordingly but getting below error if i click the button.
import tkinter as tk
from tkinter import *
from tkinter import ttk,Tk, BOTH, Menu
def raiseFrame(frame):
frame.tkraise()
class Main(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
m = PanedWindow(height=500, width=1000)
m.pack(side=tk.RIGHT,fill = tk.Y)
leftframe = Frame(m)
m.add(leftframe)
button1 =tk.Button(leftframe, text="first frame",command=lambda: raiseFrame(Frame1))
button1.pack(side = tk.TOP, expand=1)
button2 =tk.Button(leftframe, text="2nd frame",command=lambda: raiseFrame(Frame2))
button2.pack(side = tk.TOP, expand=1)
rightframe= Frame(m, bg="green")
m.add(rightframe)
class Frame1(tk.Frame):
def __init__(self):
tk.Frame.__init__(self, parent)
label = tk.Label(rightframe, text="1st FRAME").pack(side = tk.LEFT,fill = tk.BOTH)
class Frame2(tk.Frame):
def __init__(self):
tk.Frame.__init__(self,parent)
label = tk.Label(rightframe, text="2nd FRAME").pack(side = tk.LEFT,fill = tk.BOTH)
app = Main()
app.mainloop()
error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Python\Python38\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Users\New folder\GUI.py", line 23, in <lambda>
button1 =tk.Button(leftframe, text="first frame",command=lambda: raiseFrame(Frame1))
File "C:\Users\New folder\GUI.py", line 7, in raiseFrame
frame.tkraise()
TypeError: tkraise() missing 1 required positional argument: 'self'