Skip to content

Commit

Permalink
ErrorBarsDialog: Change dialog to popup-like widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Dec 6, 2024
1 parent 026e4f7 commit b25d35c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
20 changes: 14 additions & 6 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,26 @@ def _add_controls_axis(self):
vizrank_box.layout().addWidget(button)
self.vizrankSelectionChanged.connect(self.set_attr)

self.__x_axis_dlg = ErrorBarsDialog(self, "Axis x Error Bars")
self.__x_axis_dlg = ErrorBarsDialog(self)
self.__x_axis_dlg.changed.connect(self.__on_x_dlg_changed)
self.__y_axis_dlg = ErrorBarsDialog(self, "Axis y Error Bars")
self.__y_axis_dlg = ErrorBarsDialog(self)
self.__y_axis_dlg.changed.connect(self.__on_y_dlg_changed)

def __on_x_button_clicked(self):
self.__x_axis_dlg.show_dlg(self.data.domain, self.attr_x_upper,
self.attr_x_lower, self.attr_x_is_abs)
self.__show_bar_dlg(
self.__x_axis_dlg, self.button_attr_x,
self.attr_x_upper, self.attr_x_lower, self.attr_x_is_abs)

def __on_y_button_clicked(self):
self.__y_axis_dlg.show_dlg(self.data.domain, self.attr_y_upper,
self.attr_y_lower, self.attr_y_is_abs)
self.__show_bar_dlg(
self.__y_axis_dlg, self.button_attr_y,
self.attr_y_upper, self.attr_y_lower, self.attr_y_is_abs)

def __show_bars_dlg(self, dlg, button, upper, lower, is_abs):
pos = button.mapToGlobal(button.rect().bottomLeft())
dlg.show_dlg(self.data.domain,
pos.x(), pos.y(),
upper, lower, is_abs)

def __on_x_dlg_changed(self):
self.attr_x_upper, self.attr_x_lower, self.attr_x_is_abs = \
Expand Down
14 changes: 8 additions & 6 deletions Orange/widgets/visualize/utils/error_bars_dialog.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import sys
from typing import Optional

from AnyQt.QtCore import Signal
from AnyQt.QtWidgets import QDialog, QVBoxLayout, QWidget, QComboBox, \
from AnyQt.QtCore import Signal, Qt
from AnyQt.QtWidgets import QVBoxLayout, QWidget, QComboBox, \
QFormLayout, QLabel, QButtonGroup, QRadioButton, QLayout

from Orange.data import ContinuousVariable, Domain
from Orange.widgets.utils import disconnected
from Orange.widgets.utils.itemmodels import DomainModel


class ErrorBarsDialog(QDialog):
class ErrorBarsDialog(QWidget):
changed = Signal()

def __init__(
self,
parent: QWidget,
title: str,
):
super().__init__(parent, windowTitle=title)
self.setModal(True)
super().__init__(parent)
self.setWindowFlags(self.windowFlags() | Qt.Popup)
self.hide()
self.__model = DomainModel(
separators=False,
valid_types=(ContinuousVariable,),
Expand Down Expand Up @@ -68,13 +68,15 @@ def get_data(self) -> tuple[
def show_dlg(
self,
domain: Domain,
x: int, y: int,
attr_upper: Optional[ContinuousVariable] = None,
attr_lower: Optional[ContinuousVariable] = None,
is_abs: bool = True
):
self._set_data(domain, attr_upper, attr_lower, is_abs)
self.show()
self.raise_()
self.move(x, y)
self.activateWindow()

def _set_data(
Expand Down
8 changes: 3 additions & 5 deletions i18n/si/msgs.jaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ util.py:
def `funcv`:
unsafe: false
version.py:
3.38.0: false
3.38.0.dev0+b3dd2eb: false
b3dd2eba6a3cfa73ba06460226d6e16a8e25a23a: false
3.39.0: false
3.39.0.dev0+c2c1648: false
c2c16487816d19a63177fae0b9febf1f0220f982: false
.dev: false
canvas/__main__.py:
ORANGE_STATISTICS_API_URL: false
Expand Down Expand Up @@ -14695,8 +14695,6 @@ widgets/visualize/owscatterplot.py:
attr_y: false
Axis y:: Os y:
Find Informative Projections: Poišči informativne projekcije
Axis x Error Bars: Napaka Osi x
Axis y Error Bars: Napaka Osi y
def `_add_controls_sampling`:
auto_sample: false
Sample: Vzorec
Expand Down

0 comments on commit b25d35c

Please sign in to comment.