Skip to content
Snippets Groups Projects
Commit 8b5b0cd5 authored by Lan Dam's avatar Lan Dam
Browse files

Shortcut, tooltip, pep8

parent 6c330361
No related branches found
No related tags found
1 merge request!40Shortcut, tooltip, pep8
......@@ -4,9 +4,9 @@ from PySide2 import QtWidgets
class FileListItem(QtWidgets.QListWidgetItem):
"""
Widget to select file and save the absolute path of the file under
self.filePath variable
self.file_path variable
"""
def __init__(self, filePath, parent=None):
super().__init__(filePath.name, parent,
def __init__(self, file_path, parent=None):
super().__init__(file_path.name, parent,
type=QtWidgets.QListWidgetItem.UserType)
self.filePath = filePath
self.file_path = file_path
# UI and connectSignals for MainWindow
# UI and connectSignals for main_window
from PySide2 import QtCore, QtGui, QtWidgets
from sohstationviewer.view.calendar.calendar_widget import CalendarWidget
from sohstationviewer.view.plotting.state_of_health_widget import SOHWidget
from sohstationviewer.conf import constants
......@@ -22,7 +23,7 @@ def add_separation_line(layout):
class UIMainWindow(object):
def __init__(self):
"""
Class that create widgets, menus and connect signals for MainWindow.
Class that create widgets, menus and connect signals for main_window.
"""
super().__init__()
"""
......@@ -243,9 +244,9 @@ class UIMainWindow(object):
self.view_plot_type_action = None
# ========================= Help Menu =============================
"""
calendarAction: QAction - Open Calendar Dialog as a helpful tool
calendar_action: QAction - Open Calendar Dialog as a helpful tool
"""
self.calendarAction = None
self.calendar_action = None
"""
about_action: QAction - Open About Dialog to give information about
SOHView
......@@ -277,6 +278,7 @@ class UIMainWindow(object):
main_layout.addWidget(self.tracking_info_text_browser)
self.create_menu_bar(main_window)
self.connect_signals(main_window)
self.create_shortcuts(main_window)
def set_first_row(self, main_layout):
"""
......@@ -388,15 +390,21 @@ class UIMainWindow(object):
search_grid.addWidget(self.replot_button, 1, 3, 1, 1)
color_tip_fmt = ('Set the background color of the plot '
' to {0}')
background_layout = QtWidgets.QHBoxLayout()
# background_layout.setContentsMargins(0, 0, 0, 0)
left_layout.addLayout(background_layout)
background_layout.addWidget(QtWidgets.QLabel('Background: '))
self.background_black_radio_button = QtWidgets.QRadioButton(
'B', self.central_widget)
self.background_black_radio_button.setToolTip(
color_tip_fmt.format('black'))
background_layout.addWidget(self.background_black_radio_button)
self.background_white_radio_button = QtWidgets.QRadioButton(
'W', self.central_widget)
self.background_white_radio_button.setToolTip(
color_tip_fmt.format('white'))
background_layout.addWidget(self.background_white_radio_button)
add_separation_line(left_layout)
......@@ -477,16 +485,25 @@ class UIMainWindow(object):
submit_layout.setSpacing(5)
left_layout.addLayout(submit_layout)
self.read_button = QtWidgets.QPushButton('Read', self.central_widget)
self.read_button.setToolTip('Read selected files')
submit_layout.addWidget(self.read_button)
self.stop_button = QtWidgets.QPushButton('Stop', self.central_widget)
self.stop_button.setToolTip('Halt ongoing read')
submit_layout.addWidget(self.stop_button)
self.save_plot_button = QtWidgets.QPushButton(
'Save plot', self.central_widget)
self.save_plot_button.setToolTip('Save plots to disk')
submit_layout.addWidget(self.save_plot_button)
self.info_list_widget = QtWidgets.QListWidget(self.central_widget)
left_layout.addWidget(self.info_list_widget, 1)
def create_shortcuts(self, main_window):
seq = QtGui.QKeySequence('Ctrl+F')
chdir_shortcut = QtWidgets.QShortcut(seq, main_window)
chdir_shortcut.activated.connect(
main_window.change_current_directory)
def create_menu_bar(self, main_window):
"""
Setting up menu bar
......@@ -505,6 +522,7 @@ class UIMainWindow(object):
self.create_file_menu(main_window, file_menu)
self.create_command_menu(main_window, command_menu)
self.create_option_menu(main_window, option_menu)
self.create_database_menu(main_window, database_menu)
self.create_help_menu(main_window, help_menu)
......@@ -603,9 +621,9 @@ class UIMainWindow(object):
:param main_window: QMainWindow - main GUI for user to interact with
:param menu: QMenu - Help Menu
"""
self.calendarAction = QtWidgets.QAction(
self.calendar_action = QtWidgets.QAction(
'Calendar', main_window)
menu.addAction(self.calendarAction)
menu.addAction(self.calendar_action)
self.about_action = QtWidgets.QAction(
'About', main_window)
......@@ -657,11 +675,12 @@ class UIMainWindow(object):
# Form
# Help
self.calendarAction.triggered.connect(main_window.open_calendar)
self.calendar_action.triggered.connect(main_window.open_calendar)
def connect_widget_signals(self, main_window):
main_window.current_directory_changed.connect(
self.cwd_line_edit.setText)
# first Row
self.time_from_date_edit.setCalendarWidget(CalendarWidget(main_window))
self.time_from_date_edit.setDate(QtCore.QDate.fromString(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment