An open API service indexing awesome lists of open source software.

https://github.com/0xff-dev/tkinter

python GUI ✌🏻
https://github.com/0xff-dev/tkinter

Last synced: 11 months ago
JSON representation

python GUI ✌🏻

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`为菜单添加分割线.