update,
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
|
||||
LARGEFONT =("Verdana", 35)
|
||||
|
||||
class tkinterApp(tk.Tk):
|
||||
|
||||
# __init__ function for class tkinterApp
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
# __init__ function for class Tk
|
||||
tk.Tk.__init__(self, *args, **kwargs)
|
||||
|
||||
# creating a container
|
||||
container = tk.Frame(self)
|
||||
container.pack(side = "top", fill = "both", expand = True)
|
||||
|
||||
container.grid_rowconfigure(0, weight = 1)
|
||||
container.grid_columnconfigure(0, weight = 1)
|
||||
|
||||
# initializing frames to an empty array
|
||||
self.frames = {}
|
||||
|
||||
# iterating through a tuple consisting
|
||||
# of the different page layouts
|
||||
for F in (StartPage, Page1, Page2):
|
||||
|
||||
frame = F(container, self)
|
||||
|
||||
# initializing frame of that object from
|
||||
# startpage, page1, page2 respectively with
|
||||
# for loop
|
||||
self.frames[F] = frame
|
||||
|
||||
frame.grid(row = 0, column = 0, sticky ="nsew")
|
||||
|
||||
self.show_frame(StartPage)
|
||||
|
||||
# to display the current frame passed as
|
||||
# parameter
|
||||
def show_frame(self, cont):
|
||||
frame = self.frames[cont]
|
||||
frame.tkraise()
|
||||
|
||||
# first window frame startpage
|
||||
|
||||
class StartPage(tk.Frame):
|
||||
def __init__(self, parent, controller):
|
||||
tk.Frame.__init__(self, parent)
|
||||
|
||||
# label of frame Layout 2
|
||||
label = ttk.Label(self, text ="Startpage", font = LARGEFONT)
|
||||
|
||||
# putting the grid in its place by using
|
||||
# grid
|
||||
label.grid(row = 0, column = 4, padx = 10, pady = 10)
|
||||
|
||||
button1 = ttk.Button(self, text ="Page 1",
|
||||
command = lambda : controller.show_frame(Page1))
|
||||
|
||||
# putting the button in its place by
|
||||
# using grid
|
||||
button1.grid(row = 1, column = 1, padx = 10, pady = 10)
|
||||
|
||||
## button to show frame 2 with text layout2
|
||||
button2 = ttk.Button(self, text ="Page 2",
|
||||
command = lambda : controller.show_frame(Page2))
|
||||
|
||||
# putting the button in its place by
|
||||
# using grid
|
||||
button2.grid(row = 2, column = 1, padx = 10, pady = 10)
|
||||
|
||||
|
||||
|
||||
|
||||
# second window frame page1
|
||||
class Page1(tk.Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
|
||||
tk.Frame.__init__(self, parent)
|
||||
label = ttk.Label(self, text ="Page 1", font = LARGEFONT)
|
||||
label.grid(row = 0, column = 4, padx = 10, pady = 10)
|
||||
|
||||
# button to show frame 2 with text
|
||||
# layout2
|
||||
button1 = ttk.Button(self, text ="StartPage",
|
||||
command = lambda : controller.show_frame(StartPage))
|
||||
|
||||
# putting the button in its place
|
||||
# by using grid
|
||||
button1.grid(row = 1, column = 1, padx = 10, pady = 10)
|
||||
|
||||
# button to show frame 2 with text
|
||||
# layout2
|
||||
button2 = ttk.Button(self, text ="Page 2",
|
||||
command = lambda : controller.show_frame(Page2))
|
||||
|
||||
# putting the button in its place by
|
||||
# using grid
|
||||
button2.grid(row = 2, column = 1, padx = 10, pady = 10)
|
||||
|
||||
|
||||
|
||||
|
||||
# third window frame page2
|
||||
class Page2(tk.Frame):
|
||||
def __init__(self, parent, controller):
|
||||
tk.Frame.__init__(self, parent)
|
||||
label = ttk.Label(self, text ="Page 2", font = LARGEFONT)
|
||||
label.grid(row = 0, column = 4, padx = 10, pady = 10)
|
||||
|
||||
# button to show frame 2 with text
|
||||
# layout2
|
||||
button1 = ttk.Button(self, text ="Page 1",
|
||||
command = lambda : controller.show_frame(Page1))
|
||||
|
||||
# putting the button in its place by
|
||||
# using grid
|
||||
button1.grid(row = 1, column = 1, padx = 10, pady = 10)
|
||||
|
||||
# button to show frame 3 with text
|
||||
# layout3
|
||||
button2 = ttk.Button(self, text ="Startpage",
|
||||
command = lambda : controller.show_frame(StartPage))
|
||||
|
||||
# putting the button in its place by
|
||||
# using grid
|
||||
button2.grid(row = 2, column = 1, padx = 10, pady = 10)
|
||||
|
||||
|
||||
# Driver Code
|
||||
app = tkinterApp()
|
||||
app.mainloop()
|
9
hdhdjshxh/task2/_poc/grid/looptest.bat
Normal file
9
hdhdjshxh/task2/_poc/grid/looptest.bat
Normal file
@@ -0,0 +1,9 @@
|
||||
@REM rm *.bas
|
||||
@REM rm *.frm
|
||||
@REM rm *.frx
|
||||
@REM timeout 1
|
||||
|
||||
:loop
|
||||
python test.py
|
||||
timeout /t 1
|
||||
goto loop
|
32
hdhdjshxh/task2/_poc/grid/test.py
Normal file
32
hdhdjshxh/task2/_poc/grid/test.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
|
||||
root = Tk()
|
||||
|
||||
content = ttk.Frame(root)
|
||||
frame = ttk.Frame(content, borderwidth=5, relief="ridge", width=200, height=100)
|
||||
namelbl = ttk.Label(content, text="Name")
|
||||
name = ttk.Entry(content)
|
||||
|
||||
onevar = BooleanVar(value=True)
|
||||
twovar = BooleanVar(value=False)
|
||||
threevar = BooleanVar(value=True)
|
||||
|
||||
one = ttk.Checkbutton(content, text="One", variable=onevar, onvalue=True)
|
||||
two = ttk.Checkbutton(content, text="Two", variable=twovar, onvalue=True)
|
||||
three = ttk.Checkbutton(content, text="Three", variable=threevar, onvalue=True)
|
||||
ok = ttk.Button(content, text="Okay")
|
||||
cancel = ttk.Button(content, text="Cancel")
|
||||
|
||||
content.grid(column=0, row=0)
|
||||
frame.grid(column=0, row=0, columnspan=3, rowspan=2)
|
||||
namelbl.grid(column=3, row=0, columnspan=2)
|
||||
|
||||
name.grid(column=3, row=1, columnspan=2)
|
||||
one.grid(column=0, row=3)
|
||||
two.grid(column=1, row=3)
|
||||
three.grid(column=2, row=3)
|
||||
ok.grid(column=3, row=3)
|
||||
cancel.grid(column=4, row=3)
|
||||
|
||||
root.mainloop()
|
Reference in New Issue
Block a user