Skip to content

Commit 20bd24a

Browse files
author
admin
committed
- 添加message_input控件
- 添加WidgetHelper用于快速构建ui的类
1 parent 29df18b commit 20bd24a

File tree

11 files changed

+1393
-105
lines changed

11 files changed

+1393
-105
lines changed

.gitignore

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
pip-wheel-metadata/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
76+
# PyBuilder
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
.python-version
88+
89+
# pipenv
90+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
92+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
93+
# install all needed dependencies.
94+
#Pipfile.lock
95+
96+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
97+
__pypackages__/
98+
99+
# Celery stuff
100+
celerybeat-schedule
101+
celerybeat.pid
102+
103+
# SageMath parsed files
104+
*.sage.py
105+
106+
# Environments
107+
.env
108+
.venv
109+
env/
110+
venv/
111+
ENV/
112+
env.bak/
113+
venv.bak/
114+
115+
# Spyder project settings
116+
.spyderproject
117+
.spyproject
118+
119+
# Rope project settings
120+
.ropeproject
121+
122+
# mkdocs documentation
123+
/site
124+
125+
# mypy
126+
.mypy_cache/
127+
.dmypy.json
128+
dmypy.json
129+
130+
# Pyre type checker
131+
.pyre/
132+
133+
.idea/
134+
.gitignore

ExampleButton.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
__author__ = "liaokong"
33
__time__ = "2018/11/16 10:02"
44

5-
from PySide import QtGui
5+
from PySide2.QtWidgets import *
66

77
from Utils import load_style, button_style
88

99
button_style_list = ['MediumGray', 'DarkGray', 'BlueJeans', 'Aqua',
1010
'Mint', 'Grass', 'Sunflower', 'Bittersweet', 'Grapefruit', 'Lavender', 'PinkRose']
1111

1212

13-
class ExampleButtonWid(QtGui.QDialog):
13+
class ExampleButtonWid(QDialog):
1414
def __init__(self, parent=None):
1515
super(ExampleButtonWid, self).__init__(parent)
1616

1717
load_style(self)
1818

19-
v_layout = QtGui.QVBoxLayout(self)
19+
v_layout = QVBoxLayout(self)
2020

2121
for style in button_style_list:
22-
btn = QtGui.QPushButton(style)
22+
btn = QPushButton(style)
2323
btn.setMinimumWidth(185)
2424
btn.setMinimumHeight(30)
2525

@@ -30,7 +30,7 @@ def __init__(self, parent=None):
3030

3131

3232
if __name__ == '__main__':
33-
app = QtGui.QApplication([])
33+
app = QApplication([])
3434

3535
eb = ExampleButtonWid()
3636
eb.show()

ExampleHelper.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Time : 2020/11/10 21:22
3+
# Author : LiaoKong
4+
5+
from PySide2.QtGui import *
6+
from PySide2.QtCore import *
7+
from PySide2.QtWidgets import *
8+
9+
from helper import WidgetHelper
10+
11+
12+
class ExampleWidget(QDialog):
13+
def __init__(self, parent=None):
14+
super(ExampleWidget, self).__init__(parent)
15+
16+
widget_helper = WidgetHelper(self, True)
17+
18+
self.name_line = widget_helper.line_edit(placeholder=u'请输入姓名')
19+
header_layout = widget_helper.h_layout(
20+
[widget_helper.label(u'名字'), self.name_line])
21+
22+
self.gender = widget_helper.combobox([u'男', u'女', u'保密'], min_w=125)
23+
body_layout = widget_helper.h_layout(
24+
[widget_helper.label(u'性别'), self.gender, widget_helper.h_spacer()])
25+
26+
self.thing_list_widget = widget_helper.list(
27+
['a', 'b', 'c'], itemClicked=self.item_clicked)
28+
self.btn = widget_helper.btn(u'保存', min_h=35, clicked=self.btn_clicked)
29+
30+
widget_helper.v_layout(
31+
[
32+
header_layout,
33+
body_layout,
34+
self.thing_list_widget,
35+
self.btn,
36+
widget_helper.v_spacer()
37+
],
38+
self, spacing=16)
39+
40+
def btn_clicked(self):
41+
print(666)
42+
43+
def item_clicked(self, item):
44+
print(item)
45+
46+
47+
if __name__ == '__main__':
48+
app = QApplication([])
49+
50+
ew = ExampleWidget()
51+
ew.setFocus()
52+
ew.show()
53+
54+
app.exec_()

0 commit comments

Comments
 (0)