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

WIP: Attempting to change Color palette from Plot config #73

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 14 additions & 1 deletion trace/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@
if not archiver_urls:
archiver_urls = [os.getenv("PYDM_ARCHIVER_URL")]

color_palette = [QColor(hex_code) for hex_code in loaded_json["colors"]]
color_palettes = {
"Classic": [QColor(hex_code) for hex_code in loaded_json["colors"]],
"Apple": [QColor(hex_code) for hex_code in loaded_json["colors-apple"]],
"Java": [QColor(hex_code) for hex_code in loaded_json["colors-java"]],
"Excel": [QColor(hex_code) for hex_code in loaded_json["colors-excel"]],
"Diverging": [QColor(hex_code) for hex_code in loaded_json["colors-diverging"]],
"Dark": [QColor(hex_code) for hex_code in loaded_json["colors-dark"]],
}
palette_choice = "Classic"
color_palette = color_palettes[palette_choice]
def change_palette(palette: str):
palette_choice = palette
color_palette = color_palettes[palette_choice]
print("foo")
73 changes: 59 additions & 14 deletions trace/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
<x>0</x>
<y>0</y>
<width>1146</width>
<height>413</height>
<height>418</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -464,6 +464,64 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="clrscheme_lyt">
<item>
<widget class="QLabel" name="clrscheme_lbl">
<property name="text">
<string>Color Scheme</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="clrscheme_cmbbx">
<item>
<property name="text">
<string>Classic</string>
</property>
</item>
<item>
<property name="text">
<string>Apple</string>
</property>
</item>
<item>
<property name="text">
<string>Java</string>
</property>
</item>
<item>
<property name="text">
<string>Excel</string>
</property>
</item>
<item>
<property name="text">
<string>Diverging</string>
</property>
</item>
<item>
<property name="text">
<string>Dark</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="clrscheme_spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="xafs_lyt">
<item>
Expand Down Expand Up @@ -677,19 +735,6 @@
</item>
</layout>
</item>
<item>
<spacer name="plot_properties_spcr">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down
8 changes: 8 additions & 0 deletions trace/mixins/plot_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Dict
import config
from qtpy.QtGui import QColor, QFont

from pyqtgraph import ViewBox
from qtpy.QtGui import QFont, QColor
Expand Down Expand Up @@ -36,6 +38,7 @@ def plot_config_init(self):
self.ui.crosshair_chckbx.stateChanged.connect(lambda show: self.plot.enableCrosshair(show, 100, 100))

self.ui.mouse_mode_cmbbx.currentIndexChanged.connect(self.changeMouseMode)
self.ui.clrscheme_cmbbx.currentTextChanged.connect(self.set_palette)

def plot_setup(self, config: Dict):
"""Read in the full config dictionary, making sure not to fail if a user manually typed
Expand All @@ -60,6 +63,11 @@ def plot_setup(self, config: Dict):
if "refreshInterval" in config:
self.ui.refresh_interval_spnbx.setValue(config["refreshInterval"])

@Slot(str)
def set_palette(self, choice: str):
if choice in config.color_palettes:
config.change_palette(choice)

@Slot(int)
def set_font_size(self, size: int):
font = QFont()
Expand Down
2 changes: 1 addition & 1 deletion trace/widgets/table_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ def index_color(index: int) -> QColor:
"""Returns the color in the color palette at index."""
modded_index = index % len(color_palette)
color = color_palette[modded_index]

print(color_palette)
dark_factor = (index // len(color_palette)) * 35
return color.darker(100 + dark_factor)
Loading