def __init__(self, parent, *args): QWidget.__init__(self, parent, *args) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) lo = QVBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo1 = QHBoxLayout() lo.addLayout(lo1) lo1.setContentsMargins(0, 0, 0, 0) lbl = QLabel(QString("<nobr><b>Source groupings:</b></nobr>"), self) lo1.addWidget(lbl, 0) lo1.addStretch(1) # add show/hide button self._showattrbtn = QPushButton(self) self._showattrbtn.setMinimumWidth(256) lo1.addWidget(self._showattrbtn, 0) lo1.addStretch() QObject.connect(self._showattrbtn, SIGNAL("clicked()"), self._togglePlotControlsVisibility) # add table self.table = QTableWidget(self) lo.addWidget(self.table) QObject.connect(self.table, SIGNAL("cellChanged(int,int)"), self._valueChanged) self.table.setSelectionMode(QTableWidget.NoSelection) # setup basic columns self.table.setColumnCount(6 + len(self.EditableAttrs)) for i, label in enumerate( ("grouping", "total", "selection", "list", "plot", "style")): self.table.setHorizontalHeaderItem(i, QTableWidgetItem(label)) self.table.horizontalHeader().setSectionHidden(self.ColApply, True) # setup columns for editable grouping attributes for i, attr in self.AttrByCol.items(): self.table.setHorizontalHeaderItem( i, QTableWidgetItem(PlotStyles.StyleAttributeLabels[attr])) self.table.horizontalHeader().setSectionHidden(i, True) self.table.verticalHeader().hide() # other internal init self._attrs_shown = False self._togglePlotControlsVisibility() self.model = None self._setting_model = False self._currier = PersistentCurrier() # row of 'selected' grouping self._irow_selgroup = 0
def __init__(self, main): self.main = main ########################################################################## ##### Display the conversion values based on the Coinbase API self.lastPriceFetch = 0 self.lblHeader = QRichLabel(tr("""<b>Tracking buy and sell prices on Coinbase every 60 seconds</b>"""), doWrap=False) self.lblLastTime = QRichLabel('', doWrap=False) self.lblSellLabel = QRichLabel(tr('Coinbase <b>Sell</b> Price (USD):'), doWrap=False) self.lblBuyLabel = QRichLabel(tr('Coinbase <b>Buy</b> Price (USD):'), doWrap=False) self.lblSellPrice = QRichLabel('<Not Available>') self.lblBuyPrice = QRichLabel('<Not Available>') self.lastSellStr = '' self.lastBuyStr = '' self.btnUpdate = QPushButton(tr('Check Now')) self.main.connect(self.btnUpdate, SIGNAL('clicked()'), self.checkUpdatePrice) ########################################################################## ##### A calculator for converting prices between USD and BTC lblCalcTitle = QRichLabel(tr("""Convert between USD and BTC using Coinbase sell price"""), hAlign=Qt.AlignHCenter, doWrap=False) self.edtEnterUSD = QLineEdit() self.edtEnterBTC = QLineEdit() self.lblEnterUSD1 = QRichLabel('$') self.lblEnterUSD2 = QRichLabel('USD') self.lblEnterBTC = QRichLabel('BTC') btnClear = QPushButton('Clear') self.main.connect(self.edtEnterUSD, SIGNAL('textEdited(QString)'), self.updateCalcBTC) self.main.connect(self.edtEnterBTC, SIGNAL('textEdited(QString)'), self.updateCalcUSD) def clearCalc(): self.edtEnterUSD.setText('') self.edtEnterBTC.setText('') self.main.connect(btnClear, SIGNAL('clicked()'), clearCalc) frmCalcMid = makeHorizFrame( [self.lblEnterUSD1, self.edtEnterUSD, self.lblEnterUSD2, 'Stretch', self.edtEnterBTC, self.lblEnterBTC]) frmCalcClear = makeHorizFrame(['Stretch', btnClear, 'Stretch']) frmCalc = makeVertFrame([lblCalcTitle, frmCalcMid, frmCalcClear], STYLE_PLAIN) ########################################################################## ##### A table showing you the total balance of each wallet in USD and BTC lblWltTableTitle = QRichLabel(tr("Wallet balances converted to USD"), doWrap=False, hAlign=Qt.AlignHCenter) numWallets = len(self.main.walletMap) self.wltTable = QTableWidget(self.main) self.wltTable.setRowCount(numWallets) self.wltTable.setColumnCount(4) self.wltTable.horizontalHeader().setStretchLastSection(True) self.wltTable.setMinimumWidth(600) ########################################################################## ##### Setup the main layout for the tab mainLayout = QGridLayout() i=0 mainLayout.addWidget(self.lblHeader, i,0, 1,3) i+=1 mainLayout.addItem(QSpacerItem(15,15), i,0) mainLayout.addWidget(self.lblSellLabel, i,1) mainLayout.addWidget(self.lblSellPrice, i,2) i+=1 mainLayout.addItem(QSpacerItem(15,15), i,0) mainLayout.addWidget(self.lblBuyLabel, i,1) mainLayout.addWidget(self.lblBuyPrice, i,2) i+=1 mainLayout.addWidget(self.lblLastTime, i,0, 1,2) mainLayout.addWidget(self.btnUpdate, i,2) i+=1 mainLayout.addItem(QSpacerItem(20,20), i,0) i+=1 mainLayout.addWidget(frmCalc, i,0, 1,3) i+=1 mainLayout.addItem(QSpacerItem(30,30), i,0) i+=1 mainLayout.addWidget(lblWltTableTitle, i,0, 1,3) i+=1 mainLayout.addWidget(self.wltTable, i,0, 1,3) mainLayout.setColumnStretch(0,0) mainLayout.setColumnStretch(1,1) mainLayout.setColumnStretch(2,1) tabWidget = QWidget() tabWidget.setLayout(mainLayout) frmH = makeHorizFrame(['Stretch', tabWidget, 'Stretch']) frm = makeVertFrame(['Space(20)', frmH, 'Stretch']) # Now set the scrollarea widget to the layout self.tabToDisplay = QScrollArea() self.tabToDisplay.setWidgetResizable(True) self.tabToDisplay.setWidget(frm)