def __init__(self,**kwargs): super(NoteEditor,self).__init__(parent = kwargs.get('parent')) self.setWindowTitle('Note Editor') self.resize(400,400) # data noteData = kwargs.get('noteData','') # widget creation self.uiNote = QtWidgets.QTextEdit() self.uiCommit = QtWidgets.QPushButton(StyleUtils.getIcon('check'),'Commit') self.uiCancel = QtWidgets.QPushButton(StyleUtils.getIcon('close'),'Cancel') # widgetSettings self.uiNote.setText(noteData) # layout creation self.layMain = QtWidgets.QVBoxLayout() self.layOperators = QtWidgets.QHBoxLayout() # lay settings self.layOperators.addStretch() self.layOperators.addWidget(self.uiCommit) self.layOperators.addWidget(self.uiCancel) self.layMain.addWidget(self.uiNote) self.layMain.addLayout(self.layOperators) # layout assignment self.setLayout(self.layMain) # signals self.uiCancel.clicked.connect(self.reject) self.uiCommit.clicked.connect(self.updateNote)
def unitTest_SpinBox(): app = QtWidgets.QApplication(sys.argv) testDialog = QtWidgets.QDialog() layTest = QtWidgets.QHBoxLayout() layTest.addWidget(MoneySpinner()) testDialog.setLayout(layTest) ex = testDialog StyleUtils.setStyleSheet(ex) ex.show() sys.exit(app.exec_())
def __init__(self, *args, **kwargs): super(GroceryTreeItem,self).__init__(*args) self.parentWidget = kwargs.get('parentWidget') self.itemData = kwargs.get('itemData') self.hasNote = False if self.itemData['itemNote'] != '': self.hasNote = True self.setIcon(0,StyleUtils.getIcon('alert-triangle-orange')) self.parentWidget.taxUpdated.connect(self.updateTotal) labels = [ self.itemData['itemName'], self.itemData['itemPrice'], self.itemData['itemCrv'], str(self.itemData['itemTaxable']), str(0), str(self.itemData['itemTotal']), self.itemData['billTo'] ] for i in range(len(labels)): self.setText(i,labels[i]) self.updateTotal()
def setNote(self, note): if note != '': self.hasNote = True self.itemData['itemNote'] = note self.setIcon(0,StyleUtils.getIcon('alert-triangle-orange')) else: self.itemData['itemNote'] = '' self.setIcon(0,QtGui.QIcon())
def __init__(self,**kwargs): super(GroceryItemWidget,self).__init__() self.note = '' # Data self.billingActions = [] # Widget Construction self.lblItemName = QtWidgets.QLabel('Item Name:') self.uiItemName = QtWidgets.QLineEdit() self.lblPrice = QtWidgets.QLabel('Price:') self.uiPrice = QtWidgets.QDoubleSpinBox() self.lblCRV = QtWidgets.QLabel('CRV:') self.uiCRV = QtWidgets.QDoubleSpinBox() self.uiBillTo = QtWidgets.QPushButton('Add Bill Recipient:') self.uiBillToMenu = QtWidgets.QMenu() self.lblBillist = QtWidgets.QLabel() self.uiTaxable = QtWidgets.QCheckBox('Taxable') self.uiEditNote = QtWidgets.QPushButton() # Widget settings self.uiBillTo.setMenu(self.uiBillToMenu) for k in sorted(BillTo.keys()): action = QtWidgets.QAction(BillTo[k],self) action.setCheckable(True) action.triggered.connect(self.updateBillToList) self.uiBillToMenu.addAction(action) self.billingActions.append(action) self.uiEditNote.setIcon(StyleUtils.getIcon('edit')) self.uiEditNote.setToolTip('View/Edit Notes') # Layout Creation self.layMain = QtWidgets.QHBoxLayout() for widge in [ self.lblItemName, self.uiItemName, self.lblPrice, self.uiPrice, self.lblCRV, self.uiCRV, self.uiTaxable, self.uiBillTo, self.lblBillist, self.uiEditNote ]: self.layMain.addWidget(widge) self.setLayout(self.layMain) self.uiItemName.textEdited.connect(self.itemUpdated.emit) self.uiPrice.valueChanged.connect(self.itemUpdated.emit) self.uiCRV.valueChanged.connect(self.itemUpdated.emit) self.uiTaxable.stateChanged.connect(self.itemUpdated.emit) self.uiEditNote.clicked.connect(self.addNote)
def unitTest_main(): app = QtWidgets.QApplication(sys.argv) ex = AppLauncher() StyleUtils.setStyleSheet(ex) ex.show() sys.exit(app.exec_())
def unitTest_Main(): app = QtWidgets.QApplication(sys.argv) ex = RecieptBuddy() StyleUtils.setStyleSheet(ex) ex.show() sys.exit(app.exec_())
def __init__(self): super(RecieptBuddy_RecieptManager,self).__init__() self.rootItems = {} self.taxRate = 9.5 self.recieptItems = [] self.currentItem = None self.lastBackup = datetime.datetime.now() # data self.RecieptDir = os.path.join(os.environ.get('ArletaHouse'),'tools','recieptBuddy','source','lib','reciepts') if not os.path.isdir(self.RecieptDir): os.makedirs(self.RecieptDir) # widget creation self.uiRecieptSelector = QtWidgets.QComboBox() self.uiPayTo = QtWidgets.QComboBox() self.uiTaxRate = QtWidgets.QDoubleSpinBox() self.uiGroceryTreeWidget = QtWidgets.QTreeWidget() self.uiTemplateGroup = QtWidgets.QGroupBox('Item Template') self.uiItemTemplate = GroceryItemWidget() self.uiAddItem = QtWidgets.QPushButton(StyleUtils.getIcon('add'),'Add Item') # widget settings self.uiTaxRate.setValue(9.5) self.uiTemplateGroup.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum)) self.uiGroceryTreeWidget.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) for k in sorted(BillTo.keys()): self.uiPayTo.addItem(BillTo[k]) self.uiAddItem.setEnabled(False) self.uiGroceryTreeWidget.setHeaderLabels(['Item Name', 'Item Price','CRV','Taxable','Tax','Subtotal','Bill To']) self.uiGroceryTreeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.uiGroceryTreeWidget.customContextMenuRequested.connect(self.groceryTreeMenuRequested) #Layout Construction self.layMain = QtWidgets.QVBoxLayout() self.layForm = QtWidgets.QFormLayout() self.layTemplate = QtWidgets.QVBoxLayout() self.layOperators = QtWidgets.QHBoxLayout() #layout settings self.layTemplate.addWidget(self.uiItemTemplate) self.layTemplate.addLayout(self.layOperators) self.layOperators.addStretch() self.layOperators.addWidget(self.uiAddItem) self.layForm.addRow('Reciept:',self.uiRecieptSelector) self.layForm.addRow('Pay To:',self.uiPayTo) self.layForm.addRow('Tax Rate:',self.uiTaxRate) # self.layForm.addRow('Items:',self.uiGroceryTreeWidget) self.layMain.addLayout(self.layForm) self.layMain.addWidget(self.uiGroceryTreeWidget) self.layMain.addWidget(self.uiTemplateGroup) # layout application self.setLayout(self.layMain) self.uiTemplateGroup.setLayout(self.layTemplate) self.uiItemTemplate.itemUpdated.connect(self.verifyTemplate) self.uiAddItem.clicked.connect(self.addItem) self.uiRecieptSelector.currentIndexChanged.connect(self.openReciept) self.uiTaxRate.valueChanged.connect(self.updateTaxRate) self.uiTaxRate.valueChanged.connect(self.updateRecieptFile) self.uiPayTo.currentIndexChanged.connect(self.updateRecieptFile) self.recieptUpdated.connect(self.updateRecieptFile) self.populateReciepts()