https://github.com/0xff-dev/tkinter
python GUI ✌🏻
https://github.com/0xff-dev/tkinter
Last synced: 11 months ago
JSON representation
python GUI ✌🏻
- Host: GitHub
- URL: https://github.com/0xff-dev/tkinter
- Owner: 0xff-dev
- Created: 2019-04-17T15:12:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T12:58:30.000Z (over 6 years ago)
- Last Synced: 2025-02-02T08:27:26.642Z (about 1 year ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tkinter
python GUI ✌🏻
## 按钮与事件的绑定
1. 通过`command`绑定
```python
def new_label():
global root
label = Label(root, text="lable")
label.pack()
root = Tk()
btn = Button(paretn, command=func)
bnt.pack()
root.mainloop()
```
2. `bind`完成事件的绑定
> `bind(event_type, event_func)`
> 事件介绍 鼠标左键,鼠标右键, 按下A, B 等按键. F按键
> `bind`函数可以做全程序级别的绑定`bind_all`, 全局绑定快捷键. `bind_class` 绑定类别。`w.bind_class("Entry", " 解除绑定`unbind`
```python
def new_label(event):
global root
label = Label(root, text="lable")
label.pack()
root = Tk()
btn = Button(root, text="Button1")
btn.bind("", new_lable)
bnt.pack()
root.mainloop()
```
## 菜单
> Menu(parent), 使用`add_command`增加菜单, `add_cascade`及联添加子选项.
> 弹出菜单, 由`Menu.post`制作
> `add_separator`为菜单添加分割线.