Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
devwiki:python_qt [2021/09/17 08:23] – [Simple Window] ying | devwiki:python_qt [2024/01/06 20:35] – [Text Widget] ying | ||
---|---|---|---|
Line 182: | Line 182: | ||
* python 3 <code python> | * python 3 <code python> | ||
+ | **user input module** | ||
+ | * python 2 <code python>a = int(raw_input())</ | ||
+ | * python 3 <code python>a = int(input())</ | ||
===== Break 2: PySide vs PyQt ===== | ===== Break 2: PySide vs PyQt ===== | ||
Line 363: | Line 366: | ||
* get global text color <code python> | * get global text color <code python> | ||
text_color = self.palette().color(QtGui.QPalette.Text).name() | text_color = self.palette().color(QtGui.QPalette.Text).name() | ||
+ | </ | ||
+ | * list all current color palette of default in app <code python> | ||
+ | from PySide2 import QtCore, QtGui, QtWidgets | ||
+ | import MyToolName | ||
+ | ui = MyToolName.main() | ||
+ | color_info = ui.palette().color(QtGui.QPalette.Dark).name() | ||
+ | print(' | ||
+ | |||
+ | color_roles = [ | ||
+ | QtGui.QPalette.WindowText, | ||
+ | QtGui.QPalette.Dark, | ||
+ | QtGui.QPalette.ButtonText, | ||
+ | QtGui.QPalette.Highlight, | ||
+ | QtGui.QPalette.AlternateBase, | ||
+ | ] | ||
+ | |||
+ | print(" | ||
+ | for role in color_roles: | ||
+ | color = ui.palette().color(role) | ||
+ | print(f" | ||
</ | </ | ||
* apply style sheet file <code python> | * apply style sheet file <code python> | ||
Line 1138: | Line 1161: | ||
my_layout.setAlignment(QtCore.Qt.AlignTop) | my_layout.setAlignment(QtCore.Qt.AlignTop) | ||
</ | </ | ||
- | * QGridLayout <code python> | + | * QGridLayout <code python> |
+ | |||
+ | # -- make grid equal size for all cells | ||
+ | cur_layout = ui[' | ||
+ | # for i in range( cur_layout.rowCount() ): | ||
+ | # cur_layout.setRowStretch( i, 1) | ||
+ | for j in range( cur_layout.columnCount() ): | ||
+ | cur_layout.setColumnStretch( j, 1 ) | ||
+ | |||
+ | </ | ||
* QFormLayout | * QFormLayout | ||
* QSplitter <code python> | * QSplitter <code python> | ||
Line 1178: | Line 1210: | ||
self.uiList[' | self.uiList[' | ||
self.uiList[' | self.uiList[' | ||
+ | </ | ||
+ | * QLineEdit password hide <code python> | ||
+ | self.uiList[' | ||
</ | </ | ||
* QTextEdit make it accept plain text only <code python> | * QTextEdit make it accept plain text only <code python> | ||
Line 1370: | Line 1405: | ||
# make tree item editable for all columes | # make tree item editable for all columes | ||
new_node.setFlags(new_node.flags()|QtCore.Qt.ItemIsEditable) | new_node.setFlags(new_node.flags()|QtCore.Qt.ItemIsEditable) | ||
+ | |||
+ | # change align | ||
+ | new_node.setTextAlignment(i, | ||
+ | |||
+ | # change bg to pink | ||
+ | new_node.setBackgroundColor(0, | ||
+ | |||
+ | # set to brush and reset to default | ||
+ | self.brush[' | ||
+ | currentNode.setBackground(0, | ||
+ | currentNode.setData(0, | ||
</ | </ | ||
* make tree item editable only for some columes <code python> | * make tree item editable only for some columes <code python> | ||
Line 1886: | Line 1932: | ||
* so now I am moving to Qt + C++ solutions to explore more binary tools development using the same knowledge from python QT side. | * so now I am moving to Qt + C++ solutions to explore more binary tools development using the same knowledge from python QT side. | ||
+ | |||
+ | ====== Problem and Solution ====== | ||
+ | |||
+ | * Problem: qt.qpa.fonts: | ||
+ | * end-user-defined characters (EUDCs), just delete related regedit entry \HKEY_CURRENT_USER\EUDC\1252 | ||
+ | * ref: https:// | ||