batoolset 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. batoolset/GUI/__init__.py +0 -0
  2. batoolset/GUI/list_gui.py +513 -0
  3. batoolset/GUI/multi_image_display.py +989 -0
  4. batoolset/GUI/open.py +325 -0
  5. batoolset/GUI/overlay_hints.py +45 -0
  6. batoolset/GUI/paint2.py +1345 -0
  7. batoolset/GUI/scrollablepaint.py +1152 -0
  8. batoolset/IJ_ROIs/__init__.py +0 -0
  9. batoolset/IJ_ROIs/tools.py +40 -0
  10. batoolset/PATH/__init__.py +0 -0
  11. batoolset/PATH/tools.py +79 -0
  12. batoolset/SQLite_tools/__init__.py +0 -0
  13. batoolset/SQLite_tools/tools.py +840 -0
  14. batoolset/__init__.py +0 -0
  15. batoolset/binary/__init__.py +0 -0
  16. batoolset/binary/tools.py +123 -0
  17. batoolset/binarytools/__init__.py +0 -0
  18. batoolset/binarytools/cell_center_detector.py +290 -0
  19. batoolset/clipboard_tools/__init__.py +0 -0
  20. batoolset/clipboard_tools/tools.py +7 -0
  21. batoolset/colors/__init__.py +0 -0
  22. batoolset/colors/colorgen.py +193 -0
  23. batoolset/colors/tools.py +22 -0
  24. batoolset/command_line/__init__.py +0 -0
  25. batoolset/command_line/tools.py +18 -0
  26. batoolset/dialogs/__init__.py +0 -0
  27. batoolset/dialogs/opensave.py +228 -0
  28. batoolset/dicts/__init__.py +0 -0
  29. batoolset/dicts/tools.py +299 -0
  30. batoolset/dims/__init__.py +0 -0
  31. batoolset/dims/tools.py +83 -0
  32. batoolset/draw/__init__.py +0 -0
  33. batoolset/draw/shapes/Position.py +183 -0
  34. batoolset/draw/shapes/__init__.py +0 -0
  35. batoolset/draw/shapes/automated_alignment_drawing_refactored.py +346 -0
  36. batoolset/draw/shapes/circle2d.py +99 -0
  37. batoolset/draw/shapes/compute_optimal_size_all_merged.py +317 -0
  38. batoolset/draw/shapes/ellipse2d.py +336 -0
  39. batoolset/draw/shapes/freehand2d.py +235 -0
  40. batoolset/draw/shapes/group.py +1830 -0
  41. batoolset/draw/shapes/image2d.py +2469 -0
  42. batoolset/draw/shapes/line2d.py +575 -0
  43. batoolset/draw/shapes/point2d.py +257 -0
  44. batoolset/draw/shapes/polygon2d.py +357 -0
  45. batoolset/draw/shapes/polyline2d.py +235 -0
  46. batoolset/draw/shapes/rect2d.py +388 -0
  47. batoolset/draw/shapes/rectangle2d.py +601 -0
  48. batoolset/draw/shapes/scalebar.py +304 -0
  49. batoolset/draw/shapes/serializablefont.py +126 -0
  50. batoolset/draw/shapes/serializableguiparams.py +10 -0
  51. batoolset/draw/shapes/square2d.py +103 -0
  52. batoolset/draw/shapes/textorientation.py +45 -0
  53. batoolset/draw/shapes/tools.py +467 -0
  54. batoolset/draw/shapes/transform2D.py +350 -0
  55. batoolset/draw/shapes/txt2d.py +550 -0
  56. batoolset/draw/widgets/__init__.py +0 -0
  57. batoolset/draw/widgets/col.py +343 -0
  58. batoolset/draw/widgets/image_group.py +248 -0
  59. batoolset/draw/widgets/image_organizer.py +96 -0
  60. batoolset/draw/widgets/paint.py +184 -0
  61. batoolset/draw/widgets/vectorial.py +257 -0
  62. batoolset/figure/__init__.py +0 -0
  63. batoolset/figure/alignment.py +814 -0
  64. batoolset/figure/column.py +1117 -0
  65. batoolset/figure/fig_tools.py +285 -0
  66. batoolset/figure/minimal_debugger_scale_etc.py +139 -0
  67. batoolset/figure/panel.py +697 -0
  68. batoolset/figure/row.py +852 -0
  69. batoolset/figure/user_selection.py +287 -0
  70. batoolset/files/__init__.py +0 -0
  71. batoolset/files/tools.py +1321 -0
  72. batoolset/images/__init__.py +0 -0
  73. batoolset/images/tools.py +81 -0
  74. batoolset/img.py +5216 -0
  75. batoolset/linux/__init__.py +0 -0
  76. batoolset/linux/tools.py +72 -0
  77. batoolset/lists/__init__.py +0 -0
  78. batoolset/lists/tools.py +436 -0
  79. batoolset/luts/__init__.py +0 -0
  80. batoolset/luts/lut_minimal_test.py +1207 -0
  81. batoolset/matplolib/__init__.py +0 -0
  82. batoolset/matplolib/tools.py +44 -0
  83. batoolset/np_tools/__init__.py +0 -0
  84. batoolset/np_tools/tools.py +252 -0
  85. batoolset/np_tools/trash.py +15 -0
  86. batoolset/pandas_tools/__init__.py +0 -0
  87. batoolset/pandas_tools/tools.py +880 -0
  88. batoolset/partials/__init__.py +0 -0
  89. batoolset/partials/tools.py +83 -0
  90. batoolset/plot_tools/__init__.py +0 -0
  91. batoolset/plot_tools/tools.py +70 -0
  92. batoolset/pyqt/__init__.py +0 -0
  93. batoolset/pyqt/tools.py +691 -0
  94. batoolset/re_tools/__init__.py +0 -0
  95. batoolset/re_tools/tools.py +35 -0
  96. batoolset/serialization/__init__.py +0 -0
  97. batoolset/serialization/tools.py +1192 -0
  98. batoolset/sets/__init__.py +0 -0
  99. batoolset/sets/tools.py +109 -0
  100. batoolset/settings/__init__.py +0 -0
  101. batoolset/settings/global_settings.py +134 -0
  102. batoolset/strings/__init__.py +0 -0
  103. batoolset/strings/tools.py +225 -0
  104. batoolset/ta/__init__.py +0 -0
  105. batoolset/ta/database/__init__.py +0 -0
  106. batoolset/ta/database/advanced_sql_plotter.py +1170 -0
  107. batoolset/ta/database/my_qt_table.py +79 -0
  108. batoolset/ta/database/preview_and_edit_sqlite_db.py +405 -0
  109. batoolset/ta/database/sql.py +2141 -0
  110. batoolset/ta/database/sql_column_name_dialog.py +122 -0
  111. batoolset/ta/measurements/TAmeasures.py +2226 -0
  112. batoolset/ta/measurements/__init__.py +0 -0
  113. batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  114. batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +175 -0
  115. batoolset/ta/measurements/measurements3D/height_map_to_projection.py +82 -0
  116. batoolset/ta/measurements/measurements3D/measures3D.py +208 -0
  117. batoolset/ta/measurements/measurements3D/triangulate.py +331 -0
  118. batoolset/ta/measurements/nematic.py +562 -0
  119. batoolset/ta/measurements/nematic_measurements.py +107 -0
  120. batoolset/ta/segmentation/__init__.py +0 -0
  121. batoolset/ta/segmentation/neo_wshed.py +314 -0
  122. batoolset/ta/selections/__init__.py +0 -0
  123. batoolset/ta/selections/selection.py +329 -0
  124. batoolset/ta/tracking/__init__.py +0 -0
  125. batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +653 -0
  126. batoolset/ta/tracking/local_to_track_correspondance.py +138 -0
  127. batoolset/ta/tracking/rapid_detection_of_vertices.py +517 -0
  128. batoolset/ta/tracking/registration.py +108 -0
  129. batoolset/ta/tracking/swap_detector_and_fixer.py +296 -0
  130. batoolset/ta/tracking/track_correction.py +238 -0
  131. batoolset/ta/tracking/tracking_error_detector_and_fixer.py +3099 -0
  132. batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +725 -0
  133. batoolset/ta/utils/TA_tools.py +43 -0
  134. batoolset/ta/utils/__init__.py +0 -0
  135. batoolset/ta/utils/rps_tools.py +1783 -0
  136. batoolset/tests/__init__.py +0 -0
  137. batoolset/tests/rps_tools.py +51 -0
  138. batoolset/tests/tools.py +10 -0
  139. batoolset/tools/__init__.py +0 -0
  140. batoolset/tools/early_stopper_class.py +9 -0
  141. batoolset/tools/guided_data_recoverer.py +110 -0
  142. batoolset/tools/logger.py +100 -0
  143. batoolset/tools/mytimer.py +31 -0
  144. batoolset/tools/prompt_color.py +160 -0
  145. batoolset/tools/qthandler.py +118 -0
  146. batoolset/uitools/__init__.py +0 -0
  147. batoolset/uitools/blinker.py +56 -0
  148. batoolset/unsafe/__init__.py +0 -0
  149. batoolset/unsafe/tools.py +115 -0
  150. batoolset/utils/__init__.py +0 -0
  151. batoolset/utils/commontools.py +158 -0
  152. batoolset/utils/loadlist.py +728 -0
  153. batoolset/version.py +10 -0
  154. batoolset/xml/__init__.py +0 -0
  155. batoolset/xml/tools.py +65 -0
  156. batoolset/zip_tools/__init__.py +0 -0
  157. batoolset/zip_tools/tools.py +76 -0
  158. batoolset-0.1.0.dist-info/LICENSE +24 -0
  159. batoolset-0.1.0.dist-info/METADATA +45 -0
  160. batoolset-0.1.0.dist-info/RECORD +162 -0
  161. batoolset-0.1.0.dist-info/WHEEL +5 -0
  162. batoolset-0.1.0.dist-info/top_level.txt +1 -0
batoolset/GUI/open.py ADDED
@@ -0,0 +1,325 @@
1
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
+ set_UI()
3
+ import os
4
+ import traceback
5
+ from timeit import default_timer as time
6
+ from qtpy.QtCore import QSize, QTimer,Qt
7
+ from natsort import natsorted
8
+ import glob
9
+ from qtpy.QtGui import QIcon
10
+ from qtpy.QtWidgets import QPushButton, QWidget, QLineEdit, QApplication, QGridLayout, QStyle, QLabel, QTextEdit
11
+ from batoolset.dialogs.opensave import openFileNameDialog, openDirectoryDialog
12
+ import sys
13
+ import os
14
+
15
+
16
+
17
+ class QTextEditDND(QTextEdit):
18
+
19
+ def __init__(self, title, parent, tip_text=None, objectName='', allow_multiple_drop=False):
20
+ super().__init__(title, parent)
21
+ self.allow_multiple_drop = allow_multiple_drop
22
+ if tip_text is not None:
23
+ self.setPlaceholderText(tip_text)
24
+ self.setAcceptDrops(True)
25
+ self.setObjectName(objectName)
26
+ self.setAcceptRichText(True)
27
+
28
+ # Make the QTextEdit single-line
29
+ self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
30
+ self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
31
+ self.setLineWrapMode(QTextEdit.NoWrap)
32
+
33
+ # Set a fixed height or minimum height to ensure the QTextEdit doesn't grow vertically
34
+ self.setFixedHeight(30) # or self.setMinimumHeight(20)
35
+
36
+ def dragEnterEvent(self, e):
37
+ if e.mimeData().hasUrls():
38
+ e.accept()
39
+ else:
40
+ e.ignore()
41
+
42
+ def dropEvent(self, e):
43
+ if e.mimeData().hasUrls():
44
+ text = []
45
+ for txt in e.mimeData().urls():
46
+ text.append(txt.toLocalFile())
47
+ if not self.allow_multiple_drop or len(text) == 1:
48
+ self.setPlainText(text[0])
49
+ else:
50
+ # self.setPlainText('\n'.join(text))
51
+ self.setPlainText(str(text))
52
+
53
+
54
+ class QLineEditDND(QLineEdit):
55
+
56
+ def __init__(self, title, parent, tip_text=None, objectName='',allow_multiple_drop=False):
57
+ super().__init__(title, parent, objectName=objectName)
58
+ self.allow_multiple_drop=allow_multiple_drop
59
+ # self.setAcceptRichText(True)
60
+ if tip_text is not None:
61
+ self.setPlaceholderText(tip_text)
62
+ self.setAcceptDrops(True)
63
+
64
+ def dragEnterEvent(self, e):
65
+ # TODO test on osX to see if that works
66
+ if e.mimeData().hasUrls():
67
+ e.accept()
68
+ else:
69
+ e.ignore()
70
+
71
+ def dropEvent(self, e):
72
+ if e.mimeData().hasUrls():
73
+ text=[]
74
+ for txt in e.mimeData().urls():
75
+ text.append(txt.toLocalFile())
76
+ if not self.allow_multiple_drop or len(text)==1:
77
+ self.setText(text[0])
78
+ else:
79
+ self.setText(str(text))
80
+
81
+ # TODO URGENT I guess I should activate the lines below
82
+ # e.accept()
83
+ # else:
84
+ # e.ignore()
85
+
86
+ class OpenFileOrFolderWidget(QWidget):
87
+
88
+ def __init__(self, parent_window=None, add_timer_to_changetext=False, show_ok_or_not_icon=False, label_text=None,
89
+ is_file=False, extensions="All Files (*);;", show_size=False, tip_text=None, objectName='',finalize_text_change_method_overrider=None, allow_multiple_drop=False, use_qtextedit=False):
90
+ super().__init__(parent=parent_window)
91
+ # print('changed method',finalize_text_change_method_overrider)
92
+ self.finalize_text_change_method_overrider = finalize_text_change_method_overrider
93
+ self.ok_ico = self.style().standardIcon(QStyle.SP_DialogYesButton).pixmap(QSize(12, 12))
94
+ self.not_ok_ico = self.style().standardIcon(QStyle.SP_DialogNoButton).pixmap(QSize(12, 12))
95
+ self.show_ok_or_not_icon = show_ok_or_not_icon
96
+ self.parent_window = parent_window
97
+ self.add_timer_to_changetext = add_timer_to_changetext
98
+ self.label_text = label_text
99
+ self.is_file = is_file
100
+ self.tip_text = tip_text
101
+ # self.is_file_or_folder = is_file_or_folder
102
+ self.extensions = extensions
103
+ self.show_size = show_size
104
+ self.time_of_last_change = None
105
+ self.allow_multiple_drop = allow_multiple_drop
106
+ self.use_qtextedit = use_qtextedit
107
+ self.initUI(objectName)
108
+
109
+ def initUI(self, objectName):
110
+ layout = QGridLayout()
111
+ size_begin = 80
112
+ size_label = 0
113
+ size_end = 20
114
+ size_warning = 0
115
+ size_input_size = 0
116
+
117
+ if self.label_text is not None:
118
+ size_label = 10
119
+ size_begin -= size_label
120
+
121
+ if self.show_ok_or_not_icon:
122
+ size_warning = 3
123
+ size_begin -= size_warning
124
+
125
+ if self.show_size:
126
+ size_input_size = 5
127
+ size_begin -= size_input_size
128
+
129
+ layout.setColumnStretch(0, size_label)
130
+ layout.setColumnStretch(1, size_begin)
131
+ layout.setColumnStretch(2, size_end)
132
+ layout.setColumnStretch(3, size_warning)
133
+ layout.setColumnStretch(4, size_input_size)
134
+ layout.setHorizontalSpacing(3)
135
+ layout.setVerticalSpacing(0)
136
+ layout.setContentsMargins(0, 0, 0, 0)
137
+
138
+ if not self.use_qtextedit:
139
+ self.path = QLineEditDND('', self, tip_text=self.tip_text, objectName=objectName, allow_multiple_drop=self.allow_multiple_drop)
140
+ else:
141
+ self.path = QTextEditDND('', self, tip_text=self.tip_text, objectName=objectName, allow_multiple_drop=self.allow_multiple_drop)
142
+
143
+ if self.add_timer_to_changetext:
144
+
145
+ qtimer = QTimer()
146
+ qtimer.setSingleShot(True)
147
+ # self.path.textChanged.connect(lambda: qtimer.start(600))
148
+ if isinstance(self.path, QLineEdit):
149
+ self.path.textChanged.connect(lambda x: qtimer.start(600)) # somehow my weird bug is here and only in some conditions
150
+ else:
151
+ self.path.textChanged.connect(lambda: qtimer.start(600))
152
+ # # Is there a better way TODO that ????
153
+ # timer.timeout.connect(self._text_changed)
154
+ qtimer.timeout.connect(self.finalize_text_change)
155
+ if isinstance(self.path, QLineEdit):
156
+ self.path.setDragEnabled(True)
157
+
158
+ open_ico = QIcon.fromTheme("folder-open")
159
+ open_button = QPushButton(open_ico, "Open", self)
160
+
161
+ open_button.setFocusPolicy(Qt.NoFocus)
162
+ # self.path.setDefault(True)
163
+ # open_button.setDefault(False) # prevent it from
164
+ # bt_width = open_button.fontMetrics().boundingRect(open_button.text()).width() + 30
165
+ # open_button.setMaximumWidth(bt_width)
166
+ # if self.is_file_or_folder:
167
+ # open_button.clicked.connect(self.open_file_or_folder)
168
+ # el
169
+ if self.is_file:
170
+ open_button.clicked.connect(self.open_file)
171
+ else:
172
+ open_button.clicked.connect(self.open_folder)
173
+
174
+ self.ok_or_not_ico = QLabel('')
175
+ self.ok_or_not_ico.setPixmap(self.not_ok_ico)
176
+
177
+ if self.show_ok_or_not_icon:
178
+ layout.addWidget(self.ok_or_not_ico, 0, 3)
179
+
180
+ if self.label_text is not None:
181
+ layout.addWidget(QLabel(self.label_text), 0, 0)
182
+
183
+ self.size_label = QLabel('0000')
184
+
185
+ if self.show_size:
186
+ layout.addWidget(self.size_label, 0, 4)
187
+
188
+ layout.addWidget(self.path, 0, 1)
189
+ layout.addWidget(open_button, 0, 2)
190
+ self.setLayout(layout)
191
+
192
+ def open_folder(self):
193
+ if isinstance(self.path, QLineEdit):
194
+ if os.path.isdir(self.path.text()):
195
+ self.output_file_or_folder = openDirectoryDialog(parent_window=self.parent_window)
196
+ else:
197
+ self.output_file_or_folder = openDirectoryDialog(parent_window=self.parent_window,
198
+ path=self.path.text())
199
+ if self.output_file_or_folder is not None:
200
+ self.path.setText(self.output_file_or_folder)
201
+ else:
202
+ if os.path.isdir(self.path.toPlainText()):
203
+ self.output_file_or_folder = openDirectoryDialog(parent_window=self.parent_window)
204
+ else:
205
+ self.output_file_or_folder = openDirectoryDialog(parent_window=self.parent_window,
206
+ path=self.path.toPlainText())
207
+ if self.output_file_or_folder is not None:
208
+ self.path.setPlainText(self.output_file_or_folder)
209
+
210
+ def open_file(self):
211
+ # print('I am in there')
212
+ #
213
+ # try:
214
+ # print('in',self.path.text())
215
+ # except:
216
+ # print('in',self.path.toPlainText())
217
+
218
+ if isinstance(self.path, QLineEdit):
219
+ if os.path.isfile(self.path.text()):
220
+ self.output_file_or_folder = openFileNameDialog(parent_window=self.parent_window,
221
+ extensions=self.extensions)
222
+ else:
223
+ self.output_file_or_folder = openFileNameDialog(parent_window=self.parent_window,
224
+ extensions=self.extensions,
225
+ path=self.path.text())
226
+ if self.output_file_or_folder:
227
+ self.path.setText(self.output_file_or_folder)
228
+ else:
229
+ if os.path.isfile(self.path.toPlainText()):
230
+ self.output_file_or_folder = openFileNameDialog(parent_window=self.parent_window,
231
+ extensions=self.extensions)
232
+ else:
233
+ self.output_file_or_folder = openFileNameDialog(parent_window=self.parent_window,
234
+ extensions=self.extensions,
235
+ path=self.path.toPlainText())
236
+
237
+ if self.output_file_or_folder:
238
+ self.path.setPlainText(self.output_file_or_folder)
239
+
240
+ # try:
241
+ # print('out',self.path.text())
242
+ # except:
243
+ # print('out',self.path.toPlainText())
244
+
245
+ def set_time_of_last_change(self):
246
+ self.time_of_last_change = time()
247
+ # print('I have been changed', self.time_of_last_change, self) # to debug
248
+
249
+ def get_time_of_last_change(self):
250
+ return self.time_of_last_change
251
+
252
+ # def _text_changed(self):
253
+ # # this stores the time of last change --> can easily determine when the object was last changed
254
+ # self.set_time_of_last_change()
255
+ # # self.finalize_text_change()
256
+
257
+ def text(self):
258
+ if isinstance(self.path, QLineEdit):
259
+ if self.path.text().strip() == '':
260
+ return None
261
+ return self.path.text()
262
+ else:
263
+ if self.path.toPlainText().strip() == '':
264
+ return None
265
+ return self.path.toPlainText()
266
+
267
+ def finalize_text_change(self):
268
+ # print('finalize_text_change_method_overrider',self.finalize_text_change_method_overrider)
269
+ # try:
270
+ self.set_time_of_last_change()
271
+ if self.finalize_text_change_method_overrider is not None:
272
+ # print('calling neo finalizer')
273
+ # if an overriding method was defined --> use it otherwise use default
274
+ self.finalize_text_change_method_overrider()
275
+ # else:
276
+ # #
277
+ # print('in', self.path.text())
278
+ # print('in', self.path.toPlainText())
279
+ # pass
280
+ # except:
281
+ # # traceback.print_stack()
282
+ # traceback.print_exc()
283
+ # pass
284
+ # pass
285
+
286
+ def set_icon_ok(self, ok):
287
+ if not self.show_ok_or_not_icon:
288
+ return
289
+ if ok:
290
+ self.ok_or_not_ico.setPixmap(self.ok_ico)
291
+ else:
292
+ self.ok_or_not_ico.setPixmap(self.not_ok_ico)
293
+
294
+ def set_size(self, size):
295
+ self.size_label.setText(size)
296
+
297
+ def get_list_using_glob(self):
298
+ try:
299
+ if isinstance(self.path, QLineEdit):
300
+ filenames = [file for file in glob.glob(self.path.text())]
301
+ else:
302
+ filenames = [file for file in glob.glob(self.path.toPlainText())]
303
+ filenames = natsorted(filenames) # human-like sorting of file names
304
+ return filenames
305
+ except:
306
+ return None
307
+
308
+ if __name__ == '__main__':
309
+ # just for a test
310
+ app = QApplication(sys.argv)
311
+
312
+ def new_method():
313
+ print('tutu')
314
+
315
+
316
+ use_qtextedit = True
317
+ is_file=True
318
+ ex = OpenFileOrFolderWidget(parent_window=None, add_timer_to_changetext=True, finalize_text_change_method_overrider=new_method, allow_multiple_drop=True, use_qtextedit=use_qtextedit, is_file=is_file)
319
+ text = "This is <span style=\"color:green\">green text</span> and <span style=\"color:red\">red text</span>."
320
+ try:
321
+ ex.path.setText(text)
322
+ except:
323
+ ex.path.setHtml(text)
324
+ ex.show()
325
+ app.exec_()
@@ -0,0 +1,45 @@
1
+ import os
2
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
3
+ set_UI()
4
+ from qtpy.QtCore import Qt
5
+ from qtpy.QtGui import QPalette, QPainter, QBrush, QColor, QPen, QFontMetrics
6
+ from qtpy.QtWidgets import QWidget
7
+
8
+
9
+ class Overlay(QWidget):
10
+
11
+ def __init__(self, parent=None):
12
+ QWidget.__init__(self, parent)
13
+ palette = QPalette(self.palette())
14
+ # palette.setColor(palette.Background, Qt.transparent) # change due to a shift to the qtpy paradigm
15
+ self.setPalette(palette)
16
+
17
+ def paintEvent(self, event):
18
+ painter = QPainter()
19
+ try:
20
+ painter.begin(self)
21
+ painter.save()
22
+ painter.setRenderHint(QPainter.Antialiasing)
23
+ painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127)))
24
+ painter.setPen(QPen(Qt.NoPen))
25
+
26
+ painter.setPen(QColor('red'))
27
+ f = painter.font()
28
+ f.setBold(True)
29
+ f.setPointSize(20)
30
+
31
+ message = 'Please wait...'
32
+ fm = QFontMetrics(f)
33
+ txt_width = fm.width(message)
34
+ txt_height = fm.height()
35
+
36
+ painter.setFont(f)
37
+
38
+ flags = Qt.AlignTop | Qt.AlignLeft | Qt.TextSingleLine
39
+ painter.drawText(int(self.width() / 2 - txt_width), int(self.height() / 2 - self.fontMetrics().height()), txt_width,
40
+ txt_height, flags, message)
41
+
42
+ painter.restore()
43
+ finally:
44
+
45
+ painter.end()