Increasing generator usage.
This commit is contained in:
@@ -240,7 +240,7 @@ class App(QMainWindow):
|
||||
logger.warning("Save of submission type cancelled.")
|
||||
|
||||
def update_data(self):
|
||||
self.table_widget.sub_wid.setData(page=int(self.table_widget.pager.current_page.text()), page_size=page_size)
|
||||
self.table_widget.sub_wid.setData(page=self.table_widget.pager.page_anchor, page_size=page_size)
|
||||
|
||||
|
||||
class AddSubForm(QWidget):
|
||||
|
||||
@@ -3,7 +3,7 @@ Handles display of control charts
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta, date
|
||||
from typing import Tuple
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtWidgets import (
|
||||
@@ -113,6 +113,9 @@ class ControlsViewer(QWidget):
|
||||
self.chart_maker()
|
||||
return report
|
||||
|
||||
def diff_month(self, d1:date, d2:date):
|
||||
return abs((d1.year - d2.year) * 12 + d1.month - d2.month)
|
||||
|
||||
def chart_maker(self):
|
||||
"""
|
||||
Creates plotly charts for webview
|
||||
@@ -132,7 +135,8 @@ class ControlsViewer(QWidget):
|
||||
"""
|
||||
report = Report()
|
||||
# logger.debug(f"Control getter context: \n\tControl type: {self.con_type}\n\tMode: {self.mode}\n\tStart
|
||||
# Date: {self.start_date}\n\tEnd Date: {self.end_date}") NOTE: set the subtype for kraken
|
||||
# Date: {self.start_date}\n\tEnd Date: {self.end_date}")
|
||||
# NOTE: set the subtype for kraken
|
||||
if self.sub_typer.currentText() == "":
|
||||
self.subtype = None
|
||||
else:
|
||||
@@ -161,7 +165,8 @@ class ControlsViewer(QWidget):
|
||||
title = f"{self.mode} - {self.subtype}"
|
||||
# NOTE: send dataframe to chart maker
|
||||
df, modes = self.prep_df(ctx=self.app.ctx, df=df)
|
||||
fig = CustomFigure(df=df, ytitle=title, modes=modes, parent=self)
|
||||
months = self.diff_month(self.start_date, self.end_date)
|
||||
fig = CustomFigure(df=df, ytitle=title, modes=modes, parent=self, months=months)
|
||||
self.save_button.setEnabled(True)
|
||||
# logger.debug(f"Updating figure...")
|
||||
self.fig = fig
|
||||
|
||||
@@ -108,43 +108,6 @@ class AddReagentForm(QDialog):
|
||||
self.name_input.addItems(list(set([item.name for item in lookup])))
|
||||
|
||||
|
||||
# class ReportDatePicker(QDialog):
|
||||
# """
|
||||
# custom dialog to ask for report start/stop dates
|
||||
# """
|
||||
# def __init__(self) -> None:
|
||||
# super().__init__()
|
||||
# self.setWindowTitle("Select Report Date Range")
|
||||
# # NOTE: make confirm/reject buttons
|
||||
# QBtn = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
# self.buttonBox = QDialogButtonBox(QBtn)
|
||||
# self.buttonBox.accepted.connect(self.accept)
|
||||
# self.buttonBox.rejected.connect(self.reject)
|
||||
# # NOTE: widgets to ask for dates
|
||||
# self.start_date = QDateEdit(calendarPopup=True)
|
||||
# self.start_date.setObjectName("start_date")
|
||||
# self.start_date.setDate(QDate.currentDate())
|
||||
# self.end_date = QDateEdit(calendarPopup=True)
|
||||
# self.end_date.setObjectName("end_date")
|
||||
# self.end_date.setDate(QDate.currentDate())
|
||||
# self.layout = QVBoxLayout()
|
||||
# self.layout.addWidget(QLabel("Start Date"))
|
||||
# self.layout.addWidget(self.start_date)
|
||||
# self.layout.addWidget(QLabel("End Date"))
|
||||
# self.layout.addWidget(self.end_date)
|
||||
# self.layout.addWidget(self.buttonBox)
|
||||
# self.setLayout(self.layout)
|
||||
#
|
||||
# def parse_form(self) -> dict:
|
||||
# """
|
||||
# Converts information in this object to a dict
|
||||
#
|
||||
# Returns:
|
||||
# dict: output dict.
|
||||
# """
|
||||
# return dict(start_date=self.start_date.date().toPyDate(), end_date = self.end_date.date().toPyDate())
|
||||
|
||||
|
||||
class LogParser(QDialog):
|
||||
|
||||
def __init__(self, parent):
|
||||
@@ -253,35 +216,32 @@ class Pagifier(QWidget):
|
||||
def __init__(self, page_max:int):
|
||||
super().__init__()
|
||||
self.page_max = math.ceil(page_max)
|
||||
|
||||
self.page_anchor = 1
|
||||
next = QPushButton(parent=self, icon = QIcon.fromTheme(QIcon.ThemeIcon.GoNext))
|
||||
next.pressed.connect(self.increment_page)
|
||||
previous = QPushButton(parent=self, icon=QIcon.fromTheme(QIcon.ThemeIcon.GoPrevious))
|
||||
previous.pressed.connect(self.decrement_page)
|
||||
label = QLabel(f"/ {self.page_max}")
|
||||
label.setMinimumWidth(200)
|
||||
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.current_page = QLineEdit(self)
|
||||
self.current_page.setEnabled(False)
|
||||
# onlyInt = QIntValidator()
|
||||
# onlyInt.setRange(1, 4)
|
||||
# self.current_page.setValidator(onlyInt)
|
||||
self.current_page.setText("1")
|
||||
self.update_current_page()
|
||||
self.current_page.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.layout = QHBoxLayout()
|
||||
self.layout.addWidget(previous)
|
||||
self.layout.addWidget(self.current_page)
|
||||
self.layout.addWidget(label)
|
||||
self.layout.addWidget(next)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def increment_page(self):
|
||||
new = int(self.current_page.text())+1
|
||||
new = self.page_anchor + 1
|
||||
if new <= self.page_max:
|
||||
self.current_page.setText(str(new))
|
||||
self.page_anchor = new
|
||||
self.update_current_page()
|
||||
|
||||
def decrement_page(self):
|
||||
new = int(self.current_page.text())-1
|
||||
new = self.page_anchor - 1
|
||||
if new >= 1:
|
||||
self.current_page.setText(str(new))
|
||||
self.page_anchor = new
|
||||
self.update_current_page()
|
||||
|
||||
def update_current_page(self):
|
||||
self.current_page.setText(f"{self.page_anchor} of {self.page_max}")
|
||||
Reference in New Issue
Block a user