Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1582656

Browse files
App using Frame in tkinter
1 parent 79538ff commit 1582656

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎src/program9.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'''
2+
Created on Oct 26, 2017
3+
4+
@author: Aditya
5+
This function demonstrates the use of frames in tkinter
6+
'''
7+
8+
import tkinter as tk
9+
from tkinter import ttk
10+
11+
class DisplayApp:
12+
def __init__(self, master):
13+
self.frame = ttk.Frame(master, width = 100, height = 100) # frame height and width are in pixel
14+
self.frame.pack()
15+
self.frame.config(relief = tk.RAISED) # to define frame boarder
16+
self.button = ttk.Button(self.frame, text = 'Click for Magic')
17+
self.button.config(command = self.performMagic)
18+
self.button.grid() # use grid geometry manager
19+
self.frame.config(padding = (30,15))
20+
21+
self.lbfrm = ttk.LabelFrame(master, width = 100, height = 100)
22+
self.lbfrm.config(padding = (30, 15))
23+
self.lbfrm.config(text = "Magic Below")
24+
self.lbfrm.pack()
25+
self.label = ttk.Label(self.lbfrm, text = "Waiting for Magic")
26+
self.label.grid()
27+
28+
def performMagic(self):
29+
if self.label['text'] == "Waiting for Magic":
30+
self.label.config(text = 'Magic Performed')
31+
else:
32+
self.label.config(text = "Waiting for Magic")
33+
34+
def DisplayAppLaunch():
35+
root = tk.Tk()
36+
DisplayApp(root)
37+
tk.mainloop()
38+
39+
if __name__ == '__main__':
40+
DisplayAppLaunch()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /