Skip to content

Commit 1107c26

Browse files
committed
Widgets: Remove left/right default margins in MessageLabel
- Those margins need to be set according to where/how that widget is used. - Set those margins where the label is used.
1 parent 6e4b2a2 commit 1107c26

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

spyder/plugins/projects/widgets/projectdialog.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ def __init__(self, parent):
9999
self._validation_label = MessageLabel(self)
100100
self._validation_label.setVisible(False)
101101

102+
validation_label_css = self._validation_label.css
103+
validation_label_css.QLabel.setValues(
104+
marginRight=f"{7 * AppStyle.MarginSize}px",
105+
# The extra 5px are necessary because we need to add them to all
106+
# lineedits in this dialog to align them to the labels on top of
107+
# them (see SpyderConfigPage.create_lineedit).
108+
marginLeft=f"{7 * AppStyle.MarginSize + 5}px",
109+
)
110+
self._validation_label.setStyleSheet(validation_label_css.toString())
111+
102112
self._description_font = self.get_font(SpyderFontType.Interface)
103113
self._description_font.setPointSize(
104114
self._description_font.pointSize() + 1

spyder/plugins/remoteclient/widgets/connectionpages.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def _create_password_subpage(self):
413413
)
414414

415415
validation_label = MessageLabel(self)
416+
self._set_css_for_validation_label(validation_label)
416417

417418
# Add widgets to their required dicts
418419
self._widgets_for_validation[AuthenticationMethod.Password].append(
@@ -468,6 +469,7 @@ def _create_keyfile_subpage(self):
468469
)
469470

470471
validation_label = MessageLabel(self)
472+
self._set_css_for_validation_label(validation_label)
471473

472474
# Add widgets to their required dicts
473475
self._widgets_for_validation[AuthenticationMethod.KeyFile].append(
@@ -517,6 +519,7 @@ def _create_configfile_subpage(self):
517519
)
518520

519521
validation_label = MessageLabel(self)
522+
self._set_css_for_validation_label(validation_label)
520523

521524
# Add widgets to their required dicts
522525
self._name_widgets[AuthenticationMethod.ConfigFile] = name
@@ -573,6 +576,7 @@ def _create_jupyterhub_subpage(self):
573576
)
574577

575578
validation_label = MessageLabel(self)
579+
self._set_css_for_validation_label(validation_label)
576580

577581
# Add widgets to their required dicts
578582
self._name_widgets[AuthenticationMethod.JupyterHub] = name
@@ -698,6 +702,17 @@ def _compose_failed_validation_text(self, reasons: ValidationReasons):
698702

699703
return text
700704

705+
def _set_css_for_validation_label(self, label: MessageLabel):
706+
css = label.css
707+
css.QLabel.setValues(
708+
marginRight=f"{9 * AppStyle.MarginSize}px",
709+
# The extra 5px are necessary because we need to add them to all
710+
# lineedits in this dialog to align them to the labels on top of
711+
# them (see SpyderConfigPage.create_lineedit).
712+
marginLeft=f"{9 * AppStyle.MarginSize + 5}px",
713+
)
714+
label.setStyleSheet(css.toString())
715+
701716

702717
class NewConnectionPage(BaseConnectionPage):
703718
"""Page to receive SSH credentials for a remote connection."""

spyder/widgets/helperwidgets.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -799,24 +799,23 @@ def __init__(self, parent):
799799
self.setVisible(False)
800800

801801
# Set style
802-
css = qstylizer.style.StyleSheet()
803-
css.QLabel.setValues(
802+
self.css = qstylizer.style.StyleSheet()
803+
self.css.QLabel.setValues(
804804
backgroundColor=SpyderPalette.COLOR_BACKGROUND_2,
805-
# Top margin is set by the layout
805+
# Top margin is usually set by the layout
806806
marginTop="0px",
807-
marginRight=f"{9 * AppStyle.MarginSize}px",
808-
# We don't need bottom margin because there are no other elements
809-
# below this one.
807+
# We usually don't need bottom margin because there are no other
808+
# elements below this one.
810809
marginBottom="0px",
811-
# The extra 5px are necessary because we need to add them to all
812-
# lineedits in this dialog to align them to the labels on top of
813-
# them (see SpyderConfigPage.create_lineedit).
814-
marginLeft=f"{9 * AppStyle.MarginSize + 5}px",
810+
# Left and right margins need to be set according to where/how this
811+
# widget is used.
812+
marginLeft="0px",
813+
marginRight="0px",
815814
padding=f"{3 * AppStyle.MarginSize}px {6 * AppStyle.MarginSize}px",
816815
borderRadius=SpyderPalette.SIZE_BORDER_RADIUS,
817816
)
818817

819-
self.setStyleSheet(css.toString())
818+
self.setStyleSheet(self.css.toString())
820819

821820
def set_text(self, text: str):
822821
n_reasons = 1

0 commit comments

Comments
 (0)