Skip to content

Commit

Permalink
added butons to each table item
Browse files Browse the repository at this point in the history
  • Loading branch information
MakzaR committed Jun 19, 2020
1 parent 71d45ae commit f3c3a8b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
13 changes: 10 additions & 3 deletions src/currency_window.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
4 changes: 1 addition & 3 deletions src/login_window.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
42 changes: 32 additions & 10 deletions src/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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 = [
Expand All @@ -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 у. е.')
]


Expand All @@ -64,50 +71,61 @@ 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

'''Тут чистый треш, но я просто тестил заполнение данных'''

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)

self.allCurrenciesTable.setItem(row, 0, QTableWidgetItem(i.name))
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)

self.myCurrenciesTable.setItem(row, 0, QTableWidgetItem(i.name))
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)

Expand All @@ -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):
Expand Down

0 comments on commit f3c3a8b

Please sign in to comment.