Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added center func #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/view/buy_window.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
18 changes: 16 additions & 2 deletions src/view/currency_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ' у.е.')
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 12 additions & 4 deletions src/view/login_window.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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()
20 changes: 18 additions & 2 deletions src/view/main_window.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down
10 changes: 9 additions & 1 deletion src/view/sell_wndow.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()