Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no need to store style_dict inside a function #97

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions emodelrunner/GUI_utils/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)

from emodelrunner.GUI_utils.plotshape import get_morph_lines
from emodelrunner.GUI_utils.style import get_style_cst
from emodelrunner.GUI_utils.style import style_dict


def positive_int_callback(input_):
Expand Down Expand Up @@ -89,8 +89,6 @@ def __init__(self, parent, gui, attr_name, label):
"""
ttk.Frame.__init__(self, parent, style="TFrame")

style_dict = get_style_cst()

# label
self.label = ttk.Label(self, text=f"{label}:")

Expand Down Expand Up @@ -160,8 +158,6 @@ def __init__(self, parent, gui):
"""
ttk.Frame.__init__(self, parent, style="TFrame")

style_dict = get_style_cst()

self.step_stim = tk.DoubleVar()
self.step_stim.set(gui.simulation.step_stim) # step1 is selected

Expand Down Expand Up @@ -264,8 +260,6 @@ def __init__(self, parent, gui):
"""
ttk.Frame.__init__(self, parent, style="TFrame")

style_dict = get_style_cst()

self.hold_stim = tk.DoubleVar()
self.hold_stim.set(gui.simulation.hypamp) # default hold stim is selected

Expand Down Expand Up @@ -962,8 +956,6 @@ def __init__(self, parent, gui, title):
"""
ttk.LabelFrame.__init__(self, parent, style="Boxed.TFrame", labelwidget=title)

style_dict = get_style_cst()

# -- labels --
self.labels = []
self.labels.append(ttk.Label(self, text="Synapses"))
Expand Down
40 changes: 15 additions & 25 deletions emodelrunner/GUI_utils/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,25 @@
import matplotlib as mpl


def get_style_cst():
"""Returns dict containing style vars such as colors.

Returns:
dict: style colors, font and width
"""
style_dict = {}
# font & width. has to be an attribute to be accessible.
# somehow, entry font & width cannot be configurated with style.
style_dict["base_font"] = "Helvetica 10"
style_dict["entry_width"] = 8

# BBP colors
style_dict["light_blue"] = "#15D3FF"
style_dict["blue"] = "#0B83CD"
style_dict["deep_blue"] = "#050A58"
style_dict["light_grey"] = "#F2F2F2"
style_dict["grey"] = "#888888"
style_dict["deep_grey"] = "#333333"
style_dict["white"] = "#FFFFFF"

return style_dict
style_dict = {}
# font & width. has to be an attribute to be accessible.
# somehow, entry font & width cannot be configurated with style.
style_dict["base_font"] = "Helvetica 10"
style_dict["entry_width"] = 8

# BBP colors
style_dict["light_blue"] = "#15D3FF"
style_dict["blue"] = "#0B83CD"
style_dict["deep_blue"] = "#050A58"
style_dict["light_grey"] = "#F2F2F2"
style_dict["grey"] = "#888888"
style_dict["deep_grey"] = "#333333"
style_dict["white"] = "#FFFFFF"


def set_matplotlib_style():
"""Configure ticks & labels size."""
mpl.rcParams["lines.color"] = get_style_cst()["blue"]
mpl.rcParams["lines.color"] = style_dict["blue"]
mpl.rcParams["axes.labelsize"] = 8
mpl.rcParams["xtick.labelsize"] = 8
mpl.rcParams["ytick.labelsize"] = 8
Expand All @@ -55,8 +47,6 @@ def define_style(style):
Args:
style (ttk.Style): style
"""
style_dict = get_style_cst()

style.configure(
"TButton",
background=style_dict["white"],
Expand Down