From a6de582e356a2bcb5b8dbd0a309a8ceb84ed0a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D0=B0=D1=80=20=D0=97=D0=B0=D1=80=D1=87?= =?UTF-8?q?=D1=83=D0=BA=D0=BE=D0=B2?= Date: Fri, 26 Jun 2020 20:55:22 +0500 Subject: [PATCH] added center func --- src/view/buy_window.py | 10 +++++++++- src/view/currency_window.py | 18 ++++++++++++++++-- src/view/login_window.py | 16 ++++++++++++---- src/view/main_window.py | 20 ++++++++++++++++++-- src/view/sell_wndow.py | 10 +++++++++- 5 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/view/buy_window.py b/src/view/buy_window.py index f1bb26f..234091f 100644 --- a/src/view/buy_window.py +++ b/src/view/buy_window.py @@ -1,7 +1,7 @@ from decimal import Decimal from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QMainWindow, QMessageBox +from PyQt5.QtWidgets import QDesktopWidget, QMainWindow, QMessageBox from requests.exceptions import ConnectionError from src.DAL.client import Client @@ -44,5 +44,13 @@ def buy(self): except DALError as e: QMessageBox().warning(self, 'Ошибка', str(e)) + def center(self): + frame = self.frameGeometry() + center_point = QDesktopWidget().availableGeometry().center() + + frame.moveCenter(center_point) + self.move(frame.topLeft()) + def init(self): + self.center() self.show() diff --git a/src/view/currency_window.py b/src/view/currency_window.py index 795df3b..40d7338 100644 --- a/src/view/currency_window.py +++ b/src/view/currency_window.py @@ -30,7 +30,12 @@ def __init__(self, parent, user: User, currency: UserCurrency): self.setWindowTitle(currency.name) def set_text_info( - self, selling_price, buying_price, account, currency_amount, currency_name + self, + selling_price: str, + buying_price: str, + account: str, + currency_amount: str, + currency_name: str, ): self.buyingPrice.setText('Cтоимость покупки: ' + str(buying_price) + ' у.е.') self.sellingPrice.setText('Стоимость продажи: ' + str(selling_price) + ' у.е.') @@ -99,7 +104,16 @@ def draw_graphs(self): list(time.keys()), selling_prices, 'Цена продажи', (255, 0, 0), 1.5, 'o', 5, ) - def plot(self, x, y, plot_name, color, width, symbol, symbol_size): + def plot( + self, + x: list, + y: list, + plot_name: str, + color: tuple, + width: float, + symbol: str, + symbol_size: int, + ): pen = pg.mkPen(color=color, width=width) self.graphicsView.plot( x, diff --git a/src/view/login_window.py b/src/view/login_window.py index ffe5999..678363a 100644 --- a/src/view/login_window.py +++ b/src/view/login_window.py @@ -1,5 +1,5 @@ from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QMainWindow, QMessageBox +from PyQt5.QtWidgets import QDesktopWidget, QMainWindow, QMessageBox from requests.exceptions import ConnectionError from src.DAL.client import Client @@ -16,9 +16,6 @@ def __init__(self): self.confirmButton.clicked.connect(self.auth) self.cancelButton.clicked.connect(lambda: self.close()) - def init(self): - self.show() - def auth(self): self.close() try: @@ -33,3 +30,14 @@ def auth(self): return self.mainWindow = MainWindow(user, self) self.mainWindow.init() + + def center(self): + frame = self.frameGeometry() + center_point = QDesktopWidget().availableGeometry().center() + + frame.moveCenter(center_point) + self.move(frame.topLeft()) + + def init(self): + self.center() + self.show() diff --git a/src/view/main_window.py b/src/view/main_window.py index e1b31cf..f47e271 100644 --- a/src/view/main_window.py +++ b/src/view/main_window.py @@ -1,6 +1,14 @@ +from typing import List + from PyQt5 import QtWidgets from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QMainWindow, QMessageBox, QPushButton, QTableWidgetItem +from PyQt5.QtWidgets import ( + QDesktopWidget, + QMainWindow, + QMessageBox, + QPushButton, + QTableWidgetItem, +) from requests.exceptions import ConnectionError from src.DAL.client import Client @@ -98,7 +106,15 @@ def fill_operations(self): def show_details(self, user: User, currency: UserCurrency): CurrencyWindow(self, user, currency).init() + def center(self): + frame = self.frameGeometry() + center_point = QDesktopWidget().availableGeometry().center() + + frame.moveCenter(center_point) + self.move(frame.topLeft()) + def init(self): + self.center() self.operationsTable.setRowCount(0) self.allCurrenciesTable.setRowCount(0) self.myCurrenciesTable.setRowCount(0) @@ -113,7 +129,7 @@ def init(self): self.show() -def create_headers(table_name, labels): +def create_headers(table_name, labels: List[str]): table_name.setColumnCount(len(labels)) table_name.setHorizontalHeaderLabels(labels) diff --git a/src/view/sell_wndow.py b/src/view/sell_wndow.py index 3a072ce..4373726 100644 --- a/src/view/sell_wndow.py +++ b/src/view/sell_wndow.py @@ -1,7 +1,7 @@ from decimal import Decimal from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QMainWindow, QMessageBox +from PyQt5.QtWidgets import QDesktopWidget, QMainWindow, QMessageBox from requests.exceptions import ConnectionError from src.DAL.client import Client @@ -43,5 +43,13 @@ def sell(self): except DALError as e: QMessageBox().warning(self, 'Ошибка', str(e)) + def center(self): + frame = self.frameGeometry() + center_point = QDesktopWidget().availableGeometry().center() + + frame.moveCenter(center_point) + self.move(frame.topLeft()) + def init(self): + self.center() self.show()