Skip to content

Commit 3a9d503

Browse files
committed
python-GUI
1 parent b8e439e commit 3a9d503

11 files changed

Lines changed: 140 additions & 0 deletions

File tree

python_GUI/gui-butty.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from tkinter import *
2+
import tkinter.messagebox as messagebox
3+
4+
class Application(Frame):
5+
def __init__(self, master=None):
6+
Frame.__init__(self, master)
7+
self.pack()
8+
self.createWidgets()
9+
10+
def createWidgets(self):
11+
self.nameInput = Entry(self)
12+
self.nameInput.pack()
13+
self.alertButton = Button(self, text='Hello', command=self.hello)
14+
self.alertButton.pack()
15+
16+
def hello(self):
17+
name = self.nameInput.get() or 'world'
18+
messagebox.showinfo('Message', 'Hello, %s' % name)
19+
20+
app = Application()
21+
# 设置窗口标题:
22+
app.master.title('Hello World')
23+
# 主消息循环:
24+
app.mainloop()

python_GUI/py-Tkinter/1.gif

113 KB
Loading

python_GUI/py-Tkinter/1.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#python tkinter image
2+
3+
from tkinter import *
4+
5+
6+
def main():
7+
filename =r'./1.gif'
8+
root = Tk()
9+
img = PhotoImage(file=filename)
10+
label = Label(root, image=img)
11+
label.pack()
12+
root.mainloop()
13+
14+
main()

python_GUI/py-Tkinter/2.gif

80.5 KB
Loading

python_GUI/py-Tkinter/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
这部分是使用于python-tkinter的编程,
2+
分别是建立文字,文本,按钮,图片,
3+
使用图片则是必须要是gif的格式,如果需要弄出别的格式,需要再安装插件。
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#coding:utf-8
2+
from tkinter import *
3+
root = Tk()
4+
root.title("hello,world")
5+
#root.geometry('300x200')#是x不是*
6+
#root.resizable(width=False, height=True)
7+
Label(root, text='caret-button',font=('Arial', 20)).pack()
8+
temp = 0;
9+
10+
11+
def printhello():
12+
t.insert('1.0','123123\n')
13+
14+
filepwd = '1.gif'
15+
img = PhotoImage(file=filepwd)
16+
label = Label(root,image=img)
17+
label.pack()
18+
19+
t = Text()
20+
t.pack()
21+
22+
Button(root,text="press",command = printhello).pack()
23+
24+
root.mainloop()
25+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#coding:utf-8
2+
from tkinter import *
3+
root = Tk()
4+
root.title("hello,world")
5+
#root.geometry('300x200')#是x不是*
6+
#root.resizable(width=False, height=True)
7+
#Label(root, text='caret-button',font=('Arial', 20)).pack()
8+
temp = 0;
9+
def printhello():
10+
temp += 1
11+
str_temp = str(temp)
12+
t.insert('1.0',str_temp+'\n')
13+
14+
t = Text()
15+
t.pack()
16+
17+
Button(root,text="press",command = printhello).pack()
18+
19+
root.mainloop()
20+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: cp936 -*-
2+
from tkinter import *
3+
root = Tk()
4+
root.title("hello world")
5+
root.geometry()
6+
7+
def printhello():
8+
t.insert('1.0', "hello\n")
9+
10+
t = Text()
11+
t.pack()
12+
Button(root, text="press", command = printhello).pack()
13+
root.mainloop()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#coding:utf-8
2+
from tkinter import *
3+
root = Tk()
4+
root.title("hello,world")
5+
root.geometry('300x200')#是x不是*
6+
Label(root, text='creat-entry',font=('Arial', 20)).pack()
7+
8+
var = StringVar()
9+
e = Entry(root,textvariable = var)
10+
var.set("hello")
11+
e.pack()
12+
13+
root.mainloop()
14+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#coding:utf-8
2+
from tkinter import *
3+
import time
4+
root = Tk()
5+
root.title("hello,world")
6+
root.geometry('300x200')#是x不是*
7+
root.resizable(width=False, height=True)
8+
Label(root, text='creat-text',font=('Arial', 20)).pack()
9+
10+
t = Text(root)
11+
t.pack()
12+
t.insert(1.0,'hello\n')
13+
t.insert(END,'hello111\n')
14+
t.insert(END,'hello222')
15+
t.insert(END,'hello333\n')
16+
root.mainloop()
17+

0 commit comments

Comments
 (0)