From f3c3a8bdc8b8f5b5b7afa1fa3a6714508fb31055 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, 19 Jun 2020 05:00:56 +0500 Subject: [PATCH] added butons to each table item --- src/currency_window.py | 13 ++++++++++--- src/login_window.py | 4 +--- src/main_window.py | 42 ++++++++++++++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/currency_window.py b/src/currency_window.py index df17bac..7a35c15 100644 --- a/src/currency_window.py +++ b/src/currency_window.py @@ -1,7 +1,5 @@ from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import ( - QMainWindow, -) +from PyQt5.QtWidgets import QMainWindow from ui.currency import Ui_CurrencyWindow @@ -11,5 +9,14 @@ def __init__(self, parent): super().__init__(parent, Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint) self.setupUi(self) + self.buyButton.clicked.connect(self.buy) + self.sellButton.clicked.connect(self.sell) + + def buy(self): + pass + + def sell(self): + pass + def init(self): self.show() diff --git a/src/login_window.py b/src/login_window.py index cbec61d..e7b1c7c 100644 --- a/src/login_window.py +++ b/src/login_window.py @@ -1,7 +1,5 @@ from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import ( - QMainWindow, -) +from PyQt5.QtWidgets import QMainWindow from src.main_window import MainWindow from ui.auth_form import Ui_AuthorizationForm diff --git a/src/main_window.py b/src/main_window.py index 1c5c230..fa2a116 100644 --- a/src/main_window.py +++ b/src/main_window.py @@ -2,11 +2,9 @@ from PyQt5 import QtWidgets from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import ( - QMainWindow, - QTableWidgetItem, -) +from PyQt5.QtWidgets import QMainWindow, QTableWidgetItem, QPushButton +from src.currency_window import CurrencyWindow from ui.main import Ui_MainWindow @@ -26,7 +24,7 @@ class OperationData(NamedTuple): all_currencies_data = [ CurrencyData('Крипта', 1, '+1%'), CurrencyData('Биток', 2, '-10%'), - CurrencyData('Эфирbvbvbdfsbbsfbbfb', 20, '+210%'), + CurrencyData('Эфирbvbvbdfsbbsfbbaasdadadadasdfb', 20, '+210%'), ] my_currencies_data = [ @@ -53,6 +51,15 @@ class OperationData(NamedTuple): OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.'), + OperationData('Продажа', 'Биток', 20, '+ 20 у. е.') ] @@ -64,13 +71,13 @@ def __init__(self, parent): self.searchButton.clicked.connect(self.search_item) self.refreshButton.clicked.connect(self.refresh_tables) - '''Логика кнопки поиска''' + self.currencyWindow = CurrencyWindow(self) + '''Логика кнопки поиска''' def search_item(self): pass '''Логика кнопки обновления''' - def refresh_tables(self): pass @@ -78,10 +85,13 @@ def refresh_tables(self): def fill_all_currencies(self): self.allCurrenciesTable.clear() - labels = ['Название', 'Цена', 'Изменение'] + labels = ['Название', 'Цена', 'Изменение', ''] create_headers(self.allCurrenciesTable, labels) for i in all_currencies_data: + detail_button = QPushButton('Подробнее') + detail_button.clicked.connect(self.show_details) + row = self.allCurrenciesTable.rowCount() self.allCurrenciesTable.setRowCount(row + 1) @@ -89,12 +99,17 @@ def fill_all_currencies(self): self.allCurrenciesTable.setItem(row, 1, QTableWidgetItem(str(i.price))) self.allCurrenciesTable.setItem(row, 2, QTableWidgetItem(i.change)) + self.allCurrenciesTable.setCellWidget(row, 3, detail_button) + def fill_my_currencies(self): self.myCurrenciesTable.clear() - labels = ['Название', 'Цена', 'Изменение'] + labels = ['Название', 'Цена', 'Изменение', ''] create_headers(self.myCurrenciesTable, labels) for i in my_currencies_data: + detail_button = QPushButton('Подробнее') + detail_button.clicked.connect(self.show_details) + row = self.myCurrenciesTable.rowCount() self.myCurrenciesTable.setRowCount(row + 1) @@ -102,12 +117,15 @@ def fill_my_currencies(self): self.myCurrenciesTable.setItem(row, 1, QTableWidgetItem(str(i.price))) self.myCurrenciesTable.setItem(row, 2, QTableWidgetItem(i.change)) + self.myCurrenciesTable.setCellWidget(row, 3, detail_button) + def fill_operations(self): self.operationsTable.clear() labels = ['Операция', 'Название', 'Количество', 'Счёт'] create_headers(self.operationsTable, labels) for i in operation_data: + row = self.operationsTable.rowCount() self.operationsTable.setRowCount(row + 1) @@ -116,11 +134,15 @@ def fill_operations(self): self.operationsTable.setItem(row, 2, QTableWidgetItem(str(i.amount))) self.operationsTable.setItem(row, 3, QTableWidgetItem(i.account)) + '''Логика кнопки "Подробнее"''' + def show_details(self): + self.currencyWindow.init() + def init(self): - self.show() self.fill_all_currencies() self.fill_my_currencies() self.fill_operations() + self.show() def create_headers(table_name, labels):