part 1 screen updated: hint button added, plot displaying finished, save button is now operational
This commit is contained in:
parent
0f836cf5fa
commit
6cc5097b1d
@ -1,7 +1,10 @@
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
from PySide6 import QtCore, QtWidgets, QtGui
|
||||
import time
|
||||
import plots
|
||||
import asyncio
|
||||
import PIL
|
||||
|
||||
|
||||
class TitleScreen(QtWidgets.QWidget):
|
||||
@ -65,14 +68,40 @@ class TitleScreen(QtWidgets.QWidget):
|
||||
class Part1(QtWidgets.QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.n = 0
|
||||
self.hint_open = False
|
||||
self.started = False
|
||||
self.q = QtGui.QScreen.availableGeometry(QtWidgets.QApplication.primaryScreen())
|
||||
h = self.q.height() * 0.2
|
||||
plots.empty_plot(3)
|
||||
|
||||
self.points = QtWidgets.QLabel(self)
|
||||
self.points.setGeometry(QtCore.QRect(7.5 * h - 60, 3 * h - 80, 140, 20))
|
||||
self.points.setText('Измеренных точек: ' + str(self.n))
|
||||
|
||||
self.disclaimer = QtWidgets.QLabel(self)
|
||||
self.disclaimer.setText('<html><p align=\"left\"><span style=\" font-size:10pt; font-weight:600;\">Не '
|
||||
'забудьте прочитать методику<\p><p align=\"left\"><span style=\" font-size:10pt; '
|
||||
'font-weight:600;\">и подсказку выше перед началом работы!<\p><\html>')
|
||||
self.disclaimer.setGeometry(7.5 * h - 150, h, 400, 100)
|
||||
|
||||
self.button = QtWidgets.QPushButton(self)
|
||||
self.button.setGeometry(QtCore.QRect(20, 20, 40, 40))
|
||||
self.button.setText("Esc")
|
||||
|
||||
self.start_btn = QtWidgets.QPushButton(self)
|
||||
self.start_btn.setText("Начать измерения")
|
||||
self.start_btn.setGeometry(QtCore.QRect(7.5 * h - 150, 3 * h - 50, 120, 30))
|
||||
|
||||
self.reset_btn = QtWidgets.QPushButton(self)
|
||||
self.reset_btn.setText("Сбросить")
|
||||
self.reset_btn.setGeometry(QtCore.QRect(7.5 * h + 30, 3 * h - 50, 120, 30))
|
||||
|
||||
self.save_btn = QtWidgets.QPushButton(self)
|
||||
self.save_btn.setText("Сохранить")
|
||||
self.save_btn.setGeometry(QtCore.QRect(7.5 * h - 60, 3 * h, 120, 30))
|
||||
self.save_btn.hide()
|
||||
|
||||
self.title = QtWidgets.QLabel(self)
|
||||
self.title.setText(
|
||||
"<html><head/><body><p align=\"center\"><span style=\" font-size:16pt; font-weight:600;\">ЧАСТЬ "
|
||||
@ -84,7 +113,7 @@ class Part1(QtWidgets.QWidget):
|
||||
self.back_button.setGeometry(QtCore.QRect(20, self.q.height() - 20, 80, 40))
|
||||
self.back_button.setText("Назад")
|
||||
|
||||
self.pixmap0 = QtGui.QPixmap('Aspect-ratio-4x3.png')
|
||||
self.pixmap0 = QtGui.QPixmap('tmpplot1.jpg')
|
||||
self.pixmap = self.pixmap0.scaledToHeight(3 * h)
|
||||
self.plot1 = QtWidgets.QLabel(self)
|
||||
self.plot1.setPixmap(self.pixmap)
|
||||
@ -108,26 +137,40 @@ class Part1(QtWidgets.QWidget):
|
||||
"align=\"left\"><span style=\" font-size:10pt;\">значения "
|
||||
"и график.</p></html>")
|
||||
self.text.setGeometry(QtCore.QRect(6 * h, h + 20, 3 * h, 2 * h + 20))
|
||||
self.text.setStyleSheet("border: 1px solid black; background-color: white;")
|
||||
self.text.hide()
|
||||
|
||||
self.start_btn = QtWidgets.QPushButton(self)
|
||||
self.start_btn.setText("Начать измерения")
|
||||
self.start_btn.setGeometry(QtCore.QRect(7.5 * h - 150, 4 * h - 50, 120, 30))
|
||||
|
||||
self.reset_btn = QtWidgets.QPushButton(self)
|
||||
self.reset_btn.setText("Сбросить")
|
||||
self.reset_btn.setGeometry(QtCore.QRect(7.5 * h + 30, 4 * h - 50, 120, 30))
|
||||
|
||||
self.save_btn = QtWidgets.QPushButton(self)
|
||||
self.save_btn.setText("Сохранить")
|
||||
self.save_btn.setGeometry(QtCore.QRect(7.5 * h - 60, 4 * h, 120, 30))
|
||||
self.save_btn.hide()
|
||||
self.hint_btn = QtWidgets.QPushButton(self)
|
||||
self.hint_btn.setText('?')
|
||||
self.hint_btn.setGeometry(QtCore.QRect(self.q.width() - 60, 20, 40, 40))
|
||||
|
||||
self.button.clicked.connect(self.esc)
|
||||
self.back_button.clicked.connect(self.back)
|
||||
self.start_btn.clicked.connect(self.start_stop)
|
||||
self.reset_btn.clicked.connect(self.reset)
|
||||
self.hint_btn.clicked.connect(self.hint)
|
||||
self.save_btn.clicked.connect(self.savefile)
|
||||
|
||||
timer = QtCore.QTimer(self)
|
||||
timer.timeout.connect(self.upd_plot)
|
||||
timer.start(500)
|
||||
|
||||
@QtCore.Slot()
|
||||
def savefile(self):
|
||||
file, check = QtWidgets.QFileDialog.getSaveFileName(None, "Сохранить график 1",
|
||||
r"C:\Users\Vadim\Desktop\plot1.jpg", "Images (*.png *.jpg)")
|
||||
if check:
|
||||
plot1 = PIL.Image.open('tmpplot3.jpg')
|
||||
plot1.save(file)
|
||||
|
||||
def hint(self):
|
||||
if not self.hint_open:
|
||||
self.text.show()
|
||||
self.hint_open = True
|
||||
else:
|
||||
self.text.hide()
|
||||
self.hint_open = False
|
||||
|
||||
def esc(self):
|
||||
self.close()
|
||||
|
||||
@ -136,20 +179,40 @@ class Part1(QtWidgets.QWidget):
|
||||
self.w.showFullScreen()
|
||||
self.close()
|
||||
|
||||
def show_plot(self):
|
||||
self.points.setText('Измеренных точек: ' + str(self.n))
|
||||
self.pixmap0 = QtGui.QPixmap('tmpplot3.jpg')
|
||||
self.pixmap = self.pixmap0.scaledToHeight(0.6 * self.q.height())
|
||||
self.plot1.setPixmap(self.pixmap)
|
||||
|
||||
def upd_plot(self):
|
||||
if self.started:
|
||||
plots.update_plot(3)
|
||||
self.n += 10
|
||||
self.show_plot()
|
||||
|
||||
def start_stop(self):
|
||||
if not self.started:
|
||||
self.start_btn.setText("Стоп")
|
||||
self.started = True
|
||||
self.save_btn.hide()
|
||||
self.hint_btn.hide()
|
||||
|
||||
else:
|
||||
self.start_btn.setText("Продолжить")
|
||||
self.started = False
|
||||
self.save_btn.show()
|
||||
self.hint_btn.show()
|
||||
|
||||
def reset(self):
|
||||
self.started = False
|
||||
self.start_btn.setText("Начать измерения")
|
||||
self.save_btn.hide()
|
||||
self.hint_btn.show()
|
||||
self.n = 0
|
||||
plots.empty_plot(3)
|
||||
self.show_plot()
|
||||
|
||||
|
||||
|
||||
class Part2(QtWidgets.QWidget):
|
||||
|
Loading…
Reference in New Issue
Block a user