mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(colormap_selector): compatibility for PyQt6 when using designer fixed
This commit is contained in:
BIN
bec_widgets/assets/designer_icons/colormap_selector.png
Normal file
BIN
bec_widgets/assets/designer_icons/colormap_selector.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
@ -185,7 +185,7 @@ class BECDock(RPCBase):
|
||||
|
||||
@property
|
||||
@rpc_call
|
||||
def widget_list(self) -> "list[BECConnector]":
|
||||
def widget_list(self) -> "list[BECWidget]":
|
||||
"""
|
||||
Get the widgets in the dock.
|
||||
|
||||
@ -226,13 +226,13 @@ class BECDock(RPCBase):
|
||||
@rpc_call
|
||||
def add_widget(
|
||||
self,
|
||||
widget: "BECConnector | str",
|
||||
widget: "BECWidget | str",
|
||||
row=None,
|
||||
col=0,
|
||||
rowspan=1,
|
||||
colspan=1,
|
||||
shift: "Literal['down', 'up', 'left', 'right']" = "down",
|
||||
) -> "BECConnector":
|
||||
) -> "BECWidget":
|
||||
"""
|
||||
Add a widget to the dock.
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
@ -1 +0,0 @@
|
||||
{'files': ['color_map_selector.py']}
|
@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pyqtgraph as pg
|
||||
from qtpy.QtCore import Property, Signal, Slot
|
||||
from qtpy.QtGui import QColor, QFontMetrics, QImage
|
||||
@ -46,7 +48,7 @@ class ColormapSelector(QWidget):
|
||||
colormap_changed_signal = Signal(str)
|
||||
|
||||
def __init__(self, parent=None, default_colormaps=None):
|
||||
super().__init__(parent)
|
||||
super().__init__(parent=parent)
|
||||
self._colormaps = []
|
||||
self.initUI(default_colormaps)
|
||||
|
@ -0,0 +1 @@
|
||||
{'files': ['colormap_selector.py']}
|
@ -5,15 +5,18 @@ import os
|
||||
from qtpy.QtDesigner import QDesignerCustomWidgetInterface
|
||||
from qtpy.QtGui import QIcon
|
||||
|
||||
from bec_widgets.widgets.color_map_selector.color_map_selector import ColormapSelector
|
||||
import bec_widgets
|
||||
from bec_widgets.widgets.colormap_selector.colormap_selector import ColormapSelector
|
||||
|
||||
DOM_XML = """
|
||||
<ui language='c++'>
|
||||
<widget class='ColormapSelector' name='color_map_selector'>
|
||||
<widget class='ColormapSelector' name='colormap_selector'>
|
||||
</widget>
|
||||
</ui>
|
||||
"""
|
||||
|
||||
MODULE_PATH = os.path.dirname(bec_widgets.__file__)
|
||||
|
||||
|
||||
class ColormapSelectorPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
|
||||
def __init__(self):
|
||||
@ -31,12 +34,11 @@ class ColormapSelectorPlugin(QDesignerCustomWidgetInterface): # pragma: no cove
|
||||
return "BEC Buttons"
|
||||
|
||||
def icon(self):
|
||||
current_path = os.path.dirname(__file__)
|
||||
icon_path = os.path.join(current_path, "assets", "color_map_selector_icon.png")
|
||||
icon_path = os.path.join(MODULE_PATH, "assets", "designer_icons", "colormap_selector.png")
|
||||
return QIcon(icon_path)
|
||||
|
||||
def includeFile(self):
|
||||
return "color_map_selector"
|
||||
return "colormap_selector"
|
||||
|
||||
def initialize(self, form_editor):
|
||||
self._form_editor = form_editor
|
||||
@ -51,7 +53,7 @@ class ColormapSelectorPlugin(QDesignerCustomWidgetInterface): # pragma: no cove
|
||||
return "ColormapSelector"
|
||||
|
||||
def toolTip(self):
|
||||
return "A custom QComboBox widget for selecting colormaps."
|
||||
return ""
|
||||
|
||||
def whatsThis(self):
|
||||
return self.toolTip()
|
@ -6,7 +6,7 @@ def main(): # pragma: no cover
|
||||
return
|
||||
from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
|
||||
|
||||
from bec_widgets.widgets.color_map_selector.color_map_selector_plugin import (
|
||||
from bec_widgets.widgets.colormap_selector.colormap_selector_plugin import (
|
||||
ColormapSelectorPlugin,
|
||||
)
|
||||
|
@ -31,7 +31,7 @@
|
||||
<property name="title">
|
||||
<string>X Axis</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,1,3,0,1,3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,1,3,1,3">
|
||||
<item>
|
||||
<widget class="QLabel" name="x_mode_label">
|
||||
<property name="text">
|
||||
@ -82,22 +82,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
@ -121,13 +105,6 @@
|
||||
<item>
|
||||
<widget class="DeviceLineEdit" name="x_name"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="x_entry_label">
|
||||
<property name="text">
|
||||
@ -169,35 +146,14 @@
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="add_curve">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="normalize_colors_scan">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Normalize Colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="ColormapSelector" name="color_map_selector_scan">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="colormaps" stdset="0">
|
||||
<stringlist>
|
||||
<string>inferno</string>
|
||||
<string>viridis</string>
|
||||
<string>plasma</string>
|
||||
<string>magma</string>
|
||||
</stringlist>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QTableWidget" name="scan_table">
|
||||
<property name="rowCount">
|
||||
<number>0</number>
|
||||
@ -264,13 +220,19 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="normalize_colors_scan">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="add_curve">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Normalize Colors</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="ColormapSelector" name="color_map_selector_scan"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_DAP">
|
||||
@ -363,27 +325,12 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="add_dap">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="ColormapSelector" name="color_map_selector_dap">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="colormaps" stdset="0">
|
||||
<stringlist>
|
||||
<string>inferno</string>
|
||||
<string>viridis</string>
|
||||
<string>plasma</string>
|
||||
<string>magma</string>
|
||||
</stringlist>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="ColormapSelector" name="color_map_selector_dap"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -403,7 +350,7 @@
|
||||
<customwidget>
|
||||
<class>ColormapSelector</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>color_map_selector</header>
|
||||
<header>colormap_selector</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pyqtgraph as pg
|
||||
import pytest
|
||||
|
||||
from bec_widgets.widgets.color_map_selector.color_map_selector import ColormapSelector
|
||||
from bec_widgets.widgets.colormap_selector.colormap_selector import ColormapSelector
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
Reference in New Issue
Block a user