本文整理汇总了Python中wxbanker.lib.pubsub.Publisher类的典型用法代码示例。如果您正苦于以下问题:Python Publisher类的具体用法?Python Publisher怎么用?Python Publisher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Publisher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent, editing=None):
wx.Panel.__init__(self, parent)
# Create the recurring object we will use internally.
self.recurringObj = RecurringTransaction(None, None, 0, "", datetime.date.today(), RecurringTransaction.DAILY)
self.Sizer = wx.GridBagSizer(0, 3)
self.Sizer.SetEmptyCellSize((0,0))
self.recurringRow = RecurringRow(self, self.RECURRING_ROW)
self.recurringSummaryRow = RecurringSummaryRow(self, self.SUMMARY_ROW)
self.weeklyRecurringRow = WeeklyRecurringRow(self, self.WEEKLY_ROW)
self.transferRow = TransferRow(self, self.TRANSFER_ROW)
self.transactionRow = NewTransactionRow(self, self.TRANSACTION_ROW, editing=editing)
# can not set 2nd column growable in wx3.0 if Sizer is empty
self.Sizer.AddGrowableCol(1, 1)
# RecurringRow needs an update once both it and the other controls exist.
self.recurringRow.Update()
# Hide everything up to the actual transaction row initially.
if not editing:
for i in range(self.TRANSACTION_ROW):
self.ShowRow(i, False)
ctrlId = id(self.transactionRow)
Publisher.subscribe(self.onTransferToggled, "newtransaction.%i.transfertoggled"%ctrlId)
Publisher.subscribe(self.onRecurringToggled, "newtransaction.%i.recurringtoggled"%ctrlId)
开发者ID:assem-ch,项目名称:wxbanker,代码行数:28,代码来源:transactionctrl.py
示例2: init
def init(path=None, welcome=True):
import wx, sys
from wxbanker import fileservice
from wxbanker.controller import Controller
bankController = Controller(path)
# We can initialize the wx locale now that the wx.App is initialized.
localization.initWxLocale()
# Push our custom art provider.
import wx.lib.art.img2pyartprov as img2pyartprov
from wxbanker.art import silk, transparent
for provider in (silk, transparent):
wx.ArtProvider.Push(img2pyartprov.Img2PyArtProvider(provider))
# Initialize the wxBanker frame!
frame = BankerFrame(bankController, welcome)
# Greet the user if it appears this is their first time using wxBanker.
config = wx.Config.Get()
firstTime = not config.ReadBool("RUN_BEFORE")
if firstTime:
Publisher.sendMessage("first run")
config.WriteBool("RUN_BEFORE", True)
return bankController.wxApp
开发者ID:assem-ch,项目名称:wxbanker,代码行数:27,代码来源:main.py
示例3: OnPaneChanged
def OnPaneChanged(self, evt=None):
"""Redo the text and layout when the widget state is toggled."""
self.Layout()
# Change the labels
expanded = int(self.IsExpanded())
self.Label = self.Labels[expanded]
Publisher.sendMessage("CALCULATOR.TOGGLED", ("SHOW", "HIDE")[expanded])
开发者ID:gustavsen,项目名称:wxbanker,代码行数:8,代码来源:calculator.py
示例4: AddTransactions
def AddTransactions(self, transactions, sources=None):
Publisher.sendMessage("batch.start")
# If we don't have any sources, we want None for each transaction.
if sources is None:
sources = [None for i in range(len(transactions))]
for t, source in zip(transactions, sources):
self.AddTransaction(transaction=t, source=source)
Publisher.sendMessage("batch.end")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:9,代码来源:account.py
示例5: onButton
def onButton(self, event):
"""If the save button was clicked save, and close the dialog in any case (Close/Cancel/Save)."""
assert event.Id in (wx.ID_CLOSE, wx.ID_SAVE)
if event.Id == wx.ID_SAVE:
#we have to substract 1 from combo_box selection because we added the "base currency" entry
selectedCurrency = self.currencyCombo.GetSelection() - 1
Publisher.sendMessage("user.account_currency_changed", (self.Account, selectedCurrency))
self.GrandParent.Destroy()
开发者ID:assem-ch,项目名称:wxbanker,代码行数:10,代码来源:accountconfigdialog.py
示例6: onAccountClick
def onAccountClick(self, event):
"""
This method is called when the current account has been changed by clicking on an account name.
"""
radio = event.EventObject
if radio is self.allAccountsRadio:
account = None
else:
account = self.accountObjects[radio.AccountIndex]
Publisher.sendMessage("user.account changed", account)
开发者ID:assem-ch,项目名称:wxbanker,代码行数:10,代码来源:accountlistctrl.py
示例7: Remove
def Remove(self, accountName):
index = self.AccountIndex(accountName)
if index == -1:
raise bankexceptions.InvalidAccountException(accountName)
account = self.pop(index)
# Remove all the transactions associated with this account.
account.Purge()
Publisher.sendMessage("account.removed.%s"%accountName, account)
开发者ID:assem-ch,项目名称:wxbanker,代码行数:10,代码来源:accountlist.py
示例8: __init__
def __init__(self, parent, plotFactory, bankController):
wx.Panel.__init__(self, parent)
self.plotFactory = plotFactory
self.bankController = bankController
self.plotSettings = {'FitDegree': 2, 'Granularity': 100, 'Account': None, 'Months': 12}
self.plotLabels = [_("Trend Degree"), _("Months")]
self.currentPlotIndex = 0
self.cachedData = None
self.dateRange = None
self.isActive = False
# create the plot panel
self.plotPanel = plotFactory.createPanel(self, bankController)
# create the controls at the bottom
controlSizer = wx.BoxSizer()
self.graphChoice = wx.Choice(self, choices=[plot.NAME for plot in plotFactory.Plots])
self.optionCtrl = wx.SpinCtrl(self, min=1, max=24, initial=self.plotSettings['FitDegree'])
# the date range controls
self.startDate = bankcontrols.DateCtrlFactory(self)
self.endDate = bankcontrols.DateCtrlFactory(self)
self.optionText = wx.StaticText(self, label=self.plotLabels[0])
self.fromText = wx.StaticText(self, label=_("From"))
self.toText = wx.StaticText(self, label=_("until"))
controlSizer.Add(wx.StaticText(self, label=_("Graph")), 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(5)
controlSizer.Add(self.graphChoice, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(10)
controlSizer.Add(self.fromText, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(5)
controlSizer.Add(self.startDate, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(5)
controlSizer.Add(self.toText, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(5)
controlSizer.Add(self.endDate, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(10)
controlSizer.Add(self.optionText, 0, wx.ALIGN_CENTER_VERTICAL)
controlSizer.AddSpacer(5)
controlSizer.Add(self.optionCtrl, 0, wx.ALIGN_CENTER_VERTICAL)
self.optionCtrl.SetMinSize = (20, -1)
# put it all together
self.Sizer = wx.BoxSizer(wx.VERTICAL)
self.Sizer.Add(self.plotPanel, 1, wx.EXPAND)
self.Sizer.Add(controlSizer, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 6)
self.Layout()
# bind to the spin buttons
self.graphChoice.Bind(wx.EVT_CHOICE, self.onGraphChoice)
self.optionCtrl.Bind(wx.EVT_SPINCTRL, self.onOptionSpin)
self.Bind(wx.EVT_DATE_CHANGED, self.onDateRangeChanged)
Publisher.subscribe(self.onAccountSelect, "view.account changed")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:55,代码来源:summarytab.py
示例9: __init__
def __init__(self, path, autoSave=True):
self.Subscriptions = []
self.Version = 13
self.Path = path
self.AutoSave = False
self.Dirty = False
self.BatchDepth = 0
self.cachedModel = None
# Upgrades can't enable syncing if needed from older versions.
self.needsSync = False
existed = True
# See if the path already exists to decide what to do.
if not os.path.exists(self.Path):
existed = False
# Initialize the connection and optimize it.
connection = sqlite.connect(self.Path)
self.dbconn = connection
# Disable synchronous I/O, which makes everything MUCH faster, at the potential cost of durability.
self.dbconn.execute("PRAGMA synchronous=OFF;")
# If the db doesn't exist, initialize it.
if not existed:
debug.debug('Initializing', self.Path)
self.initialize()
else:
debug.debug('Loading', self.Path)
self.Meta = self.getMeta()
debug.debug(self.Meta)
while self.Meta['VERSION'] < self.Version:
# If we are creating a new db, we don't need to backup each iteration.
self.upgradeDb(self.Meta['VERSION'], backup=existed)
self.Meta = self.getMeta()
debug.debug(self.Meta)
# We have to subscribe before syncing otherwise it won't get synced if there aren't other changes.
self.Subscriptions = (
(self.onORMObjectUpdated, "ormobject.updated"),
(self.onAccountBalanceChanged, "account.balance changed"),
(self.onAccountRemoved, "account.removed"),
(self.onBatchEvent, "batch"),
(self.onExit, "exiting"),
)
for callback, topic in self.Subscriptions:
Publisher.subscribe(callback, topic)
# If the upgrade process requires a sync, do so now.
if self.needsSync:
self.syncBalances()
self.needsSync = False
self.AutoSave = autoSave
self.commitIfAppropriate()
开发者ID:assem-ch,项目名称:wxbanker,代码行数:55,代码来源:persistentstore.py
示例10: __init__
def __init__(self, bankmodel, store):
list.__init__(self, store.GetAccounts())
# Make sure all the items know their parent list.
for account in self:
account.Parent = self
self.BankModel = bankmodel
self.Store = store
self.sort()
Publisher.subscribe(self.onAccountRenamed, "ormobject.updated.Account.Name")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:11,代码来源:accountlist.py
示例11: AddRecurringTransaction
def AddRecurringTransaction(self, amount, description, date, repeatType, repeatEvery=1, repeatOn=None, endDate=None, source=None):
# Create the recurring transaction object.
recurring = RecurringTransaction(None, self, amount, description, date, repeatType, repeatEvery, repeatOn, endDate, source)
# Store it.
self.Store.MakeRecurringTransaction(recurring)
# Add it to our internal list.
self.RecurringTransactions.append(recurring)
Publisher.sendMessage("recurringtransaction.created", (self, recurring))
return recurring
开发者ID:assem-ch,项目名称:wxbanker,代码行数:11,代码来源:account.py
示例12: SetAutoSave
def SetAutoSave(self, val):
self._AutoSave = val
wx.Config.Get().WriteBool("AUTO-SAVE", val)
Publisher.sendMessage("controller.autosave_toggled", val)
for model in self.Models:
debug.debug("Setting auto-save to: %s" % val)
model.Store.AutoSave = val
# If the user enables auto-save, we want to also save.
if self.AutoSave:
Publisher.sendMessage("user.saved")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:11,代码来源:controller.py
示例13: onSearch
def onSearch(self, event=None):
# Stop any timer that may be active, in the case of a manual search.
self.SearchTimer.Stop()
searchString = self.searchCtrl.Value # For a date, should be YYYY-MM-DD.
matchType = self.matchChoices.index(self.matchBox.Value)
searchInfo = (searchString, matchType)
# Consider a blank search as a search cancellation.
if searchString == "":
self.onCancel()
else:
Publisher.sendMessage("SEARCH.INITIATED", searchInfo)
开发者ID:xuzhen,项目名称:wxbanker,代码行数:12,代码来源:searchctrl.py
示例14: Login
def Login(cls, username, password, notify=True):
if cls.IsLoggedIn():
return
accounts = {}
for account in mintapi.get_accounts(username, password):
account['balance'] = account['value'] # convert to wxBanker speak
accounts[account['accountId']] = account
cls._CachedAccounts = accounts
if notify:
Publisher.sendMessage("mint.updated")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:12,代码来源:api.py
示例15: __init__
def __init__(self, parent, bankController):
GroupListView.__init__(self, parent, style=wx.LC_REPORT|wx.SUNKEN_BORDER, name="TransactionOLV")
self.LastSearch = None
self.CurrentAccount = None
self.BankController = bankController
self.showGroups = False
#WXTODO: figure out these (and the text color, or is that already?) from theme (LP: ???)
self.evenRowsBackColor = wx.Colour(224,238,238)
self.oddRowsBackColor = wx.WHITE
self.cellEditMode = GroupListView.CELLEDIT_DOUBLECLICK
self.SetEmptyListMsg(self.EMPTY_MSG_NORMAL)
# Calculate the necessary width for the date column.
dateStr = str(datetime.date.today())
dateWidth = self.GetTextExtent(dateStr)[0] + 10
# Define some constants to use throughout.
self.COL_DATE = 0
self.COL_DESCRIPTION = 1
self.COL_AMOUNT = 2
self.COL_TOTAL = 3
# If you change these column names, update sizeAmounts()!
self.SetColumns([
ColumnDefn(_("Date"), valueGetter=self.getDateAndIDOf, valueSetter=self.setDateOf, stringConverter=self.renderDateIDTuple, editFormatter=self.renderEditDate, width=dateWidth),
ColumnDefn(_("Description"), valueGetter="Description", isSpaceFilling=True, editFormatter=self.renderEditDescription),
ColumnDefn(_("Amount"), "right", valueGetter=self.getAmount, valueSetter=self.setAmount, stringConverter=self.renderFloat, editFormatter=self.renderEditFloat),
ColumnDefn(_("Balance"), "right", valueGetter=self.getTotal, stringConverter=self.renderFloat, isEditable=False),
])
# Our custom hack in OLV.py:2017 will render amount floats appropriately as %.2f when editing.
# By default, sort by the date column, ascending.
self.SORT_COL = self.COL_DATE
self.SortBy(self.SORT_COL)
self.Bind(wx.EVT_RIGHT_DOWN, self.onRightDown)
self.Subscriptions = (
(self.onSearch, "SEARCH.INITIATED"),
(self.onSearchCancelled, "SEARCH.CANCELLED"),
(self.onSearchMoreToggled, "SEARCH.MORETOGGLED"),
(self.onTransactionAdded, "transaction.created"),
(self.onTransactionsRemoved, "transactions.removed"),
(self.onCurrencyChanged, "currency_changed"),
(self.onShowCurrencyNickToggled, "controller.show_currency_nick_toggled"),
(self.updateTotals, "ormobject.updated.Transaction.Amount"),
(self.onTransactionDateUpdated, "ormobject.updated.Transaction.Date"),
)
for callback, topic in self.Subscriptions:
Publisher.subscribe(callback, topic)
开发者ID:gustavsen,项目名称:wxbanker,代码行数:53,代码来源:transactionolv.py
示例16: __init__
def __init__(self, parent, bankController):
wx.Panel.__init__(self, parent)
self.ID_TIMER = wx.NewId()
self.SearchTimer = wx.Timer(self, self.ID_TIMER)
self.bankController = bankController
self.searchCtrl = bankcontrols.UpdatableSearchCtrl(self, value="", size=(200, -1), style=wx.TE_PROCESS_ENTER)
# Try to grab the GTK system icon for clearing a search, otherwise we'll get the wxPython one.
iconSize = self.searchCtrl.GetClientRect().GetHeight() - 2
clearBitmap = wx.ArtProvider.GetBitmap('edit-clear', wx.ART_OTHER, [iconSize, iconSize])
if clearBitmap:
self.searchCtrl.SetCancelBitmap(clearBitmap)
self.searchCtrl.ShowCancelButton(True)
self.searchCtrl.ShowSearchButton(False)
self.searchCtrl.DescriptiveText = _("Search transactions")
self.searchCtrl.SetForegroundColour('DARK GRAY')
# The More/Less button.
self.moreButton = bankcontrols.MultiStateButton(self, labelDict={True: _("More options"), False: _("Less options")}, state=True)
self.matchChoices = [_("Amount"), _("Description"), _("Date")]
self.descriptionSelection = 1
self.matchBox = bankcontrols.CompactableComboBox(self, value=self.matchChoices[1], choices=self.matchChoices, style=wx.CB_READONLY)
topSizer = wx.BoxSizer()
topSizer.Add(self.searchCtrl, 0, wx.ALIGN_CENTER_VERTICAL)
topSizer.AddSpacer(10)
topSizer.Add(self.moreButton, 0, wx.ALIGN_CENTER_VERTICAL)
self.moreSizer = moreSizer = wx.BoxSizer()
moreSizer.Add(wx.StaticText(self, label=_("Match: ")), 0, wx.ALIGN_CENTER_VERTICAL)
moreSizer.Add(self.matchBox, 0, wx.ALIGN_CENTER_VERTICAL)
self.Sizer = wx.BoxSizer(wx.VERTICAL)
self.Sizer.Add(topSizer, 0, wx.ALIGN_RIGHT|wx.TOP|wx.BOTTOM, 2)
self.Sizer.Add(moreSizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 2)
self.matchBox.Compact()
self.Layout()
self.searchCtrl.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.onCancel)
self.searchCtrl.Bind(wx.EVT_TEXT, self.onText)
#self.searchCtrl.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.onSearch)
self.searchCtrl.Bind(wx.EVT_TEXT_ENTER, self.onSearch)
self.moreButton.Bind(wx.EVT_BUTTON, self.onToggleMore)
# Bindings to search on settings change automatically.
self.matchBox.Bind(wx.EVT_COMBOBOX, self.onSearchTrigger)
self.Bind(wx.EVT_TIMER, self.onSearchTimer)
Publisher.subscribe(self.onExternalSearch, "SEARCH.EXTERNAL")
# Initially hide the extra search options.
self.onToggleMore()
开发者ID:assem-ch,项目名称:wxbanker,代码行数:53,代码来源:searchctrl.py
示例17: onNewTransaction
def onNewTransaction(self, event=None):
# First, ensure an account is selected.
destAccount = self.CurrentAccount
if destAccount is None:
dlg = wx.MessageDialog(self.Parent,
_("Please select an account and then try again."),
_("No account selected"), wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
return
# Grab the transaction values from the control.
result = self.getValues()
if result is None:
# Validation failed, user was informed.
return
amount, desc, date = result
# If a search is active, we have to ask the user what they want to do.
if self.Parent.Parent.searchActive:
msg = _("A search is currently active.") + " " + _('Would you like to clear the current search and make this transaction in "%s"?') % (destAccount.Name)
dlg = wx.MessageDialog(self.Parent, msg, _("Clear search?"), style=wx.YES_NO|wx.ICON_WARNING)
result = dlg.ShowModal()
if result == wx.ID_YES:
Publisher.sendMessage("SEARCH.CANCELLED")
else:
return
sourceAccount = None
# If the transfer box is checked, this is a transfer!
if self.transferCheck.Value:
result = self.Parent.transferRow.GetAccounts(destAccount)
if result is None:
dlg = wx.MessageDialog(self.Parent,
_("This transaction is marked as a transfer. Please select the transfer account."),
_("No account selected"), wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
return
sourceAccount, destAccount = result
# Now let's see if this is a recurring transaction
if self.recursCheck.GetValue():
settings = self.Parent.GetSettings()
args = [amount, desc, date] + list(settings) + [sourceAccount]
destAccount.AddRecurringTransaction(*args)
else:
destAccount.AddTransaction(amount, desc, date, sourceAccount)
# A transaction was added, we can stop flashing if we were.
self.newButton.StopFlashing()
# Reset the controls and focus to their default values.
self.clear()
开发者ID:assem-ch,项目名称:wxbanker,代码行数:52,代码来源:newtransactionctrl.py
示例18: __init__
def __init__(self, bankController, parent, plotSettings=None):
wx.Panel.__init__(self, parent)
baseplot.BasePlot.__init__(self)
self.bankController = bankController
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.data = None
self.x_labels = None
self.plotSettings = plotSettings
# watch if there's any currency change to repaint the plot.
Publisher.subscribe(self.currencyChanged, "controller.show_currency_nick_toggled")
Publisher.subscribe(self.currencyChanged, "currency_changed")
开发者ID:assem-ch,项目名称:wxbanker,代码行数:13,代码来源:cairopanel.py
示例19: __init__
def __init__(self, parent, bankController):
wx.Panel.__init__(self, parent)
self.bankController = bankController
self.mainPanel = managetab.MainPanel(self, bankController)
Publisher.subscribe(self.onRecurringTransactionAdded, "recurringtransaction.created")
Publisher.subscribe(self.onRecurringTransactionUpdated, "recurringtransaction.updated")
self.Sizer = wx.BoxSizer(wx.VERTICAL)
self.Sizer.Add(self.mainPanel, 1, wx.EXPAND)
wx.CallLater(1000, self.CheckRecurringTransactions)
开发者ID:assem-ch,项目名称:wxbanker,代码行数:13,代码来源:main.py
示例20: getTransactionsFrom
def getTransactionsFrom(self, account):
transactions = TransactionList()
# Generate a map of recurring transaction IDs to the objects for fast look-up.
recurringCache = {}
for recurring in account.Parent.GetRecurringTransactions():
recurringCache[recurring.ID] = recurring
Publisher.sendMessage("batch.start")
for result in self.dbconn.cursor().execute('SELECT * FROM transactions WHERE accountId=?', (account.ID,)).fetchall():
t = self.result2transaction(result, account, recurringCache=recurringCache)
transactions.append(t)
Publisher.sendMessage("batch.end")
return transactions
开发者ID:assem-ch,项目名称:wxbanker,代码行数:13,代码来源:persistentstore.py
注:本文中的wxbanker.lib.pubsub.Publisher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论