Python: tkinter实例 简单介绍
来源:互联网 发布:北京软件开发培训 编辑:程序博客网 时间:2024/05/29 02:51
#!/usr/bin/env python3.3#coding=utf-8import tkinter as tkfrom tkinter import ttkdef sample1_hello_title(): '''1, 最简单''' root = tk.Tk() root.title('你好, 这是tkinter世界!') root.mainloop()def sample2_hello_label(): '''2, 添加一个标签''' root = tk.Tk() root.title('示例') label = ttk.Label(root, text='你好,欢迎来到tkinter世界!') label.pack() root.mainloop()def sample3_hello2(): class Application(object): def __init__(self, master=None): self.master = master frame = ttk.Frame(master) frame.pack(expand="yes", fill="both") #输入框 self.msgVar = tk.StringVar() self.msgVar.set('欢迎来到tkinter的世界') self.input = ttk.Entry(frame, textvariable=self.msgVar) self.input.pack(fill='x', padx=10, pady=10) #提示信息框 self.caption = ttk.Label(frame,text='') self.caption.pack(expand='yes') #命令面板 commandpane = ttk.Frame(frame) commandpane.pack(pady=10) self.btnHello = ttk.Button(commandpane, text='您好', command=self.say_hi) self.btnHello.pack(side='left') self.button = ttk.Button(commandpane, text='退出', command=frame.quit) self.button.pack() def say_hi(self): self.caption['text']= '你好,%s!' % self.input.get() app = Application(tk.Tk()) app.master.mainloop()if __name__ == '__main__': #sample1_hello_title() #sample2_hello_label() sample3_hello2()
0 0
- Python: tkinter实例 简单介绍
- Python 图形界面 GUI Tkinter 实例
- Python Tkinter 简单布局学习
- Python Tkinter 简单登录界面
- python tkinter实现简单计算器
- Python Tkinter 简单登录界面
- Python: tkinter实例 更名小工具
- Python: tkinter实例改名小工具
- python tkinter GUI 程序简易实例
- Python简单介绍,单向链表实例
- Python GUI——Tkinter~简单入门
- python——Tkinter的简单学习
- python tkinter 实现简单计算器2
- python中Tkinter模块的简单应用
- python Tkinter Text的简单用法
- Python Tkinter实现的简单计算器
- python+Tkinter+多线程 简单例子1
- python GUI编程(Tkinter)简单使用
- android:adb环境变量的配置
- Mongodb VS Hbase
- NYOJ 478 月老的烦恼(1)
- 需求文档怎么编写
- sql2000 安装配置失败 C:\WINNT\sqlstp.log(转)
- Python: tkinter实例 简单介绍
- GDB使用
- C#:[StructLayout(LayoutKind.Sequential)]
- jQueryEasyUI
- Fuel 3D 扫描仪
- 代码面试最常用的10大算法
- hack-前期中期后期
- 【算法导论实验2】快速排序与第i小数问题
- CUDA:低占用率下的更好性能(一)