from tkinter import *
import tkinter as tk
class Win1(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
Label(self, text= "ISMC", font= ('Helvetica 20 bold')).pack(padx=5, pady=5)
b1=Button(self, text="AUTO", command=lambda:controller.show_frame(Win2)).pack(padx=5, pady=5)
class Win2(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
b1=Button(self, text= "button 1", command=lambda:controller.show_frame(Win3)).pack(padx=5, pady=5)
b2=Button(self, text= "button 1").pack(padx=5, pady=5)
b3=Button(self, text= "button 3").pack(padx=5, pady=5)
b4=Button(self, text= "PROCEED").pack(padx=5, pady=5)
b5=Button(self, text= "BACK", command=lambda:controller.show_frame(Win1)).pack(padx=5, pady=5)
class Win3(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
val_x=0
val_y=10
self.vars = []
self.array = []
for i in range(3):
self.array.append("RELAY " + str(i+1))
self.vars.append(StringVar())
self.vars[-1].set(0)
c1=Checkbutton(self, text=self.array[i], variable=self.vars[-1], onvalue=1, offvalue=0).place(x=val_x, y=val_y)
if i<=3:
val_x=val_x+0
val_y=val_y+50
b1=Button(self, text="back", bg="red", fg="white", command=lambda:controller.show_frame(Win2)).place(x=30,y=140)
b2=Button(self, text="proceed", bg="green", fg="white").place(x=30,y=160)
b3=Button(self, text= "Select All").place()
class Application(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
window = tk.Frame(self)
window.pack(side = "top", fill = "both", expand = True)
self.frames = {}
for F in (Win1, Win2, Win3):
frame = F(window, self)
self.frames[F] = frame
frame.grid(row = 0, column=0, sticky="nsew")
self.show_frame(Win1)
def show_frame(self, window):
frame = self.frames[window]
frame.tkraise()
self.title("Test")
self.geometry('1500x1500')
app = Application()
app.mainloop()
I need to select all checkboxes in my window 3 and give that command to a button "AUTO" which is present in window 1. I tried many times but i don't know how to do that?
Can anyone please help. I am beginner of programming.
Aucun commentaire:
Enregistrer un commentaire