Commit f23a759a authored by Margaux Mouchene's avatar Margaux Mouchene
Browse files

replace buttons by menu/qactions

parent b866d224
......@@ -12,6 +12,7 @@ from PyQt5.QtCore import (
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout,
QPushButton, QToolBar,
QSizePolicy,
)
from insarviz.utils import (get_nearest)
......@@ -134,6 +135,7 @@ class myPlotWindow(QWidget):
"""
Window to display the plots
"""
sig_clear_plots = pyqtSignal()
def __init__(self, plot_model, plottype):
"""
......@@ -171,9 +173,18 @@ class myPlotWindow(QWidget):
toolbar = QToolBar("Graph toolbar")
self.zoom_button = QPushButton('Zoom')
self.zoom_button.setCheckable(True)
self.theme_button = QPushButton('Dark/Light',
clicked=self.plot_widget.setStyle)
self.clear_button = QPushButton(
'Clear',
clicked=self.sig_clear_plots.emit)
self.theme_button = QPushButton(
'Dark/Light',
clicked=self.plot_widget.setStyle)
toolbar.addWidget(self.zoom_button)
toolbar.addWidget(self.clear_button)
spacer = QWidget(self)
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
toolbar.addWidget(spacer)
toolbar.addWidget(self.theme_button)
# layout
......
......@@ -5,6 +5,7 @@ import logging
from PyQt5.QtWidgets import (
QSizePolicy, QApplication, QLabel, QWidget, QGridLayout,
QPushButton,QSlider, QMainWindow, QFileDialog, QToolBar,
QMenu, QAction, QMenuBar
)
from PyQt5.QtCore import (
......@@ -52,7 +53,7 @@ class MainWindow(QMainWindow):
self.slider.valueChanged.connect(self.display_date)
# current date label:
self.date_label = QLabel('Click Open to load data')
self.date_label = QLabel('Click on File > Open to load data')
self.date_label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.date_label.setMaximumHeight(20)
......@@ -100,34 +101,64 @@ class MainWindow(QMainWindow):
# plot window:
self.plotw_t = None
# Toolbar:
toolbar = QToolBar("Main toolbar")
open_button = QPushButton('Open',
clicked=self.on_button_clicked_open)
quit_button = QPushButton('Quit',
clicked=self.on_button_clicked_quit)
self.plotwindowbutton = QPushButton("Plots")
self.plotwindowbutton.setCheckable(True)
self.plotwindowbutton.setEnabled(False)
self.plotwindowbutton.toggled.connect(self.show_plot_window)
self.clear_graph_button = QPushButton("Clear Profile", self)
self.clear_graph_button.setEnabled(False)
self.clear_graph_button.clicked.connect(self.on_button_clicked_clear_plot)
toolbar.addWidget(open_button)
toolbar.addSeparator()
toolbar.addWidget(minimap_button)
toolbar.addSeparator()
toolbar.addWidget(self.plotwindowbutton)
toolbar.addWidget(self.clear_graph_button)
spacer = QWidget(self)
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
toolbar.addWidget(spacer)
toolbar.addSeparator()
toolbar.addWidget(quit_button)
self.addToolBar(toolbar)
# menu
menubar = self.menuBar()
menubar.setNativeMenuBar(False)
filemenu = menubar.addMenu('File')
open_action = QAction("Open", self)
open_action.triggered.connect(self.on_button_clicked_open)
quit_action = QAction("Quit", self)
quit_action.triggered.connect(self.on_button_clicked_quit)
filemenu.addAction(open_action)
filemenu.addSeparator()
filemenu.addAction(quit_action)
viewmenu = menubar.addMenu('View')
plotwin_action = QAction("Plot Window", self)
plotwin_action.setCheckable(True)
plotwin_action.setChecked(False)
plotwin_action.toggled.connect(self.show_plot_window)
minimap_action = QAction("Minimap", self)
minimap_action.setCheckable(True)
minimap_action.setChecked(True)
minimap_action.toggled.connect(self.minimap_widget.setVisible)
self.minimap_widget.sigClosing.connect(minimap_action.setChecked)
viewmenu.addAction(plotwin_action)
viewmenu.addAction(minimap_action)
# # Toolbar:
# toolbar = QToolBar("Main toolbar")
# open_button = QPushButton('Open',
# clicked=self.on_button_clicked_open)
# quit_button = QPushButton('Quit',
# clicked=self.on_button_clicked_quit)
# self.plotwindowbutton = QPushButton("Plots")
# self.plotwindowbutton.setCheckable(True)
# self.plotwindowbutton.setEnabled(False)
# self.plotwindowbutton.toggled.connect(self.show_plot_window)
# self.clear_graph_button = QPushButton("Clear Profile", self)
# self.clear_graph_button.setEnabled(False)
# self.clear_graph_button.clicked.connect(self.on_button_clicked_clear_plot)
# toolbar.addWidget(open_button)
# toolbar.addSeparator()
# toolbar.addWidget(minimap_button)
# toolbar.addSeparator()
# toolbar.addWidget(self.plotwindowbutton)
# toolbar.addWidget(self.clear_graph_button)
# spacer = QWidget(self)
# spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
# toolbar.addWidget(spacer)
# toolbar.addSeparator()
# toolbar.addWidget(quit_button)
# self.addToolBar(toolbar)
# loading directly if file specified upon app launch:
self.current_filename = filename
......@@ -149,8 +180,8 @@ class MainWindow(QMainWindow):
self.slider.setMaximum(len(self.map_model.loader)-1)
self.slider.setValue(len(self.map_model.loader)//2)
# enable plot buttons:
self.plotwindowbutton.setEnabled(True)
self.clear_graph_button.setEnabled(True)
# self.plotwindowbutton.setEnabled(True)
# self.clear_graph_button.setEnabled(True)
def display_date(self):
""" display the date_number's date and print it on status bar """
......@@ -207,8 +238,15 @@ class MainWindow(QMainWindow):
plot_model=self.plot_model)
self.map_widget.sig_map2plotw.connect(
self.plotw_s.plot_widget.plotLoadedData)
self.plotw_t.move(self.x()+self.width(), self.y()+self.minimap_widget.height())
self.plotw_s.move(self.x()+self.width()+30, self.y()+self.minimap_widget.height()+30)
self.plotw_t.move(self.x() + self.width(),
self.y() + self.minimap_widget.height())
self.plotw_s.move(self.x() + self.width() + 30,
self.y()+self.minimap_widget.height() + 30)
self.plotw_t.sig_clear_plots.connect(
self.on_button_clicked_clear_plot)
self.plotw_s.sig_clear_plots.connect(
self.on_button_clicked_clear_plot)
self.plotw_s.show()
self.plotw_t.show()
......@@ -254,7 +292,7 @@ class MainWindow(QMainWindow):
# clear plots
self.plotw_t.on_button_clicked_clearplot()
self.plotw_s.on_button_clicked_clearplot()
self.show_plot_window(True)
# self.show_plot_window(True)
def main():
QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment