batoolset 0.1.8__tar.gz → 0.1.10__tar.gz

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 (172) hide show
  1. {batoolset-0.1.8 → batoolset-0.1.10}/PKG-INFO +1 -1
  2. batoolset-0.1.10/batoolset/GUI/customdialog.py +136 -0
  3. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/luts/lut_minimal_test.py +71 -26
  4. batoolset-0.1.10/batoolset/luts/lutcreatorfromformula.py +209 -0
  5. batoolset-0.1.10/batoolset/luts/luteditor.py +243 -0
  6. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/pyqts/tools.py +60 -2
  7. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/version.py +1 -1
  8. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset.egg-info/PKG-INFO +1 -1
  9. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset.egg-info/SOURCES.txt +3 -0
  10. {batoolset-0.1.8 → batoolset-0.1.10}/LICENSE +0 -0
  11. {batoolset-0.1.8 → batoolset-0.1.10}/README.md +0 -0
  12. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/__init__.py +0 -0
  13. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/list_gui.py +0 -0
  14. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/multi_image_display.py +0 -0
  15. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/open.py +0 -0
  16. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/overlay_hints.py +0 -0
  17. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/paint2.py +0 -0
  18. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/GUI/scrollablepaint.py +0 -0
  19. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/IJ_ROIs/__init__.py +0 -0
  20. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/IJ_ROIs/tools.py +0 -0
  21. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/SQLites/__init__.py +0 -0
  22. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/SQLites/tools.py +0 -0
  23. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/__init__.py +0 -0
  24. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/binaries/__init__.py +0 -0
  25. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/binaries/tools.py +0 -0
  26. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/clipboards/__init__.py +0 -0
  27. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/clipboards/tools.py +0 -0
  28. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/colors/__init__.py +0 -0
  29. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/colors/colorgen.py +0 -0
  30. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/colors/tools.py +0 -0
  31. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/command_line/__init__.py +0 -0
  32. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/command_line/tools.py +0 -0
  33. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dialogs/__init__.py +0 -0
  34. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dialogs/opensave.py +0 -0
  35. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dicts/__init__.py +0 -0
  36. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dicts/tools.py +0 -0
  37. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dims/__init__.py +0 -0
  38. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/dims/tools.py +0 -0
  39. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/__init__.py +0 -0
  40. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/Position.py +0 -0
  41. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/__init__.py +0 -0
  42. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/automated_alignment_drawing_refactored.py +0 -0
  43. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/circle2d.py +0 -0
  44. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/compute_optimal_size_all_merged.py +0 -0
  45. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/ellipse2d.py +0 -0
  46. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/freehand2d.py +0 -0
  47. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/group.py +0 -0
  48. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/image2d.py +0 -0
  49. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/line2d.py +0 -0
  50. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/point2d.py +0 -0
  51. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/polygon2d.py +0 -0
  52. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/polyline2d.py +0 -0
  53. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/rect2d.py +0 -0
  54. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/rectangle2d.py +0 -0
  55. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/scalebar.py +0 -0
  56. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/serializablefont.py +0 -0
  57. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/serializableguiparams.py +0 -0
  58. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/square2d.py +0 -0
  59. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/textorientation.py +0 -0
  60. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/tools.py +0 -0
  61. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/transform2D.py +0 -0
  62. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/shapes/txt2d.py +0 -0
  63. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/__init__.py +0 -0
  64. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/col.py +0 -0
  65. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/image_group.py +0 -0
  66. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/image_organizer.py +0 -0
  67. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/paint.py +0 -0
  68. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/drawings/widgets/vectorial.py +0 -0
  69. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/__init__.py +0 -0
  70. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/alignment.py +0 -0
  71. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/column.py +0 -0
  72. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/fig_tools.py +0 -0
  73. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/minimal_debugger_scale_etc.py +0 -0
  74. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/panel.py +0 -0
  75. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/row.py +0 -0
  76. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/figure/user_selection.py +0 -0
  77. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/files/__init__.py +0 -0
  78. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/files/tools.py +0 -0
  79. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/images/__init__.py +0 -0
  80. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/images/centralstore.py +0 -0
  81. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/images/tools.py +0 -0
  82. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/img.py +0 -0
  83. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/javas/__init__.py +0 -0
  84. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/javas/tools.py +0 -0
  85. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/linux/__init__.py +0 -0
  86. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/linux/tools.py +0 -0
  87. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/lists/__init__.py +0 -0
  88. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/lists/tools.py +0 -0
  89. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/luts/__init__.py +0 -0
  90. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/matplolibs/__init__.py +0 -0
  91. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/matplolibs/tools.py +0 -0
  92. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/nps/__init__.py +0 -0
  93. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/nps/tools.py +0 -0
  94. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/pandaz/__init__.py +0 -0
  95. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/pandaz/tools.py +0 -0
  96. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/partials/__init__.py +0 -0
  97. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/partials/tools.py +0 -0
  98. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/paths/__init__.py +0 -0
  99. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/paths/tools.py +0 -0
  100. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/plots/__init__.py +0 -0
  101. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/plots/tools.py +0 -0
  102. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/pyqts/__init__.py +0 -0
  103. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/pyqts/pleasewaitdialog.py +0 -0
  104. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/res/__init__.py +0 -0
  105. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/res/tools.py +0 -0
  106. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/serializations/__init__.py +0 -0
  107. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/serializations/tools.py +0 -0
  108. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/sets/__init__.py +0 -0
  109. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/sets/tools.py +0 -0
  110. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/settings/__init__.py +0 -0
  111. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/settings/global_settings.py +0 -0
  112. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/strings/__init__.py +0 -0
  113. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/strings/tools.py +0 -0
  114. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/__init__.py +0 -0
  115. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/__init__.py +0 -0
  116. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/advanced_sql_plotter.py +0 -0
  117. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/my_qt_table.py +0 -0
  118. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/preview_and_edit_sqlite_db.py +0 -0
  119. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/sql.py +0 -0
  120. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/database/sql_column_name_dialog.py +0 -0
  121. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/TAmeasures.py +0 -0
  122. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/__init__.py +0 -0
  123. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  124. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +0 -0
  125. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/measurements3D/height_map_to_projection.py +0 -0
  126. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/measurements3D/measures3D.py +0 -0
  127. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/measurements3D/triangulate.py +0 -0
  128. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/nematic.py +0 -0
  129. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/measurements/nematic_measurements.py +0 -0
  130. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/segmentation/__init__.py +0 -0
  131. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/segmentation/neo_wshed.py +0 -0
  132. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/selections/__init__.py +0 -0
  133. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/selections/selection.py +0 -0
  134. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/__init__.py +0 -0
  135. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +0 -0
  136. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/local_to_track_correspondance.py +0 -0
  137. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/rapid_detection_of_vertices.py +0 -0
  138. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/registration.py +0 -0
  139. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/swap_detector_and_fixer.py +0 -0
  140. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/track_correction.py +0 -0
  141. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/tracking_error_detector_and_fixer.py +0 -0
  142. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +0 -0
  143. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/utils/TA_tools.py +0 -0
  144. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/utils/__init__.py +0 -0
  145. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/ta/utils/rps_tools.py +0 -0
  146. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tests/__init__.py +0 -0
  147. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tests/rps_tools.py +0 -0
  148. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tests/tools.py +0 -0
  149. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/__init__.py +0 -0
  150. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/early_stopper_class.py +0 -0
  151. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/guided_data_recoverer.py +0 -0
  152. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/logger.py +0 -0
  153. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/mytimer.py +0 -0
  154. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/prompt_color.py +0 -0
  155. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/tools/qthandler.py +0 -0
  156. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/uis/__init__.py +0 -0
  157. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/uis/blinker.py +0 -0
  158. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/unsafe/__init__.py +0 -0
  159. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/unsafe/tools.py +0 -0
  160. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/utils/__init__.py +0 -0
  161. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/utils/commontools.py +0 -0
  162. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/utils/loadlist.py +0 -0
  163. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/xmls/__init__.py +0 -0
  164. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/xmls/tools.py +0 -0
  165. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/zarrs/__init__.py +0 -0
  166. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/zips/__init__.py +0 -0
  167. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset/zips/tools.py +0 -0
  168. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset.egg-info/dependency_links.txt +0 -0
  169. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset.egg-info/requires.txt +0 -0
  170. {batoolset-0.1.8 → batoolset-0.1.10}/batoolset.egg-info/top_level.txt +0 -0
  171. {batoolset-0.1.8 → batoolset-0.1.10}/setup.cfg +0 -0
  172. {batoolset-0.1.8 → batoolset-0.1.10}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batoolset
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: An aggregate of functions I find useful
5
5
  Home-page: https://github.com/baigouy/batoolset
6
6
  Author: Benoit Aigouy
@@ -0,0 +1,136 @@
1
+ from qtpy import QtWidgets, QtCore
2
+ from qtpy.QtWidgets import (QDialog, QVBoxLayout, QLabel, QPushButton, QApplication, QWidget,QFrame)
3
+ from qtpy.QtCore import Qt,Signal
4
+
5
+ from batoolset.pyqts.tools import disable_wheel_for_combo_and_spin
6
+
7
+
8
+ # from batoolset.pyqts.tools import disable_wheel_for_widget_and_children
9
+
10
+
11
+ class CustomDialog(QDialog):
12
+ option_selected = Signal(str)
13
+ accepting_keywords = ["yes", "ok", "done", "validate", "y"]
14
+ rejecting_keywords = ["no", "cancel", "quit", "abandon", "reject", "stop", "n", "q"]
15
+
16
+ def __init__(self, title="Custom Dialog", message="Do you want to proceed?", main_widget=None, parent=None, options=None, add_separator=True, auto_adjust=False, reset_style_sheet=True):
17
+ super().__init__(parent)
18
+
19
+ if reset_style_sheet:
20
+ # self.setStyleSheet("") # make sure to reset style sheet # this doesn't work
21
+ self.setStyleSheet("background-color: none;") # make sure to reset style sheet
22
+ # main_widget.setStyleSheet("")
23
+ main_widget.setStyleSheet("background-color: none;")
24
+
25
+ # self.setStyleSheet("background-color: lightblue;")
26
+
27
+ # Set the object name for the widget
28
+ # self.setObjectName("VectorialDrawPane2")
29
+
30
+ # Set the background color
31
+ # if background is not None:
32
+ # self.setStyleSheet("") # prevent it from getting the style sheet of the parent
33
+
34
+ # Set the window flags to stay on top
35
+ self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
36
+
37
+ self.setWindowTitle(title)
38
+
39
+ self.main_widget = main_widget
40
+
41
+ layout = QVBoxLayout()
42
+ if main_widget:
43
+ # main_widget.setStyleSheet("") # also reset style sheet of content
44
+ layout.addWidget(main_widget)
45
+
46
+ # Add a separator
47
+ separator = QFrame()
48
+ separator.setFrameShape(QFrame.HLine)
49
+ separator.setFrameShadow(QFrame.Sunken)
50
+ layout.addWidget(separator)
51
+
52
+ if message:
53
+ label = QLabel(message)
54
+ layout.addWidget(label)
55
+
56
+ if options is None:
57
+ options = ["Yes", "No"]
58
+
59
+ if isinstance(options, str):
60
+ options=[options]
61
+
62
+ for option in options:
63
+ button = QPushButton(option)
64
+ button.setFocusPolicy(Qt.NoFocus)# prevent auto selection from buttons
65
+ layout.addWidget(button)
66
+ button.clicked.connect(lambda _, opt=option: self.handle_option_clicked(opt))
67
+
68
+ self.setLayout(layout)
69
+
70
+ # disable_wheel_for_widget_and_children(self)
71
+
72
+ # disable_wheel_for_combo_and_spin(self.main_widget)
73
+ # disable_wheel_for_combo_and_spin(self.main_widget)
74
+
75
+ if not auto_adjust:
76
+ try:
77
+ try:
78
+ # Get the screen where the application is currently displayed
79
+ screen = self.screen()
80
+ if screen is not None:
81
+ screen_geometry = screen.geometry()
82
+ else:
83
+ # If the application is not displayed on any screen, use the primary screen
84
+ screen_geometry = QtWidgets.QApplication.primaryScreen().geometry()
85
+ except:
86
+ try:
87
+ from qtpy.QtGui import QGuiApplication
88
+ screen_geometry = QGuiApplication.primaryScreen().geometry()
89
+ except:
90
+ pass # no big deal if all fails...
91
+ # Set width and height to 75% of the screen size
92
+ width = int(screen_geometry.width() * 0.85)
93
+ height = int(screen_geometry.height() * 0.85)
94
+ self.resize(width, height)
95
+ except:
96
+ pass # no big deal if it fails...
97
+ else:
98
+ # force the window to assume the smallest minimum size can be very useful when min size is set
99
+ self.adjustSize()
100
+
101
+ def handle_option_clicked(self, option):
102
+ self.selected_option = option
103
+ if option.lower() in CustomDialog.accepting_keywords:
104
+ self.accept() # Close the dialog with QDialog.Accepted status
105
+ elif option.lower() in CustomDialog.rejecting_keywords:
106
+ self.reject() # Close the dialog with QDialog.Rejected status
107
+ else:
108
+ self.accept() # Close the dialog with QDialog.Accepted status
109
+
110
+ # def exec_(self):
111
+ # result = super().exec_()
112
+ # if result == QDialog.Accepted:
113
+ # return self.selected_option
114
+ # else:
115
+ # return None
116
+
117
+ def get_selected_answer(self):
118
+ return self.selected_option
119
+
120
+ if __name__ == "__main__":
121
+ import sys
122
+ app = QApplication(sys.argv)
123
+
124
+ options = ["Option 1", "Option 2", "Option 3", "No"] # None
125
+ options = "Done"
126
+ message = "Do you want to proceed?" # "Do you want to proceed?" # None
127
+ auto_adjust = True # force the window to take minimal size if used (calls adjustsize)
128
+ custom_dialog = CustomDialog(title="Custom Dialog", message=message , main_widget=QWidget(), options=options, auto_adjust=auto_adjust)
129
+ custom_dialog.option_selected.connect(lambda option: print(f"Selected option: {option}"))
130
+ selected_option = custom_dialog.exec_()
131
+ print(selected_option)
132
+ if selected_option:
133
+ print(f"Selected option: {selected_option}")
134
+ print(custom_dialog.selected_option)
135
+ else:
136
+ print("Dialog was closed without selecting an option.")
@@ -11,6 +11,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg
11
11
  from matplotlib.figure import Figure
12
12
  from batoolset.img import fig_to_numpy
13
13
  import base64
14
+ import numexpr as ne
14
15
 
15
16
  def serialize_lut(lut_256_3):
16
17
  # see also /home/aigouy/mon_prog/Python/epyseg_pkg/personal/FigGen_EzFig2/trash/tst_base64_encode_the_whole_np_array.py
@@ -142,11 +143,10 @@ def list_available_luts(return_matplotlib_lib_luts_in_separate_database=False):
142
143
  """
143
144
  hash_pal = {
144
145
  "DEFAULT": "22,13,-23",
145
- "GREEN": "0,3,0",
146
146
  "RED": "3,0,0",
147
+ "GREEN": "0,3,0",
147
148
  "BLUE": "0,0,3",
148
149
  "GRAY": "3,3,3",
149
- "GREY": "3,3,3",
150
150
  "AFM_HOT": "34,35,36",
151
151
  "PACKING": "PACKING",
152
152
  "RED_HOT": "21,22,23",
@@ -451,6 +451,38 @@ class PaletteCreator:
451
451
 
452
452
  return equation
453
453
 
454
+ # def computeEquation(self, equation, variable, val):
455
+ # """
456
+ # Computes the result of an equation using the numexpr library.
457
+ #
458
+ # Args:
459
+ # equation (str): The equation to compute.
460
+ # variable (str): The variable name in the equation.
461
+ # val: The value for the variable.
462
+ #
463
+ # Returns:
464
+ # float: The computed result of the equation.
465
+ #
466
+ # # Examples:
467
+ # # >>> palette_creator = PaletteCreator()
468
+ # # >>> result = palette_creator.computeEquation("2*a*(b/c)**2", "a", [1, 2, 2])
469
+ # # >>> print(result)
470
+ # # array([0.88888889, 0.44444444, 4.])
471
+ # """
472
+ # import numexpr as ne
473
+ # var = {'a': np.array([1, 2, 2]), 'b': np.array([2, 1, 3]), 'c': np.array([3])}
474
+ # print('TOO', ne.evaluate('2*a*(b/c)**2', local_dict=var))
475
+ # try:
476
+ # for i in range(10):
477
+ # equation = equation.replace(str(i) + variable, str(i) + "*" + variable)
478
+ # for i in range(10):
479
+ # equation = equation.replace(variable + str(i), variable + "*" + str(i))
480
+ #
481
+ # equation = equation.replace(variable, "(double)" + variable)
482
+ # print(equation)
483
+ # except:
484
+ # traceback.print_exc()
485
+ # return 0
454
486
  def computeEquation(self, equation, variable, val):
455
487
  """
456
488
  Computes the result of an equation using the numexpr library.
@@ -461,28 +493,29 @@ class PaletteCreator:
461
493
  val: The value for the variable.
462
494
 
463
495
  Returns:
464
- float: The computed result of the equation.
465
-
466
- # Examples:
467
- # >>> palette_creator = PaletteCreator()
468
- # >>> result = palette_creator.computeEquation("2*a*(b/c)**2", "a", [1, 2, 2])
469
- # >>> print(result)
470
- # array([0.88888889, 0.44444444, 4.])
496
+ numpy.ndarray: The computed result of the equation.
471
497
  """
472
- import numexpr as ne
473
- var = {'a': np.array([1, 2, 2]), 'b': np.array([2, 1, 3]), 'c': np.array([3])}
474
- print('TOO', ne.evaluate('2*a*(b/c)**2', local_dict=var))
475
498
  try:
476
- for i in range(10):
477
- equation = equation.replace(str(i) + variable, str(i) + "*" + variable)
478
- for i in range(10):
479
- equation = equation.replace(variable + str(i), variable + "*" + str(i))
480
-
481
- equation = equation.replace(variable, "(double)" + variable)
482
- print(equation)
483
- except:
499
+ # Handle the special case where the equation is just a minus sign
500
+ if equation.strip() == '-':
501
+ return -np.array(val)
502
+ if equation.strip() == '+':
503
+ return np.array(val)
504
+ # Prepare the variable dictionary
505
+ var = {variable: np.array(val)}
506
+
507
+ # Print the equation and variables for debugging
508
+ print(f"Evaluating equation: {equation}")
509
+ print(f"Variables: {var}")
510
+ # Evaluate the equation using numexpr
511
+ result = ne.evaluate(equation, local_dict=var)
512
+
513
+ return result
514
+ except Exception as e:
515
+ # Print the traceback and the error message
484
516
  traceback.print_exc()
485
- return 0
517
+ print(f"Error evaluating the equation '{equation}': {e}")
518
+ return np.zeros_like(val) # Return an array of zeros with the same shape as val
486
519
 
487
520
  def create5(self, red, green, blue):
488
521
  """
@@ -773,7 +806,7 @@ class PaletteCreator:
773
806
  final_palette = None
774
807
  try:
775
808
  r = g = b = 3
776
- if "," in palette_name:
809
+ if palette_name and "," in palette_name:
777
810
  formula_size = len(palette_name.split(","))
778
811
  if formula_size == 3:
779
812
  r = int(palette_name.split(",")[0])
@@ -786,15 +819,22 @@ class PaletteCreator:
786
819
  equa2 = new_equa2
787
820
  equa3 = new_equa3
788
821
 
822
+ # print('passing there')
823
+
789
824
  if abs(r) < 37 and abs(g) < 37 and abs(b) < 37:
790
825
  return self.create3(palette_name)
791
826
 
792
827
  if abs(r) >= 37 and abs(g) >= 37 and abs(b) >= 37:
793
828
  palette1 = self.createEmptyPalette()
794
829
  else:
795
- palette1 = self.create(palette_name)
830
+ palette1 = self.create3(palette_name)
796
831
 
832
+ # print('inside equa', equa1, equa2, equa3)
797
833
  palette2 = self.create_from_formula(equa1, equa2, equa3)
834
+
835
+
836
+ # print(palette2.shape)
837
+
798
838
  final_palette = np.zeros((palette1.shape[0], palette1.shape[1]), dtype=np.uint8)
799
839
  l = 0
800
840
  l1 = 0
@@ -812,9 +852,14 @@ class PaletteCreator:
812
852
  green = green2 if abs(g) >= 37 and abs(g) <= 39 else green1
813
853
  blue = blue2 if abs(b) >= 37 and abs(b) <= 39 else blue1
814
854
 
815
- final_palette[l, 0] = red
816
- final_palette[l, 1] = green
817
- final_palette[l, 2] = blue
855
+ # print('final_palette', final_palette.shape)
856
+ # print('red', red)
857
+ # print('green', green)
858
+ # print('blue', blue)
859
+
860
+ final_palette[l, 0] = red[0]
861
+ final_palette[l, 1] = green[1]
862
+ final_palette[l, 2] = blue[2]
818
863
  l += 1
819
864
  except:
820
865
  traceback.print_exc()
@@ -0,0 +1,209 @@
1
+ from batoolset.pyqts.tools import updateLutLabelPreview
2
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
3
+ set_UI()
4
+ import sys
5
+ import random
6
+ from qtpy.QtWidgets import (
7
+ QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit,
8
+ QPushButton, QTextEdit, QGroupBox, QMessageBox, QScrollArea, QSizePolicy,
9
+ )
10
+ from qtpy.QtCore import Qt
11
+ from qtpy.QtGui import QFont
12
+ from batoolset.luts.lut_minimal_test import PaletteCreator, list_available_luts, apply_lut, lsm_LUT_to_numpy
13
+
14
+
15
+ class PaletteFormulaEditor(QWidget):
16
+ def __init__(self, parent=None):
17
+ super().__init__(parent)
18
+ self.palette = None
19
+
20
+ # Initialize the UI components
21
+ self.initUI()
22
+
23
+ def initUI(self):
24
+ layout = QVBoxLayout()
25
+
26
+ # Preview Panel
27
+ self.preview_group = QGroupBox("Preview")
28
+ preview_layout = QVBoxLayout()
29
+ # Align the QLabel to the center
30
+
31
+ self.previewLabel = QLabel()
32
+ # self.previewLabel.setFixedSize(750,16)
33
+ preview_layout.addWidget(self.previewLabel)
34
+ preview_layout.setAlignment(self.previewLabel, Qt.AlignCenter)
35
+ self.preview_group.setLayout(preview_layout)
36
+ layout.addWidget(self.preview_group)
37
+
38
+ # Formula Panel
39
+ self.formula_group = QGroupBox("Formula")
40
+ formula_layout = QVBoxLayout()
41
+
42
+ h_layout1 = QHBoxLayout()
43
+ h_layout2 = QHBoxLayout()
44
+
45
+ # Red Formula
46
+ self.redLabel = QLabel("Red Formula:")
47
+ self.redFormula = QLineEdit("34")
48
+ self.redFormula.textChanged.connect(self.update_palette)
49
+
50
+ # Green Formula
51
+ self.greenLabel = QLabel("Green Formula:")
52
+ self.greenFormula = QLineEdit("35")
53
+ self.greenFormula.textChanged.connect(self.update_palette)
54
+
55
+ # Blue Formula
56
+ self.blueLabel = QLabel("Blue Formula:")
57
+ self.blueFormula = QLineEdit("36")
58
+ self.blueFormula.textChanged.connect(self.update_palette)
59
+
60
+ # Add to layout
61
+ h_layout1.addWidget(self.redLabel)
62
+ h_layout1.addWidget(self.redFormula)
63
+ h_layout1.addWidget(self.greenLabel)
64
+ h_layout1.addWidget(self.greenFormula)
65
+ h_layout1.addWidget(self.blueLabel)
66
+ h_layout1.addWidget(self.blueFormula)
67
+
68
+
69
+ # Equation Text Fields
70
+ self.eqLabel1 = QLabel("Eq. #1:")
71
+ self.eq1 = QLineEdit("x")
72
+ self.eq1.textChanged.connect(self.update_palette)
73
+
74
+ self.eqLabel2 = QLabel("Eq. #2:")
75
+ self.eq2 = QLineEdit("x")
76
+ self.eq2.textChanged.connect(self.update_palette)
77
+
78
+ self.eqLabel3 = QLabel("Eq. #3:")
79
+ self.eq3 = QLineEdit("x")
80
+ self.eq3.textChanged.connect(self.update_palette)
81
+
82
+ # Random Button
83
+ self.randomButton = QPushButton("Random")
84
+ self.randomButton.clicked.connect(self.randomize_formulas)
85
+
86
+ # Update Button
87
+ # self.updateButton = QPushButton("Update")
88
+ # self.updateButton.clicked.connect(self.update_palette)
89
+
90
+ if False: # TODO --> really connect this in the future but ok for now
91
+ h_layout2.addWidget(self.eqLabel1)
92
+ h_layout2.addWidget(self.eq1)
93
+ h_layout2.addWidget(self.eqLabel2)
94
+ h_layout2.addWidget(self.eq2)
95
+ h_layout2.addWidget(self.eqLabel3)
96
+ h_layout2.addWidget(self.eq3)
97
+ h_layout2.addWidget(self.randomButton)
98
+ # h_layout2.addWidget(self.updateButton)
99
+
100
+ # Text Area
101
+ self.textArea = QTextEdit()
102
+ self.textArea.setReadOnly(True)
103
+ self.textArea.setText(
104
+ "0: 0\t\t\t1: 0.5\t\t\t2: 1\n"
105
+ "3: x\t\t\t4: x^2\t\t\t5: x^3\n"
106
+ "6: x^4\t\t\t7: sqrt(x)\t\t8: sqrt(sqrt(x))\n"
107
+ "9: sin(90*x)\t\t10: cos(90*x)\t\t11: |x-0.5|\n"
108
+ "12: (2*x-1)^2\t\t13: sin(180*x)\t\t14: |cos(180*x)|\n"
109
+ "15: sin(360*x)\t\t16: cos(360*x)\t\t17: |sin(360*x)|\n"
110
+ "18: |cos(360*x)|\t\t19: |sin(720*x)|\t\t20: |cos(720*x)|\n"
111
+ "21: 3*x\t\t\t22: 3*x-1\t\t23: 3*x-2\n"
112
+ "24: |3*x-1|\t\t25: |3*x-2|\t\t26: (3*x-1)/2\n"
113
+ "27: (3*x-2)/2\t\t28: |(3*x-1)/2|\t\t29: |(3*x-2)/2|\n"
114
+ "30: x/0.32-25/32\t\t31: 2*x-0.84\t\t32: x\n"
115
+ "33: |2*x - 0.5|\t\t34: 2*x\t\t\t35: 2*x - 0.5\n"
116
+ "36: 2*x - 1\t\t37: eq. #1\t\t38: eq. #2\n"
117
+ "39: eq. #3\n\n"
118
+ "NB: negative numbers --> returns the negative of the generated palette\n"
119
+ "NB2: I used Gnuplot numbering for equations to promote compatibility between the 2 softwares\n"
120
+ "NB3: the idea of using formulas to create LUTs is coming from Gnuplot"
121
+ )
122
+ # Set the font to monospace
123
+ font = QFont("Courier New", 12) # You can adjust the font size as needed
124
+ self.textArea.setFont(font)
125
+
126
+ # Disable scrollbars
127
+ self.textArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
128
+ self.textArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
129
+
130
+ # Resize QTextEdit to fit its content
131
+ self.textArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
132
+ self.textArea.setMinimumHeight(360) # Set a minimum height to ensure it's usable
133
+
134
+ formula_layout.addLayout(h_layout1)
135
+ formula_layout.addLayout(h_layout2)
136
+ formula_layout.addWidget(self.textArea)
137
+
138
+ self.formula_group.setLayout(formula_layout)
139
+ layout.addWidget(self.formula_group)
140
+
141
+ self.setLayout(layout)
142
+
143
+ self.update_palette()
144
+
145
+
146
+ def randomize_formulas(self):
147
+ rand = int(self.randomSign(random.uniform(0, 39)))
148
+ self.redFormula.setText(str(rand))
149
+ rand = int(self.randomSign(random.uniform(0, 39)))
150
+ self.greenFormula.setText(str(rand))
151
+ rand = int(self.randomSign(random.uniform(0, 39)))
152
+ self.blueFormula.setText(str(rand))
153
+ self.update_palette()
154
+
155
+ def randomSign(self, nb):
156
+ return nb if random.random() > 0.5 else -nb
157
+
158
+ def update_palette(self):
159
+ if self.check_validity():
160
+ # Here, you would call your function to create and update the palette
161
+ self.palette = self.create_palette(
162
+ self.redFormula.text(),
163
+ self.greenFormula.text(),
164
+ self.blueFormula.text(),
165
+ self.eq1.text(),
166
+ self.eq2.text(),
167
+ self.eq3.text()
168
+ )
169
+ self.show_palette()
170
+ def check_validity(self):
171
+ return all([self.redFormula.text(), self.greenFormula.text(), self.blueFormula.text()])
172
+
173
+ def create_palette(self, red_formula, green_formula, blue_formula, eq1, eq2, eq3):
174
+ # print('red_formula, green_formula, blue_formula, eq1, eq2, eq3', red_formula, green_formula, blue_formula, eq1, eq2, eq3)
175
+ pc = PaletteCreator()
176
+ # lut = pc.create2(None, str(red_formula)+str(eq1), str(green_formula)+str(eq2), str(blue_formula)+str(eq3))
177
+ lut = pc.create2(f'{str(red_formula)},{ str(green_formula)},{str(blue_formula)}', eq1,eq2, eq3)
178
+
179
+ # print('lut', lut)
180
+
181
+ # self.show_palette()
182
+ return lut # Return the LUT for preview
183
+
184
+ def show_palette(self):
185
+ if self.palette is not None:
186
+ # print('show_palette called')
187
+ # Compute the total length based on your button dimensions and spacing
188
+ total_length = 760#(button_width * 16) + (spacing * 15) # Adjust based on columns and spacing
189
+ updateLutLabelPreview(self.palette, self.previewLabel, total_length, height=32)
190
+ else:
191
+ if self.check_validity():
192
+ QMessageBox.warning(self, "No Palette", "No palette to display. Please generate a palette first.")
193
+
194
+ def get_palette(self):
195
+ """
196
+ Returns the current LUT.
197
+
198
+ :return: The current LUT or None if no LUT has been generated.
199
+ """
200
+ return self.palette
201
+
202
+
203
+ if __name__ == '__main__':
204
+ app = QApplication(sys.argv)
205
+ jar_folder = "" # Provide the correct path if needed
206
+ ex = PaletteFormulaEditor()
207
+ ex.setWindowTitle('Palette Formula Editor')
208
+ ex.show()
209
+ sys.exit(app.exec_())