Skip to content

Commit 17bbbee

Browse files
authored
#3 dark mode for graphs
1 parent ab16434 commit 17bbbee

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/__main__.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import qdarktheme
33
from PyQt6.QtGui import QAction, QIcon
44
from PyQt6.QtWidgets import QApplication, QMainWindow, QDockWidget, QVBoxLayout, QWidget, QLineEdit, QListWidget, \
5-
QAbstractItemView, QToolBar
5+
QAbstractItemView, QToolBar, QStatusBar, QSizePolicy
66
from PyQt6.QtCore import Qt
77
from GraphWidget import MatplotlibWidget
88

@@ -11,13 +11,16 @@ class Graphite(QMainWindow):
1111
def __init__(self):
1212
super().__init__()
1313

14-
self.setWindowTitle("Graphite.")
14+
self.setWindowTitle("Graphyte.")
1515
self.setWindowIcon(QIcon("resources/icons/icon_black.ico"))
1616
self.setGeometry(100, 100, 800, 600)
1717

1818
self.toolbox = QToolBar(self)
1919
self.toolbox.setFixedHeight(40)
20-
#self.addToolBar(self.toolbox)
20+
# self.addToolBar(self.toolbox)
21+
22+
self.bottom_bar = QStatusBar()
23+
self.setStatusBar(self.bottom_bar)
2124

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

2932
# Connect actions to their respective functions
30-
# action1.triggered.connect(self.on_button1_click)
31-
#action2.triggered.connect(self.on_button2_click)
33+
# action1.triggered.connect(self.on_button1_click)
34+
# action2.triggered.connect(self.on_button2_click)
3235

3336
# Add actions to the toolbar
3437
self.toolbox.addAction(move)
@@ -68,11 +71,22 @@ def __init__(self):
6871
central_layout.addWidget(self.toolbox)
6972
central_layout.addWidget(self.graph_widget)
7073

74+
# Add a stretchable spacer to fill the status bar
75+
spacer = QWidget()
76+
spacer.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
77+
78+
self.bottom_bar.addWidget(spacer)
7179
# Create an input bar below the graphing area
7280
self.input_bar = QLineEdit()
81+
#self.input_bar.setAlignment(Qt.AlignmentFlag.AlignRight)
82+
# self.input_bar.setMinimumWidth(500)
7383
self.input_bar.returnPressed.connect(self.update_graph)
7484
central_layout.addWidget(self.input_bar)
7585

86+
self.bottom_bar.addWidget(spacer)
87+
self.bottom_bar.addWidget(self.input_bar)
88+
# self.bottom_bar.addWidget(self.input_bar)
89+
7690
# List to hold user-entered functions
7791
self.functions = []
7892

@@ -85,6 +99,7 @@ def listboxActions(self):
8599
def update_graph(self):
86100
function_text = self.input_bar.text()
87101
self.functions.append(function_text)
102+
self.function_list_widget.addItem(function_text)
88103
self.graph_widget.plot_function(self.functions)
89104

90105
def _move(self):
@@ -100,13 +115,14 @@ def remove_selected_function(self):
100115
row = self.function_list_widget.row(selected_items[0])
101116
self.function_list_widget.takeItem(row)
102117
self.functions.remove(selected_item_text)
118+
f = ["sin(x)", "cos(x)"]
103119
self.graph_widget.plot_function(self.functions)
104120

105121

106-
107122
if __name__ == "__main__":
108123
app = QApplication(sys.argv)
109124
window = Graphite()
125+
window.showMaximized()
110126
qdarktheme.setup_theme("dark")
111127
window.show()
112128
sys.exit(app.exec())

0 commit comments

Comments
 (0)