pyqt5 学习笔记五 (布局:QGridLayout)
目录
写在前面:
①本教程使用pycharm编译器进行pyqt5的学习,安装教程请大家自行百度
②本系列博客根据B站王铭东博主教程学习 学习代码 笔记5
链接:https://pan.baidu.com/s/1i3y4mI_9N84iAC6tav-j8Q
提取码:gupx
资料:
【1】B站教程
【2】B站教程配套课件
【3】PyQt官网的所有模块 (有部分内容没有补充进去)
【4】C++具体实现的API文档
布局器
共有四种:
QBoxLayout:垂直水平布局器
QGridLayout:网格布局器
QFormLayout:表单布局器
QStackedLayout:抽屉布局器
(一)字典
参考链接:
【1】python字典:https://blog.csdn.net/weixin_40581859/article/details/126235852
【2】enumerate() 函数:https://www.runoob.com/python/python-func-enumerate.html
1、字典的遍历 items()
data = {
0: ["7", "8", "9", "+", "("],
1: ["4", "5", "6", "-", ")"],
2: ["1", "2", "3", "*", "<-"],
3: ["0", ".", "=", "/", "C"]
}
for temp in data.items():
print(temp)
for temp1, temp2 in data.items():
print("temp1:", temp1)
print("temp2:", temp2)
temp输出:
(0, ['7', '8', '9', '+', '('])
(1, ['4', '5', '6', '-', ')'])
(2, ['1', '2', '3', '*', '<-'])
(3, ['0', '.', '=', '/', 'C'])
temp1与temp2输出:
temp1: 0
temp2: ['7', '8', '9', '+', '(']
temp1: 1
temp2: ['4', '5', '6', '-', ')']
temp1: 2
temp2: ['1', '2', '3', '*', '<-']
temp1: 3
temp2: ['0', '.', '=', '/'