Skip to content

Commit

Permalink
Merge pull request #733 from Sjoerd1993/Tune-label-size-chooser
Browse files Browse the repository at this point in the history
Tune labelsize chooser
  • Loading branch information
cmkohnen committed Jan 17, 2024
2 parents 73c537d + 511f447 commit 1d6eea2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions data/ui/style_editor.blp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ template $GraphsStyleEditor : Adw.NavigationPage {
width-request: 200;
adjustment: Adjustment {
lower: 1;
upper: 2;
upper: 4;
};
}
}
Expand All @@ -70,7 +70,7 @@ template $GraphsStyleEditor : Adw.NavigationPage {
width-request: 200;
adjustment: Adjustment {
lower: 1;
upper: 2;
upper: 4;
};
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def on_accept(self, _button):

def _title_format_function(_scale, value: float) -> str:
"""Format a float value as percentage string"""
return str(value * 100)[:3] + "%"
return str(value / 2 * 100).split(".")[0] + "%"


@Gtk.Template(resource_path="/se/sjoerd/Graphs/ui/style_editor.ui")
Expand Down Expand Up @@ -531,10 +531,10 @@ def load_style(self, style):
font_size = self.style_params["font.size"]
font_description.set_size(font_size * Pango.SCALE)
self.titlesize.set_value(
round(self.style_params["figure.titlesize"] / font_size, 1),
round(self.style_params["figure.titlesize"] * 2 / font_size, 1),
)
self.labelsize.set_value(
round(self.style_params["axes.labelsize"] / font_size, 1),
round(self.style_params["axes.labelsize"] * 2 / font_size, 1),
)
font_description.set_family(self.style_params["font.sans-serif"][0])
font_description.set_weight(self.style_params["font.weight"])
Expand Down Expand Up @@ -575,8 +575,8 @@ def save_style(self):
for key in ("font.size", "xtick.labelsize", "ytick.labelsize",
"legend.fontsize", "figure.labelsize"):
self.style_params[key] = font_size
titlesize = round(self.titlesize.get_value() * font_size, 1)
labelsize = round(self.labelsize.get_value() * font_size, 1)
titlesize = round(self.titlesize.get_value() / 2 * font_size, 1)
labelsize = round(self.labelsize.get_value() / 2 * font_size, 1)
self.style_params["figure.titlesize"] = titlesize
self.style_params["axes.titlesize"] = titlesize
self.style_params["axes.labelsize"] = labelsize
Expand Down

0 comments on commit 1d6eea2

Please sign in to comment.