We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e1333b commit f63c854Copy full SHA for f63c854
1 file changed
py3/gui/hello_gui.py
@@ -0,0 +1,27 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+
4
+from tkinter import *
5
+import tkinter.messagebox as messagebox
6
7
+class Application(Frame):
8
+ def __init__(self, master=None):
9
+ Frame.__init__(self, master)
10
+ self.pack()
11
+ self.createWidgets()
12
13
+ def createWidgets(self):
14
+ self.nameInput = Entry(self)
15
+ self.nameInput.pack()
16
+ self.alertButton = Button(self, text='Hello', command=self.hello)
17
+ self.alertButton.pack()
18
19
+ def hello(self):
20
+ name = self.nameInput.get() or 'world'
21
+ messagebox.showinfo('Message', 'Hello, %s' % name)
22
23
+app = Application()
24
+# 设置窗口标题:
25
+app.master.title('Hello World')
26
+# 主消息循环:
27
+app.mainloop()
0 commit comments