Skip to content
Snippets Groups Projects
Commit 4df53d5f authored by Vincent Texier's avatar Vincent Texier
Browse files

Informations list separated in three groups

Catch exceptions on network request
parent 6451795d
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ Created on 2 févr. 2014 ...@@ -4,6 +4,7 @@ Created on 2 févr. 2014
@author: inso @author: inso
""" """
import logging
from PyQt5.QtWidgets import QWidget, QHeaderView from PyQt5.QtWidgets import QWidget, QHeaderView
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from ..models.parameters import ParametersModel from ..models.parameters import ParametersModel
...@@ -25,18 +26,43 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): ...@@ -25,18 +26,43 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
self.community = community self.community = community
self.account = account self.account = account
self.table_currency_informations.HorizontalHeader = QHeaderView(Qt.Orientation(Qt.Horizontal)) self.table_general.HorizontalHeader = QHeaderView(Qt.Orientation(Qt.Horizontal))
self.table_currency_informations.HorizontalHeader.setSectionResizeMode(QHeaderView.ResizeToContents) #self.table_general.HorizontalHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
self.table_currency_informations.HorizontalHeader.setStretchLastSection(True) self.table_general.HorizontalHeader.setStretchLastSection(True)
#self.table_currency_informations.HorizontalHeader.setSectionResizeMode(QHeaderView.Stretch) self.table_general.setHorizontalHeader(self.table_general.HorizontalHeader)
self.table_currency_informations.setHorizontalHeader(self.table_currency_informations.HorizontalHeader) self.table_general.horizontalHeader().hide()
self.table_currency_informations.horizontalHeader().hide() self.table_general.verticalHeader().hide()
self.table_currency_informations.verticalHeader().hide()
self.table_money.HorizontalHeader = QHeaderView(Qt.Orientation(Qt.Horizontal))
params = self.community.get_parameters() #self.table_money.HorizontalHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
block = self.community.get_ud_block() self.table_money.HorizontalHeader.setStretchLastSection(True)
infos = [ self.table_money.setHorizontalHeader(self.table_money.HorizontalHeader)
# variables self.table_money.horizontalHeader().hide()
self.table_money.verticalHeader().hide()
self.table_wot.HorizontalHeader = QHeaderView(Qt.Orientation(Qt.Horizontal))
#self.table_wot.HorizontalHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
self.table_wot.HorizontalHeader.setStretchLastSection(True)
self.table_wot.setHorizontalHeader(self.table_wot.HorizontalHeader)
self.table_wot.horizontalHeader().hide()
self.table_wot.verticalHeader().hide()
self.display_tables()
def display_tables(self):
try:
params = self.community.get_parameters()
except Exception as e:
logging.debug('community get_parameters error : ' + str(e))
return False
try:
block = self.community.get_ud_block()
except Exception as e:
logging.debug('community get_ud_block error : ' + str(e))
return False
general = [
{'name': 'dividend', 'value': block['dividend'], {'name': 'dividend', 'value': block['dividend'],
'description': 'Universal Dividend UD(t) in currency units'}, 'description': 'Universal Dividend UD(t) in currency units'},
{'name': 'monetaryMass', 'value': block['monetaryMass'], {'name': 'monetaryMass', 'value': block['monetaryMass'],
...@@ -47,7 +73,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): ...@@ -47,7 +73,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
'description': 'Monetary Mass per member M(t)/N(t) in currency units'}, 'description': 'Monetary Mass per member M(t)/N(t) in currency units'},
{'name': 'actualGrowth', {'name': 'actualGrowth',
'value': "{:2.2%}".format(block['dividend'] / ((block['monetaryMass'] - (block['membersCount'] * block['dividend'])) / block['membersCount'])), 'value': "{:2.2%}".format(block['dividend'] / ((block['monetaryMass'] - (block['membersCount'] * block['dividend'])) / block['membersCount'])),
'description': 'Actual % Growth (UD(t) / (M(t-1)/Nt))'}, 'description': 'Actual % Growth (UD(t) / (M(t-1)/Nt))'}
]
self.table_general.setModel(ParametersModel(general))
update_table_height(self.table_general, len(general))
money = [
# money params # money params
{'name': 'c', 'value': "{:2.0%}".format(params['c']), {'name': 'c', 'value': "{:2.0%}".format(params['c']),
'description': '% growth'}, 'description': '% growth'},
...@@ -64,7 +95,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): ...@@ -64,7 +95,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
{'name': 'blocksRot', 'value': params['blocksRot'], {'name': 'blocksRot', 'value': params['blocksRot'],
'description': 'The number of previous blocks to check for personalized difficulty'}, 'description': 'The number of previous blocks to check for personalized difficulty'},
{'name': 'percentRot', 'value': "{:2.0%}".format(params['percentRot']), {'name': 'percentRot', 'value': "{:2.0%}".format(params['percentRot']),
'description': 'The percent of previous issuers to reach for personalized difficulty'}, 'description': 'The percent of previous issuers to reach for personalized difficulty'}
]
self.table_money.setModel(ParametersModel(money))
update_table_height(self.table_money, len(money))
wot = [
# wot params # wot params
{'name': 'sigDelay', 'value': params['sigDelay'] / 86400, {'name': 'sigDelay', 'value': params['sigDelay'] / 86400,
'description': 'Minimum delay between 2 identical certifications (in days)'}, 'description': 'Minimum delay between 2 identical certifications (in days)'},
...@@ -79,7 +115,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): ...@@ -79,7 +115,12 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
{'name': 'stepMax', 'value': params['stepMax'], {'name': 'stepMax', 'value': params['stepMax'],
'description': 'Maximum distance between each WoT member and a newcomer'}, 'description': 'Maximum distance between each WoT member and a newcomer'},
] ]
self.table_wot.setModel(ParametersModel(wot))
self.table_currency_informations.setModel(ParametersModel(infos)) update_table_height(self.table_wot, len(wot))
def update_table_height(table, rows):
row_height = table.rowHeight(0)
table_height = (rows * row_height) + table.horizontalHeader().height() + (2 * table.frameWidth())
table.setMinimumHeight(table_height)
table.setMaximumHeight(table_height)
...@@ -41,11 +41,6 @@ class ParametersModel(QAbstractTableModel): ...@@ -41,11 +41,6 @@ class ParametersModel(QAbstractTableModel):
font = QFont() font = QFont()
font.setBold(True) font.setBold(True)
return font return font
elif role == Qt.BackgroundColorRole:
if index.row() > 12:
return QColor("#dddddd")
elif index.row() > 4:
return QColor("#eeeeee")
return None return None
def headerData(self, section, orientation, role=Qt.DisplayRole): def headerData(self, section, orientation, role=Qt.DisplayRole):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment