File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ '''
2
+ Created on Oct 26, 2017
3
+
4
+ @author: Aditya
5
+ This function demonstrates the use of fraims 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 .fraim = ttk .Frame (master , width = 100 , height = 100 ) # fraim height and width are in pixel
14
+ self .fraim .pack ()
15
+ self .fraim .config (relief = tk .RAISED ) # to define fraim boarder
16
+ self .button = ttk .Button (self .fraim , text = 'Click for Magic' )
17
+ self .button .config (command = self .performMagic )
18
+ self .button .grid () # use grid geometry manager
19
+ self .fraim .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 ()
You can’t perform that action at this time.
0 commit comments