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 f84baa8

Browse files
Make active hello buttons.
Press buttons to display hello-message in root window in the form of label.
1 parent b3882eb commit f84baa8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎src/program2.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'''
2+
Created on Aug 12, 2017
3+
4+
@author: Aditya
5+
'''
6+
7+
import tkinter as tk
8+
from tkinter import ttk
9+
10+
class Helloapp:
11+
def __init__(self, master):
12+
# display label in main window master
13+
self.label = ttk.Label(master, text = 'Hello, World and This is Python3.6 speaking')
14+
15+
# place the label using grid method in the main window
16+
self.label.grid(row =0, column =0, columnspan=2)
17+
18+
# Create and place button below label
19+
ttk.Button(master, text = 'Delhi', command = self.delhi_hello).grid(row=1, column=0)
20+
ttk.Button(master, text = 'Pune', command = self.pune_hello).grid(row=1, column=1)
21+
22+
def delhi_hello(self):
23+
self.label.config(text = 'Namaste Duniya, main Python hu.')
24+
25+
def pune_hello(self):
26+
self.label.config(text = 'Bhava, hey Python3.6 ahe.')
27+
28+
29+
30+
def HelloAppLaunch():
31+
root = tk.Tk()
32+
Helloapp(root)
33+
root.mainloop()
34+
35+
def test():
36+
HelloAppLaunch()
37+
38+
if __name__ == '__main__':test()

0 commit comments

Comments
(0)

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