之前在网上看到别人写的桌面程序非常漂亮
很想自己也写出像 huhumhire-hosts 那样漂亮的桌面应用程序
仔细一查,原来是用 PyQt 写的,于是自己也下定了决心来学学这个
目前国内好像没有多少关于这方面的比较系统的入门教程
于是只好自己摸索。
一次偶然的机会,在油土鳖上看到了一个比较不错的视频
https://www.youtube.com/watch?v=DF_44sWnAsk&list=PLQVvvaa0QuDdVpDFNq4FwY9APZPGSUyR4
听了下这个大神讲的课,感觉非常不错,虽然可能需要点英语水平,不过不是什么大问题
这里就把他所讲到的这些例子给列出来吧
1、Hello World 程序(QMainWindow)
一个最简单的 PyQt4 窗口程序:
1 | # -*- coding: utf-8 -*- |
2、按钮控件 Buttons(QPushButton)
在上例的基础上添加代码:
1 | # -*- coding: utf-8 -*- |
3、按钮事件控制 Button Functions
在上例的基础上添加代码:
1 | # -*- coding: utf-8 -*- |
4、菜单栏 menubar(QMenuBar)
1 | # -*- coding: utf-8 -*- |
效果图:
5、工具栏 toolbar(QToolBar)
1 | import sys |
效果图
6、弹出消息窗口 pop up message(QMessageBox)
1 | # coding: utf-8 |
效果图
7、复选框 check box(QCheckBox)
1 | # coding: utf-8 |
效果图
8、进度条 progress bar(QProgressBar)
1 | # coding: utf-8 |
效果图
9、下拉菜单 drop down combobox(QComboBox)
1 | # coding: utf-8 |
效果图
10、字体选择器 font widget(QFontDialog)
1 | # coding: utf-8 |
效果图
11、颜色选择器与日历控件 color pickup widget and calendar(QColorDialog, QCalendarWidget)
1 | # coding: utf-8 |
效果图
12、文本编辑器 editor textedit(QTextEdit)
1 | # coding: utf-8 |
效果图
13、文件选择器 file picker(QFileDialog)
1 | # coding: utf-8 |
效果图