Skip to content

Commit

Permalink
#3 dark mode for graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
rohankishore committed Feb 12, 2024
1 parent ab16434 commit 17bbbee
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import qdarktheme
from PyQt6.QtGui import QAction, QIcon
from PyQt6.QtWidgets import QApplication, QMainWindow, QDockWidget, QVBoxLayout, QWidget, QLineEdit, QListWidget, \
QAbstractItemView, QToolBar
QAbstractItemView, QToolBar, QStatusBar, QSizePolicy
from PyQt6.QtCore import Qt
from GraphWidget import MatplotlibWidget

Expand All @@ -11,13 +11,16 @@ class Graphite(QMainWindow):
def __init__(self):
super().__init__()

self.setWindowTitle("Graphite.")
self.setWindowTitle("Graphyte.")
self.setWindowIcon(QIcon("resources/icons/icon_black.ico"))
self.setGeometry(100, 100, 800, 600)

self.toolbox = QToolBar(self)
self.toolbox.setFixedHeight(40)
#self.addToolBar(self.toolbox)
# self.addToolBar(self.toolbox)

self.bottom_bar = QStatusBar()
self.setStatusBar(self.bottom_bar)

move = QAction("Move", self)
move.triggered.connect(self._move)
Expand All @@ -27,8 +30,8 @@ def __init__(self):
save.setIcon(QIcon("resources/icons/save.png"))

# Connect actions to their respective functions
# action1.triggered.connect(self.on_button1_click)
#action2.triggered.connect(self.on_button2_click)
# action1.triggered.connect(self.on_button1_click)
# action2.triggered.connect(self.on_button2_click)

# Add actions to the toolbar
self.toolbox.addAction(move)
Expand Down Expand Up @@ -68,11 +71,22 @@ def __init__(self):
central_layout.addWidget(self.toolbox)
central_layout.addWidget(self.graph_widget)

# Add a stretchable spacer to fill the status bar
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)

self.bottom_bar.addWidget(spacer)
# Create an input bar below the graphing area
self.input_bar = QLineEdit()
#self.input_bar.setAlignment(Qt.AlignmentFlag.AlignRight)
# self.input_bar.setMinimumWidth(500)
self.input_bar.returnPressed.connect(self.update_graph)
central_layout.addWidget(self.input_bar)

self.bottom_bar.addWidget(spacer)
self.bottom_bar.addWidget(self.input_bar)
# self.bottom_bar.addWidget(self.input_bar)

# List to hold user-entered functions
self.functions = []

Expand All @@ -85,6 +99,7 @@ def listboxActions(self):
def update_graph(self):
function_text = self.input_bar.text()
self.functions.append(function_text)
self.function_list_widget.addItem(function_text)
self.graph_widget.plot_function(self.functions)

def _move(self):
Expand All @@ -100,13 +115,14 @@ def remove_selected_function(self):
row = self.function_list_widget.row(selected_items[0])
self.function_list_widget.takeItem(row)
self.functions.remove(selected_item_text)
f = ["sin(x)", "cos(x)"]
self.graph_widget.plot_function(self.functions)



if __name__ == "__main__":
app = QApplication(sys.argv)
window = Graphite()
window.showMaximized()
qdarktheme.setup_theme("dark")
window.show()
sys.exit(app.exec())

0 comments on commit 17bbbee

Please sign in to comment.