def OnValid(self,event):
        if self.Validate() and self.TransferDataFromWindow():
            # get fields
            self.m_isin = self.editISIN.GetValue()
            self.m_name = self.editName.GetValue()
            self.m_ticker = self.editTicker.GetValue()
            self.m_market = self.editMarket.GetValue()
            self.m_country = self.dispCountry.GetValue()
            self.m_currency = self.editCurrency.GetValue()
            self.m_place = self.editPlace.GetValue()

            # check isin ?
            if self.qmode == QLIST_ADD:
                # check validity
                if self.m_isin!='':
                    if not checkISIN(self.m_isin):
                        #__xdlg = wx.MessageDialog(self, message('invalid_isin') % self.m_isin, self.tt, wx.OK | wx.ICON_ERROR)
                        #__xidRet = dlg.ShowModal()
                        #__xdlg.Destroy()
                        iTradeError(self, message('invalid_isin') % self.m_isin, self.tt)
                        self.editISIN.SetFocus()
                        return

                # check uniqueness
                ref = quote_reference(self.m_isin,self.m_ticker,self.m_market,self.m_place)
                if quotes.lookupKey(ref):
                    #__xdlg = wx.MessageDialog(self, message('listquote_duplicate_ref') % ref, self.tt, wx.OK | wx.ICON_ERROR)
                    #__xidRet = dlg.ShowModal()
                    #__xdlg.Destroy()
                    iTradeError(self, message('listquote_duplicate_ref') % ref, self.tt)
                    return

            # isin,name,ticker,market,currency,place,country
            self.aRet = (self.m_isin,self.m_name,self.m_ticker,self.m_market,self.m_currency,self.m_place,self.m_country)
            self.EndModal(wx.ID_OK)
    def OnRightClick(self, event):
        if self.m_currentItem<0:
            inList = False
        else:
            debug("OnRightClick %s\n" % self.m_list.GetItemText(self.m_currentItem))
            inList = True

        # only do this part the first time so the events are only bound once
        if not hasattr(self, "m_popupID_Modify"):
            self.m_popupID_Modify = ID_MODIFY
            self.m_popupID_Delete = ID_DELETE
            self.m_popupID_Add = ID_ADD
            wx.EVT_MENU(self, self.m_popupID_Modify, self.OnModify)
            wx.EVT_MENU(self, self.m_popupID_Delete, self.OnDelete)
            wx.EVT_MENU(self, self.m_popupID_Add, self.OnAdd)

        # make a menu
        menu = wx.Menu()
        # add some items
        menu.Append(self.m_popupID_Modify, message('main_popup_edit'))
        menu.Enable(self.m_popupID_Modify,inList)
        menu.Append(self.m_popupID_Delete, message('main_popup_remove'))
        menu.Enable(self.m_popupID_Delete,inList)
        menu.AppendSeparator()
        menu.Append(self.m_popupID_Add, message('main_popup_add'))

        # Popup the menu.  If an item is selected then its handler
        # will be called before PopupMenu returns.
        self.PopupMenu(menu, wx.Point(self.x, self.y))
        menu.Destroy()
 def OnSave(self,event):
     self.m_dirty = False
     quotes.saveListOfQuotes()
     #__xdlg = wx.MessageDialog(self, message('listquote_saved'), message('listquote_save_desc'), wx.OK | wx.OK | wx.ICON_INFORMATION)
     #__xdlg.ShowModal()
     #__xdlg.Destroy()
     iTradeInformation(self, message('listquote_saved'), message('listquote_save_desc'))
    def OnDownload(self,event):
        if self.m_market==None:
            lst = list_of_markets()
            max = len(lst)+1
            keepGoing = True
            x = 0

            dlg = wx.ProgressDialog(message('download_symbols_alllists'),"",max,self,wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            for market in lst:
                if keepGoing:
                    keepGoing = dlg.Update(x,market)
                    fn = getListSymbolConnector(market,QLIST_ANY,QTAG_LIST)
                    if fn:
                        fn(quotes,market,dlg,x)
                    else:
                        print 'ListSymbolConnector for %s not found !' % market
                    x = x + 1
        else:
            x = 0
            dlg = wx.ProgressDialog(message('download_symbols_onelist'),"",2,self,wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            dlg.Update(0,self.m_market)
            fn = getListSymbolConnector(self.m_market,QLIST_ANY,QTAG_LIST)
            if fn:
                fn(quotes,self.m_market,dlg,x)
            else:
                print 'ListSymbolConnector for %s not found !' % self.m_market

        dlg.Update(x,message('save'))
        self.m_dirty = True
        if dlg:
            dlg.Destroy()
        self.PopulateList()
    def OnImport(self,event):
        dlg = wx.FileDialog(self.m_parent, message('import_from_file'), itrade_config.dirImport, "", "*.txt", wx.OPEN|wx.FILE_MUST_EXIST)
        if dlg.ShowModal() == wx.ID_OK:
            dirname  = dlg.GetDirectory()
            filename = dlg.GetFilename()
            file = os.path.join(dirname,filename)

            if itrade_config.verbose:
                print 'Import file %s for quote %s' % (file,self.m_quote.key())

            # clear everything
            self.m_quote.flushTrades()

            # import the file
            self.m_quote.loadTrades(file)
            self.m_quote.saveTrades()

            # be sure indicators have been updated
            self.m_quote.compute()

            iTradeInformation(self, message('imported_from_file') % file, message('import_from_file'))

            dlg.Destroy()
            dlg = None

            # force a refresh on the root window
            if self.m_wincb:
                self.m_wincb.OnRefresh()

        if dlg: dlg.Destroy()
    def refresh(self):
        self.m_list.ClearAll()
        self.m_list.InsertColumn(IDC_DATE, message('date'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_TYPE, message('type'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_SOURCE, message('source'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_ISIN, message('isin'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_TITLE, message('title'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)

        x = 0
        for eachAlert in alerts.listAlerts():
            self.m_list.InsertImageStringItem(x, "%s" % eachAlert.date(), self.idx_tbref)
            self.m_list.SetStringItem(x,IDC_TYPE,eachAlert.type_desc())
            self.m_list.SetStringItem(x,IDC_SOURCE,eachAlert.source())
            self.m_list.SetStringItem(x,IDC_ISIN,eachAlert.isin())
            self.m_list.SetStringItem(x,IDC_TITLE,eachAlert.title())

            x = x + 1

        # adjust columns
        self.m_list.SetColumnWidth(IDC_DATE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_TYPE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_SOURCE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_ISIN, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_TITLE, wx.LIST_AUTOSIZE)

        # default selection
        if x>0:
            self.m_currentItem = 0
            self.m_list.SetItemState(0, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
            self.m_list.EnsureVisible(self.m_currentItem)
        else:
            self.m_currentItem = -1
    def _init_toolbar(self):
        self._NTB2_EXIT = wx.NewId()

        self._NTB2_DISPALL = wx.NewId()
        self._NTB2_DISPQUOTES = wx.NewId()
        self._NTB2_DISPCASH = wx.NewId()
        self._NTB2_DISPPVAL = wx.NewId()
        self._NTB2_DISPSRD = wx.NewId()

        self._NTB2_ADD = wx.NewId()
        self._NTB2_MODIFY = wx.NewId()
        self._NTB2_DELETE = wx.NewId()

        self._NTB2_30DAYS = wx.NewId()
        self._NTB2_90DAYS = wx.NewId()
        self._NTB2_CURRENTYEAR = wx.NewId()
        self._NTB2_ALLYEARS = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24,24))
        self.AddSimpleTool(self._NTB2_EXIT, wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
                           message('main_close'), message('main_desc_close'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))

        self.AddRadioLabelTool(self._NTB2_DISPALL,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'dispall.png')),wx.NullBitmap,message('portfolio_dispall'),message('portfolio_desc_dispall'))
        self.AddRadioLabelTool(self._NTB2_DISPQUOTES,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'dispquote.png')),wx.NullBitmap,message('portfolio_dispquotes'),message('portfolio_desc_dispquotes'))
        self.AddRadioLabelTool(self._NTB2_DISPCASH,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'dispcash.png')),wx.NullBitmap,message('portfolio_dispcash'),message('portfolio_desc_dispcash'))
        self.AddRadioLabelTool(self._NTB2_DISPPVAL,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'dispvalue.png')),wx.NullBitmap,message('portfolio_dispvalues'),message('portfolio_desc_dispvalues'))
        self.AddRadioLabelTool(self._NTB2_DISPSRD,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'dispsrd.png')),wx.NullBitmap,message('portfolio_dispsrd'),message('portfolio_desc_dispsrd'))

        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))

        self.AddSimpleTool(self._NTB2_ADD,wx.Bitmap(os.path.join(itrade_config.dirRes, 'add.png')),message('portfolio_opadd'),message('portfolio_desc_opadd'))
        self.AddSimpleTool(self._NTB2_MODIFY,wx.Bitmap(os.path.join(itrade_config.dirRes, 'modify.png')),message('portfolio_opmodify'),message('portfolio_desc_opmodify'))
        self.AddSimpleTool(self._NTB2_DELETE,wx.Bitmap(os.path.join(itrade_config.dirRes, 'delete.png')),message('portfolio_opdelete'),message('portfolio_desc_opdelete'))

        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))

        self.AddRadioLabelTool(self._NTB2_30DAYS,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'filter30.png')),wx.NullBitmap,message('portfolio_per30days'),message('portfolio_desc_per30days'))
        self.AddRadioLabelTool(self._NTB2_90DAYS,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'filter90.png')),wx.NullBitmap,message('portfolio_per90days'),message('portfolio_desc_per90days'))
        self.AddRadioLabelTool(self._NTB2_CURRENTYEAR,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'filter.png')),wx.NullBitmap,message('portfolio_peryear'),message('portfolio_desc_peryear'))
        self.AddRadioLabelTool(self._NTB2_ALLYEARS,'',wx.Bitmap(os.path.join(itrade_config.dirRes, 'nofilter.png')),wx.NullBitmap,message('portfolio_perall'),message('portfolio_desc_perall'))

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.onExit)

        wx.EVT_TOOL(self, self._NTB2_DISPALL, self.onDispAll)
        wx.EVT_TOOL(self, self._NTB2_DISPQUOTES, self.onDispQuotes)
        wx.EVT_TOOL(self, self._NTB2_DISPCASH, self.onDispCash)
        wx.EVT_TOOL(self, self._NTB2_DISPPVAL, self.onDispPVal)
        wx.EVT_TOOL(self, self._NTB2_DISPSRD, self.onDispSRD)

        wx.EVT_TOOL(self, self._NTB2_MODIFY, self.onModify)
        wx.EVT_TOOL(self, self._NTB2_DELETE, self.onDelete)
        wx.EVT_TOOL(self, self._NTB2_ADD, self.onAdd)

        wx.EVT_TOOL(self, self._NTB2_30DAYS, self.on30Days)
        wx.EVT_TOOL(self, self._NTB2_90DAYS, self.on90Days)
        wx.EVT_TOOL(self, self._NTB2_CURRENTYEAR, self.onCurrentYear)
        wx.EVT_TOOL(self, self._NTB2_ALLYEARS, self.onAllYears)

        self.Realize()
 def ClearIndicator(self):
     if itrade_config.bAutoRefreshMatrixView:
         label = " " + message('indicator_autorefresh')
     else:
         label = " " + message('indicator_noautorefresh')
     self.m_indicator.SetBackgroundColour(wx.NullColour)
     #self.m_indicator.ClearBackground()
     self.m_indicator.ChangeValue(label)
    def init(self):
        self.win = {}
        self.DeleteAllPages()

        self.win[self.ID_PAGE_ALERTS] = iTradeAlertsPanel(self,wx.NewId(),self.m_port)
        self.AddPage(self.win[self.ID_PAGE_ALERTS], message('alerts_alerts'))

        self.win[self.ID_PAGE_NEWS] = iTradeNewsPanel(self,wx.NewId(),self.m_port)
        self.AddPage(self.win[self.ID_PAGE_NEWS], message('alerts_news'))
Example #10
0
 def OnRemoveCurrentQuote(self,e):
     quote = self.currentQuote()
     # ask a confirmation
     idRet = iTradeYesNo(self, message('remove_quote_info') % quote.name(), message('remove_quote_title'))
     if idRet == wx.ID_YES:
         if removeFromMatrix_iTradeQuote(self,self.m_matrix,quote):
             print 'OnRemoveCurrentQuote:',quote
             self.m_portfolio.setupCurrencies()
             self.RebuildList()
Example #11
0
def removeStops_iTradeQuote(win,quote):
    if not isinstance(quote,Quote):
        quote = quotes.lookupKey(quote)
    if quote:
        if quote.hasStops():
            iRet = iTradeYesNo(win,message('stops_remove_text')%quote.name(),message('stops_remove_caption'))
            if iRet==wx.ID_YES:
                quotes.removeStops(quote.key())
                return True
    return False
Example #12
0
 def OnTest(self,event):
     u = self.wxUsernameCtrl.GetValue().strip()
     p = self.wxPasswordCtrl.GetValue().strip()
     ret = self.m_connector.login(u,p)
     self.m_connector.logout()
     if ret:
         #__xdlg = wx.MessageDialog(self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION)
         iTradeInformation(self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name())
     else:
         #__xdlg = wx.MessageDialog(self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION)
         iTradeError(self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name())
    def PopulateList(self,bDuringInit=False):
        wx.SetCursor(wx.HOURGLASS_CURSOR)

        # clear list
        self.m_list.ClearAll()
        self.currentItem = -1

        # but since we want images on the column header we have to do it the hard way:
        self.m_list.InsertColumn(IDC_ISIN, message('isin'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_TICKER, message('ticker'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_NAME, message('name'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_PLACE, message('place'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_MARKET, message('market'), wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)

        x = 0

        self.itemDataMap = {}
        self.itemQuoteMap = {}
        self.itemLineMap = {}

        for eachQuote in quotes.list():
            if (not self.m_filter or eachQuote.isMatrix()) and self.isFiltered(eachQuote,bDuringInit):
                self.itemDataMap[x] = (eachQuote.isin(),eachQuote.ticker(),eachQuote.name(),eachQuote.place(),eachQuote.market())
                self.itemQuoteMap[x] = eachQuote
                x = x + 1

        items = self.itemDataMap.items()
        line = 0
        curline = -1
        for x in range(len(items)):
            key, data = items[x]
            if data[0]!='':
                self.m_list.InsertImageStringItem(line, data[0], self.sm_q)
            else:
                self.m_list.InsertImageStringItem(line, data[0], self.sm_i)
            if data[0] == self.m_isin and data[1]== self.m_ticker and data[3] == self.m_place and data[4] == self.m_market:
                # current selection
                curline = line
            self.m_list.SetStringItem(line, IDC_TICKER, data[1])
            self.m_list.SetStringItem(line, IDC_NAME, data[2])
            self.m_list.SetStringItem(line, IDC_PLACE, data[3])
            self.m_list.SetStringItem(line, IDC_MARKET, data[4])
            self.m_list.SetItemData(line, key)
            self.itemLineMap[data[1]] = line
            line += 1

        self.m_list.SetColumnWidth(IDC_ISIN, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_TICKER, wx.LIST_AUTOSIZE_USEHEADER)
        self.m_list.SetColumnWidth(IDC_NAME, 16*10)
        self.m_list.SetColumnWidth(IDC_PLACE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_MARKET, wx.LIST_AUTOSIZE)
        self.SetCurrentItem(curline)

        wx.SetCursor(wx.STANDARD_CURSOR)
    def __init__(self, parent,id,title):
        self.m_id = wx.NewId()
        wx.Frame.__init__(self,None,self.m_id, title, size = (640,480), style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
        iTrade_wxFrame.__init__(self,parent,'currencies')
        iTrade_wxLiveCurrencyMixin.__init__(self)

        # the menu
        self.filemenu = wx.Menu()
        #self.filemenu.Append(ID_SAVE,message('main_save'),message('main_desc_save'))
        #self.filemenu.AppendSeparator()
        self.filemenu.Append(ID_CLOSE,message('main_close'),message('main_desc_close'))

        self.viewmenu = wx.Menu()
        self.viewmenu.Append(ID_CONVERT, message('main_view_convert'),message('main_view_desc_convert'))
        self.viewmenu.Append(ID_REFRESH, message('main_view_refresh'),message('main_view_desc_refresh'))
        self.viewmenu.AppendCheckItem(ID_AUTOREFRESH, message('main_view_autorefresh'),message('main_view_desc_autorefresh'))

        # default checking
        self.updateCheckItems()

        # Creating the menubar
        menuBar = wx.MenuBar()

        # Adding the "<x>menu" to the MenuBar
        menuBar.Append(self.filemenu,message('currency_menu_file'))
        menuBar.Append(self.viewmenu,message('currency_menu_view'))

        # Adding the MenuBar to the Frame content
        self.SetMenuBar(menuBar)

        # Toolbar
        self.m_toolbar = iTradeCurrencyToolbar(self, wx.NewId())

        # default list is quotes
        self.m_list = iTradeCurrenciesMatrix(self, wx.NewId(),
                                 style = wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.LC_HRULES,
                                 list=list_of_currencies())
        #self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL)
        self.m_list.SetFont(wx.Font(10, wx.SWISS , wx.NORMAL, wx.NORMAL))

        wx.EVT_SIZE(self, self.OnSize)

        wx.EVT_MENU(self, ID_CLOSE, self.OnClose)
        wx.EVT_MENU(self, ID_CONVERT, self.OnConvert)
        wx.EVT_MENU(self, ID_REFRESH, self.OnRefresh)
        wx.EVT_MENU(self, ID_AUTOREFRESH, self.OnAutoRefresh)

        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
        wx.EVT_CLOSE(self, self.OnCloseWindow)

        EVT_UPDATE_LIVECURRENCY(self, self.OnLiveCurrency)

        # refresh full view after window init finished
        EVT_POSTINIT(self, self.OnPostInit)
        wx.PostEvent(self,PostInitEvent())

        self.Show(True)
    def _init_toolbar(self):
        self._NTB2_EXIT = wx.NewId()
        self._NTB2_SELECT = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24,24))
        self.AddSimpleTool(self._NTB2_EXIT, wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
                           message('main_close'), message('main_desc_close'))
        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_SELECT, wx.Bitmap(os.path.join(itrade_config.dirRes, 'quotes.png')),
                           message('quote_select_title'), message('quote_select_title'))

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.exit)
        wx.EVT_TOOL(self, self._NTB2_SELECT, self.select)
        self.Realize()
Example #16
0
def resolve_wxversion():
    patt = "%d\.%d[0-9\-\.A-Za-z]*-unicode"
    patts = "-unicode"

    versions = wxversion.getInstalled()
    if verbose:
        print 'wxPython Installed :',versions

    # need to select the more recent one with 'unicode'
    vSelected = None
    vSelectedMsg = ''
    for eachVersion in versions:
        for min in range(WXVERSION_MINOR1,WXVERSION_MINOR2+1):
            m = re.search( patt % (WXVERSION_MAJOR,min), eachVersion)
            if m:
                if min == WXVERSION_MINOR2:
                    vSelectedMsg = ''
                else:
                    vSelectedMsg = ' (deprecated version - think to update)'
                vSelected = eachVersion
                break
        if m:
            break

    if vSelected:
        print 'wxPython Selected  :',vSelected,vSelectedMsg
        wxversion.select(vSelected)
        return

    # no compatible version :-( : try to select any release
    bUnicode = False
    for eachVersion in versions:
        m = re.search(patts, eachVersion)
        if m:
            print 'wxPython Selected  :',eachVersion
            wxversion.select(eachVersion)
            bUnicode = True
            break

    if not bUnicode:
        # only ansi release :-( => use US lang
        setLang('us')

    import sys, wx, webbrowser
    app = wx.PySimpleApp()
    wx.MessageBox(message('wxversion_msg') % (WXVERSION_MAJOR,WXVERSION_MINOR2), message('wxversion_title'))
    app.MainLoop()
    webbrowser.open("http://wxpython.org/")
    sys.exit()
    def init(self):
        self.win = {}
        self.DeleteAllPages()

        self.win[self.ID_PAGE_EVALUATION] = iTradeEvaluationPanel(self,wx.NewId(),self.m_port)
        self.AddPage(self.win[self.ID_PAGE_EVALUATION], message('money_evaluation'))

        self.win[self.ID_PAGE_COMPUTE] = iTradeComputePanel(self,wx.NewId(),self.m_quote)
        self.AddPage(self.win[self.ID_PAGE_COMPUTE], message('money_compute'))

        self.win[self.ID_PAGE_EVALCHART] = iTradeEvaluationChartPanel(self,wx.NewId(),self.m_port)
        self.AddPage(self.win[self.ID_PAGE_EVALCHART], message('money_evaluationchart'))

        self.win[self.ID_PAGE_MONEY] = iTradeMoneyPanel(self,wx.NewId(),self.m_port)
        self.AddPage(self.win[self.ID_PAGE_MONEY], message('money_money'))
    def OnExport(self,event):
        dlg = wx.FileDialog(self.m_parent, message('export_to_file'), itrade_config.dirExport, "", "*.txt", wx.SAVE|wx.OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            dirname  = dlg.GetDirectory()
            filename = dlg.GetFilename()
            file = os.path.join(dirname,filename)
            if itrade_config.verbose:
                print 'Export file %s for quote %s' % (file,self.m_quote.key())

            self.m_quote.saveTrades(file)

            iTradeInformation(self,message('exported_to_file') % file, message('export_to_file'))

            #
        dlg.Destroy()
    def _init_toolbar(self):
        self._NTB2_EXIT = wx.NewId()
        self._NTB2_REFRESH = wx.NewId()

        self.SetToolBitmapSize(wx.Size(24,24))
        self.AddSimpleTool(self._NTB2_EXIT, wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR),
                           message('main_close'), message('main_desc_close'))

        self.AddControl(wx.StaticLine(self, -1, size=(-1,23), style=wx.LI_VERTICAL))
        self.AddSimpleTool(self._NTB2_REFRESH, wx.Bitmap(os.path.join(itrade_config.dirRes, 'refresh.png')),
                           message('main_view_refresh'), message('main_view_desc_refresh'))

        wx.EVT_TOOL(self, self._NTB2_EXIT, self.onExit)
        wx.EVT_TOOL(self, self._NTB2_REFRESH, self.onRefresh)
        self.Realize()
    def PopulateList(self):
        self.m_list.ClearAll()

        # but since we want images on the column header we have to do it the hard way:
        info = wx.ListItem()
        info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT
        info.m_image = -1
        info.m_format = wx.LIST_FORMAT_LEFT
        info.m_text = message('portfolio_list_filename')
        self.m_list.InsertColumnInfo(0, info)

        info.m_format = wx.LIST_FORMAT_LEFT
        info.m_text = message('portfolio_list_name')
        self.m_list.InsertColumnInfo(1, info)

        info.m_format = wx.LIST_FORMAT_LEFT
        info.m_text = message('portfolio_list_accountref')
        self.m_list.InsertColumnInfo(2, info)

        x = 0
        self.currentItem = -1

        self.itemDataMap = {}
        for eachPortfolio in portfolios.list():
            if self.m_except<>eachPortfolio.filename():
                self.itemDataMap[x] = (eachPortfolio.filename(),eachPortfolio.name(),eachPortfolio.accountref())
                x = x + 1

        items = self.itemDataMap.items()
        for x in range(len(items)):
            key, data = items[x]
            if data[0]!='':
                self.m_list.InsertImageStringItem(x, data[0], self.sm_q)
            else:
                self.m_list.InsertImageStringItem(x, data[0], self.sm_i)
            if data[0] == self.m_name:  # current selection
                self.currentItem = x
            self.m_list.SetStringItem(x, 1, data[1])
            self.m_list.SetStringItem(x, 2, data[2])
            self.m_list.SetItemData(x, key)

        self.m_list.SetColumnWidth(0, wx.LIST_AUTOSIZE_USEHEADER)
        self.m_list.SetColumnWidth(1, wx.LIST_AUTOSIZE_USEHEADER)
        self.m_list.SetColumnWidth(2, wx.LIST_AUTOSIZE_USEHEADER)

        if self.currentItem>=0:
            self.m_list.SetItemState(self.currentItem, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
            self.m_list.EnsureVisible(self.currentItem)
Example #21
0
def iTradeInformation(parent,text,caption=message('info_caption')):
    #dlg = HTMLDialog(parent=parent,caption=caption,text=text,buttons=OKButton(makedefault=1),image="box_info.png")
    dlg = iTradeDialog(parent=parent,caption=caption,text=text,style=wx.OK|wx.ICON_INFORMATION)
    idRet = dlg.CentreOnParent()
    idRet = dlg.ShowModal()
    dlg.Destroy()
    return idRet
Example #22
0
def iTradeError(parent,text,caption=message('alert_caption')):
    #dlg = HTMLDialog(parent=parent,caption=caption,text=text,buttons=OKButton(makedefault=1),image="box_alert.png")
    dlg = iTradeDialog(parent=parent,caption=caption,text=text,style=wx.OK|wx.ICON_ERROR)
    idRet = dlg.CentreOnParent()
    idRet = dlg.ShowModal()
    dlg.Destroy()
    return idRet
Example #23
0
 def gotoInternetUrl(self, url):
     try:
         import webbrowser
     except ImportError:
         iTradeInformation(message('about_url') % url)
     else:
         webbrowser.open(url)
Example #24
0
    def stopLiveCurrency(self,key=None,bBusy=False):
        if key:
            # stop live only for one currency
            if self.m_threads.has_key(key):
                #if itrade_config.verbose:
                #    print 'stopLive Currency : %s' % key
                t = self.m_threads[key]
                if t.IsRunning():
                    t.Stop()
            else:
                if itrade_config.verbose:
                    print 'stopLive Currency : %s UNKNOWN KEY' % key
        else:
            #if itrade_config.verbose:
            #    print 'stopLive Currency : %d threads ---[' % len(self.m_threads.values())

            if len(self.m_threads.values()):
                # stop live for all registered currencies
                if bBusy:
                    busy = wx.BusyInfo(message('live_busy'))
                    wx.Yield()

                for t in self.m_threads.values():
                    if t.IsRunning():
                        t.Stop()

                if bBusy:
                    running = 1
                    while running:
                        running = 0

                        for t in self.m_threads.values():
                            running = running + t.IsRunning()

                        time.sleep(0.1)
Example #25
0
 def gotoInternetUrl(self, url):
     try:
         import webbrowser
     except ImportError:
         wx.MessageBox(message('about_url') % url)
     else:
         webbrowser.open(url)
Example #26
0
    def __init__(self, prnt):
        wx.Dialog.__init__(self, size=wx.Size(480, 525), pos=(-1, -1),
              id = wxID_ABOUTBOX, title = message('about_title'), parent=prnt,
              name = 'AboutBox', style = wx.DEFAULT_DIALOG_STYLE)

        self.blackback = wx.Window(self, -1, pos=(0, 0),
              size=self.GetClientSize(), style=wx.CLIP_CHILDREN)
        self.blackback.SetBackgroundColour(wx.BLACK)

        self.m_html = wxUrlClickHtmlWindow(self.blackback, -1, style = wx.CLIP_CHILDREN | wx.html.HW_NO_SELECTION)
        EVT_HTML_URL_CLICK(self.m_html, self.OnLinkClick)

        self.setPage()
        self.blackback.SetAutoLayout(True)

        # adjust constraints
        lc = wx.LayoutConstraints()
        lc.top.SameAs(self.blackback, wx.Top, self.border)
        lc.left.SameAs(self.blackback, wx.Left, self.border)
        lc.bottom.SameAs(self.blackback, wx.Bottom, self.border)
        lc.right.SameAs(self.blackback, wx.Right, self.border)
        self.m_html.SetConstraints(lc)

        # layout everything
        self.blackback.Layout()
        self.Center(wx.BOTH)

        #
        self.SetAcceleratorTable(wx.AcceleratorTable([(0, wx.WXK_ESCAPE, wx.ID_OK)]))
Example #27
0
    def SetIndicator(self,market,connector,indice):
        clock = connector.currentClock(indice)
        if clock=="::":
            label = " " + indice.market() + ": " + message('indicator_disconnected')
            self.m_indicator.SetBackgroundColour(cDISCONNECTED)
        else:
            label = " " + indice.market() + "- " + clock
            if indice:
                label = label + " - " + indice.name() + ": "+ indice.sv_close()+ " (" + indice.sv_percent()+ " )"
            if label==self.m_indicator.GetValue():
                self.m_indicator.SetBackgroundColour(cCONNECTED)
            else:
                self.m_indicator.SetBackgroundColour(cCONNECTED_I)
        #self.m_indicator.ClearBackground()
        self.m_indicator.ChangeValue(label)
	# get indicator and toolbar positions and sizes
	indicatorposition = self.m_indicator.GetScreenPosition()
	indicatorsize = self.m_indicator.GetClientSize()
	toolbarposition = self.GetScreenPosition()
	toolbarsize = self.GetClientSize()
	# compute width... minus 2 because it only works that way with gtk 2.6
	computedwidth = toolbarsize.width + toolbarposition.x - indicatorposition.x - 2
	if indicatorsize.width != computedwidth:
	    indicatorsize.SetWidth(computedwidth)
	    self.m_indicator.SetSize(indicatorsize)
    def OnImport(self,event):
        dlg = wx.FileDialog(self.m_parent, message('import_from_file'), itrade_config.dirImport, "", "*.txt", wx.OPEN|wx.FILE_MUST_EXIST)
        if dlg.ShowModal() == wx.ID_OK:
            dirname  = dlg.GetDirectory()
            filename = dlg.GetFilename()
            file = os.path.join(dirname,filename)

            info('Import file %s' % file)
            self.m_quote.loadTrades(file)
            self.m_quote.saveTrades()

            # __xdlg2 = wx.MessageDialog(self, message('imported_from_file') % file, message('import_from_file'), wx.OK | wx.ICON_INFORMATION)
            # __xdlg2.ShowModal()
            # __xdlg2.Destroy()
            iTradeInformation(self, message('imported_from_file') % file, message('import_from_file'))

        dlg.Destroy()
 def OnClear(self,event):
     if self.m_market==None:
         market = message('all_markets')
         txt = message('clear_symbols_alldesc')
     else:
         market = self.m_market
         txt = message('clear_symbols_onedesc')
     #__xdlg = wx.MessageDialog(self, message('listquote_clear_confirm')%(market,txt), message('listquote_clear_confirm_title'), wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
     #__xidRet = dlg.ShowModal()
     #__xdlg.Destroy()
     idRet = iTradeYesNo(self, message('listquote_clear_confirm')%(market,txt), message('listquote_clear_confirm_title'))
     if idRet == wx.ID_YES:
         wx.SetCursor(wx.HOURGLASS_CURSOR)
         quotes.removeQuotes(self.m_market,self.m_qlist)
         self.m_dirty = True
         self.PopulateList()
     else: return
    def OnExport(self,event):
        dlg = wx.FileDialog(self.m_parent, message('export_to_file'), itrade_config.dirExport, "", "*.txt", wx.SAVE|wx.OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            dirname  = dlg.GetDirectory()
            filename = dlg.GetFilename()
            file = os.path.join(dirname,filename)
            info('Export file %s' % file)

            self.m_quote.saveTrades(file)

            #__xdlg2 = wx.MessageDialog(self, message('exported_to_file') % file, message('export_to_file'), wx.OK | wx.ICON_INFORMATION)
            #__xdlg2.ShowModal()
            #__xdlg2.Destroy()
            iTradeInformation(self,message('exported_to_file') % file, message('export_to_file'))

            #
        dlg.Destroy()
    def goto(self,html,url):
        if html:
            html.paint0()
        info('goto %s',url)

        buf = self.getdata(url)
        #print buf

        if not buf:
            if html:
                html.paint_NC()
            else:
                print 'unable to connect'
            return

        title = re.search('<tr>[ \t\n\r]+<td.*</font></td>[ \t\n\r]+</tr>',buf,re.IGNORECASE|re.MULTILINE|re.DOTALL)
        if title:
            title = title.group()
        else:
            title = ''

        buf = re.search('<tr>[ \t\n\r]*<td>.*</table>',buf,re.IGNORECASE|re.MULTILINE|re.DOTALL)
        if buf:
            buf = buf.group()[:-8]
            #print '----------------('
            #print buf
            #print ')----------------'
            page = '<html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body>' + "<br><a href=':back'>%s</a><H3>" % message('backtolist') + title + "</H3>" + buf + "<br><br><a href=':back'>%s</a>" % message('backtolist')  + "</body></html>"

            if html:
                html.SetPageWithoutCache(page)
            else:
                print page
        else:
            if html:
                html.paint_NC()
            else:
                print 'empty'
Example #32
0
    def __init__(self, parent, portfolio, operation):
        iTradeSizedDialog.__init__(self,
                                   None,
                                   -1,
                                   message('portfolio_properties_%s' %
                                           operation),
                                   style=wx.DEFAULT_DIALOG_STYLE,
                                   size=(420, 420))

        if portfolio:
            self.m_filename = portfolio.filename()
            self.m_name = portfolio.name()
            self.m_accountref = portfolio.accountref()
            self.m_market = portfolio.market()
            self.m_currency = portfolio.currency()
            self.m_vat = portfolio.vat()
            self.m_term = portfolio.term()
            self.m_risk = portfolio.risk()
            self.m_indice = portfolio.indice()
        else:
            self.m_filename = 'noname'
            self.m_name = ''
            self.m_accountref = ''
            self.m_market = 'EURONEXT'
            self.m_currency = 'EUR'
            self.m_vat = 1.196
            self.m_term = 3
            self.m_risk = 5
            self.m_indice = getDefaultIndice(self.m_market)
        self.m_operation = operation

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # row1 : filename
        label = wx.StaticText(pane, -1, message('portfolio_filename'))
        label.SetSizerProps(valign='center')
        self.wxFilenameCtrl = wx.TextCtrl(pane,
                                          -1,
                                          self.m_filename,
                                          size=(120, -1))
        self.wxFilenameCtrl.SetSizerProps(expand=True)

        # row2 : name
        label = wx.StaticText(pane, -1, message('portfolio_name'))
        label.SetSizerProps(valign='center')
        self.wxNameCtrl = wx.TextCtrl(pane, -1, self.m_name, size=(180, -1))
        self.wxNameCtrl.SetSizerProps(expand=True)

        # row3 : accountref
        label = wx.StaticText(pane, -1, message('portfolio_accountref'))
        label.SetSizerProps(valign='center')

        self.wxAccountRefCtrl = wx.TextCtrl(pane,
                                            -1,
                                            self.m_accountref,
                                            size=(80, -1))
        self.wxAccountRefCtrl.SetSizerProps(expand=True)

        # row4 : market
        label = wx.StaticText(pane, -1, message('portfolio_market'))
        label.SetSizerProps(valign='center')

        self.wxMarketCtrl = wx.ComboBox(pane,
                                        -1,
                                        "",
                                        size=wx.Size(160, -1),
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket)

        count = 0
        for eachCtrl in list_of_markets():
            self.wxMarketCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_market:
                idx = count
            count = count + 1

        self.wxMarketCtrl.SetSelection(idx)

        # row5 : main indice
        label = wx.StaticText(pane, -1, message('portfolio_indicator'))
        label.SetSizerProps(valign='center')

        self.wxIndicatorCtrl = wx.ComboBox(pane,
                                           -1,
                                           "",
                                           size=wx.Size(160, -1),
                                           style=wx.CB_DROPDOWN
                                           | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxIndicatorCtrl.GetId(), self.OnIndicator)

        count = 0
        for eachCtrl in quotes.list():
            if eachCtrl.list() == QLIST_INDICES:
                #self.wxIndicatorCtrl.Append(eachCtrl.name(),eachCtrl.isin())
                try:
                    self.wxIndicatorCtrl.Append(eachCtrl.name(),
                                                eachCtrl.isin())
                except:
                    print 'eachCtrl:', eachCtrl
                if eachCtrl.isin() == self.m_indice:
                    idx = count
                count = count + 1

        self.wxIndicatorCtrl.SetSelection(idx)

        # row6 : currency
        label = wx.StaticText(pane, -1, message('portfolio_currency'))
        label.SetSizerProps(valign='center')

        self.wxCurrencyCtrl = wx.ComboBox(pane,
                                          -1,
                                          "",
                                          size=wx.Size(80, -1),
                                          style=wx.CB_DROPDOWN
                                          | wx.CB_READONLY)
        wx.EVT_COMBOBOX(self, self.wxCurrencyCtrl.GetId(), self.OnCurrency)

        count = 0
        for eachCtrl in list_of_currencies():
            #print eachCtrl
            self.wxCurrencyCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_currency:
                idx = count
            count = count + 1

        self.wxCurrencyCtrl.SetSelection(idx)

        # row7 : default vat
        label = wx.StaticText(pane, -1, message('portfolio_vat'))
        label.SetSizerProps(valign='center')

        self.wxVATCtrl = masked.Ctrl(pane,
                                     integerWidth=5,
                                     fractionWidth=3,
                                     controlType=masked.controlTypes.NUMBER,
                                     allowNegative=False,
                                     groupChar=getGroupChar(),
                                     decimalChar=getDecimalChar())
        self.wxVATCtrl.SetValue((self.m_vat - 1) * 100)

        # Row8 : trading style
        label = wx.StaticText(container, -1, message('prop_tradingstyle'))

        btnpane = sc.SizedPanel(container,
                                -1,
                                style=wx.RAISED_BORDER | wx.CAPTION
                                | wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN
                                | wx.NO_FULL_REPAINT_ON_RESIZE)
        btnpane.SetSizerType("form")
        btnpane.SetSizerProps(expand=True)

        label = wx.StaticText(btnpane, -1, message('prop_term'))
        label.SetSizerProps(valign='center')

        self.wxTermCtrl = masked.Ctrl(btnpane,
                                      integerWidth=3,
                                      fractionWidth=0,
                                      controlType=masked.controlTypes.NUMBER,
                                      allowNegative=False,
                                      groupChar=getGroupChar(),
                                      decimalChar=getDecimalChar())
        self.wxTermCtrl.SetValue(self.m_term)

        label = wx.StaticText(btnpane, -1, message('prop_risk'))
        label.SetSizerProps(valign='center')

        self.wxRiskCtrl = masked.Ctrl(btnpane,
                                      integerWidth=3,
                                      fractionWidth=0,
                                      controlType=masked.controlTypes.NUMBER,
                                      allowNegative=False,
                                      groupChar=getGroupChar(),
                                      decimalChar=getDecimalChar())
        self.wxRiskCtrl.SetValue(self.m_risk)

        # row 9 : separator
        line = wx.StaticLine(container,
                             -1,
                             size=(20, -1),
                             style=wx.LI_HORIZONTAL)
        line.SetSizerProps(expand=True)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        if operation == 'create':
            msg = message('portfolio_properties_btncreate')
            msgdesc = message('portfolio_properties_btncreatedesc')
            fnt = self.OnValid
        elif operation == 'delete':
            msg = message('portfolio_properties_btndelete')
            msgdesc = message('portfolio_properties_btndeletedesc')
            fnt = self.OnValid
        elif operation == 'edit':
            msg = message('portfolio_properties_btnedit')
            msgdesc = message('portfolio_properties_btneditdesc')
            fnt = self.OnValid
        elif operation == 'rename':
            msg = message('portfolio_properties_btnrename')
            msgdesc = message('portfolio_properties_btnrenamedesc')
            fnt = self.OnValid
        else:
            msg = message('valid')
            msgdesc = message('valid_desc')
            fnt = self.OnValid

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, msg)
        btn.SetDefault()
        btn.SetHelpText(msgdesc)
        wx.EVT_BUTTON(self, wx.ID_OK, fnt)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # enable some fields based on the operation
        if operation == 'edit':
            # edit: filename, market and currency can't be changed
            self.wxFilenameCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            #self.wxNameCtrl.SetFocus()
        elif operation == 'delete':
            # display only
            self.wxFilenameCtrl.Enable(False)
            self.wxNameCtrl.Enable(False)
            self.wxAccountRefCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            self.wxVATCtrl.Enable(False)
            self.wxTermCtrl.Enable(False)
            self.wxRiskCtrl.Enable(False)
            self.wxIndicatorCtrl.Enable(False)
            #self.btn.SetFocus()
        elif operation == 'rename':
            # filename only
            self.wxNameCtrl.Enable(False)
            self.wxAccountRefCtrl.Enable(False)
            self.wxMarketCtrl.Enable(False)
            self.wxCurrencyCtrl.Enable(False)
            self.wxVATCtrl.Enable(False)
            self.wxTermCtrl.Enable(False)
            self.wxRiskCtrl.Enable(False)
            self.wxIndicatorCtrl.Enable(False)
            #self.btn.SetFocus()
        else:
            # everything is editable
            pass

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
 def desc(self):
     return message('login_boursorama_desc')
Example #34
0
    def refresh(self):
        self.m_port.computeOperations()
        # __x localisation + better look + previous year information + ...
        # __x hopefully for next release :-)
        self.m_html.SetPage('<html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body>')
        self.m_html.AppendToPage('<table border="1" cellpadding="2" cellspacing="1" class="bright">')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap><b>%s</b></td>' % message('money_portfolio'))
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % self.m_port.filename())
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_description'))
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % self.m_port.name())
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_account_number'))
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % self.m_port.accountref())
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage('</table>')
        self.m_html.AppendToPage('<br><br>')
        self.m_html.AppendToPage('<table border="1" cellpadding="2" cellspacing="1" width="100%" class="bright">')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap></td>')
        self.m_html.AppendToPage('   <td align="right" ><b>%s</b></td>' % message('money_initial_investment'))
        self.m_html.AppendToPage('   <td align="right" nowrap><b>%s %s</b></td>' % (message('money_value'),date.today()))
        self.m_html.AppendToPage('   <td align="right" nowrap><b>%s</b></td>' % message('money_performance'))
        self.m_html.AppendToPage('   <td align="center" nowrap><b>%</b></td>')
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap><b>%s</b></td>' % message('money_investment_evaluation'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_invest(bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_totalValue(bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_perfTotal(bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_perfTotalPercent()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % (message('money_srd')))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_credit(bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_value(QUOTE_CREDIT,bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_perf(QUOTE_CREDIT,bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="center" nowrap>%s</td>'    % (self.m_port.sv_perfPercent(QUOTE_CREDIT)))
        self.m_html.AppendToPage(' </tr>') # __x
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s (%2.2f%s)</td>' % (message('money_cash'),self.m_port.nv_percentCash(QUOTE_CASH),message('money_percent_of_portfolio')))
        self.m_html.AppendToPage('   <td align="right" nowrap></td>')
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_cash(bDispCurrency=True)))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="L20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s (%2.2f%s)</td>' % (message('money_quote'),self.m_port.nv_percentQuotes(QUOTE_CASH),message('money_percent_of_portfolio')))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_buy(QUOTE_CASH,bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_value(QUOTE_CASH,bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="right" nowrap>%s</b></td>' % (self.m_port.sv_perf(QUOTE_CASH,bDispCurrency=True)))
        self.m_html.AppendToPage('   <td align="center" nowrap>%s</td>'    % (self.m_port.sv_perfPercent(QUOTE_CASH)))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage('</table>')
        self.m_html.AppendToPage('<br>')
        self.m_html.AppendToPage('<br>')
        self.m_html.AppendToPage('<table border="1" cellpadding="2" cellspacing="1" width="320" class="bright">')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap><b>%s</b></td>' % message('money_fiscal_year'))
        self.m_html.AppendToPage('   <td align="right" class="percent" nowrap><b>%d</b></td>' % (date.today().year-2))
        self.m_html.AppendToPage('   <td align="right" class="percent" nowrap><b>%d</b></td>' % (date.today().year-1))
        self.m_html.AppendToPage('   <td align="right" class="percent" nowrap><b>%d</b></td>' % date.today().year)
        self.m_html.AppendToPage(' </tr>')

        expenses0,transfer0,appr0,taxable0,taxes0 = self.compute(date.today().year-2)
        expenses1,transfer1,appr1,taxable1,taxes1 = self.compute(date.today().year-1)
        expenses2,transfer2,appr2,taxable2,taxes2 = self.compute(date.today().year)

        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_expenses_vat'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (expenses0,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (expenses1,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (expenses2,self.m_port.currency_symbol()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_total_of_transfers'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (transfer0,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (transfer1,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (transfer2,self.m_port.currency_symbol()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_financial_appreciation'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (appr0,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (appr1,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (appr2,self.m_port.currency_symbol()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_taxable_amounts'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxable0,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxable1,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxable2,self.m_port.currency_symbol()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage(' <tr align="right" class="T20">')
        self.m_html.AppendToPage('   <td align="left" nowrap>%s</td>' % message('money_amount_of_taxes'))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxes0,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxes1,self.m_port.currency_symbol()))
        self.m_html.AppendToPage('   <td align="right" nowrap>%.2f %s</td>' % (taxes2,self.m_port.currency_symbol()))
        self.m_html.AppendToPage(' </tr>')
        self.m_html.AppendToPage('</table>')
        self.m_html.AppendToPage("</body></html>")
Example #35
0
    def __init__(self, parent, id, title):
        self.m_id = wx.NewId()
        wx.Frame.__init__(self,
                          None,
                          self.m_id,
                          title,
                          size=(640, 480),
                          style=wx.DEFAULT_FRAME_STYLE
                          | wx.NO_FULL_REPAINT_ON_RESIZE)
        iTrade_wxFrame.__init__(self, parent, 'currencies')
        iTrade_wxLiveCurrencyMixin.__init__(self)

        # the menu
        self.filemenu = wx.Menu()
        #self.filemenu.Append(ID_SAVE,message('main_save'),message('main_desc_save'))
        #self.filemenu.AppendSeparator()
        self.filemenu.Append(ID_CLOSE, message('main_close'),
                             message('main_desc_close'))

        self.viewmenu = wx.Menu()
        self.viewmenu.Append(ID_CONVERT, message('main_view_convert'),
                             message('main_view_desc_convert'))
        self.viewmenu.Append(ID_REFRESH, message('main_view_refresh'),
                             message('main_view_desc_refresh'))
        self.viewmenu.AppendCheckItem(ID_AUTOREFRESH,
                                      message('main_view_autorefresh'),
                                      message('main_view_desc_autorefresh'))

        # default checking
        self.updateCheckItems()

        # Creating the menubar
        menuBar = wx.MenuBar()

        # Adding the "<x>menu" to the MenuBar
        menuBar.Append(self.filemenu, message('currency_menu_file'))
        menuBar.Append(self.viewmenu, message('currency_menu_view'))

        # Adding the MenuBar to the Frame content
        self.SetMenuBar(menuBar)

        # Toolbar
        self.m_toolbar = iTradeCurrencyToolbar(self, wx.NewId())

        # default list is quotes
        self.m_list = iTradeCurrenciesMatrix(
            self,
            wx.NewId(),
            style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL
            | wx.LC_VRULES | wx.LC_HRULES,
            list=list_of_currencies())
        #self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL)
        self.m_list.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))

        wx.EVT_SIZE(self, self.OnSize)

        wx.EVT_MENU(self, ID_CLOSE, self.OnClose)
        wx.EVT_MENU(self, ID_CONVERT, self.OnConvert)
        wx.EVT_MENU(self, ID_REFRESH, self.OnRefresh)
        wx.EVT_MENU(self, ID_AUTOREFRESH, self.OnAutoRefresh)

        wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
        wx.EVT_CLOSE(self, self.OnCloseWindow)

        EVT_UPDATE_LIVECURRENCY(self, self.OnLiveCurrency)

        # refresh full view after window init finished
        EVT_POSTINIT(self, self.OnPostInit)
        wx.PostEvent(self, PostInitEvent())

        self.Show(True)
Example #36
0
    def __init__(self, parent, quote, portfolio):
        sc.SizedPanel.__init__(self, parent, -1)

        # keep back reference
        self.m_parent = parent
        self.m_quote = quote
        self.m_portfolio = portfolio

        # select a font
        #self.m_font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)
        #self.SetFont(self.m_font)

        # container
        self.SetSizerType("horizontal")

        # --- resizable pane #1 : Cash Position on the value ------------------
        pane1 = sc.SizedPanel(self, -1)
        pane1.SetSizerType("vertical")
        pane1.SetSizerProps(expand=True)

        # Pane#1 Row #1
        label = wx.StaticText(pane1, -1,
                              message('decision_positiononquote_cash'))
        label.SetSizerProps(valign='center')

        # Pane#1 Box #1
        box1 = sc.SizedPanel(pane1, -1)
        box1.SetSizerType("form")
        box1.SetSizerProps(expand=True)

        # Pane#1 Box #1 Row #1 : number of shares in portfolio
        label = wx.StaticText(box1, -1, message('decision_numofshares'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCashNumOfShares = wx.StaticText(box1, -1, '')
        self.wxCashNumOfShares.SetSizerProps(valign='center')

        # Pane#1 Box #1 Row #2 : PRU in portfolio
        label = wx.StaticText(box1, -1, message('decision_upp'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCashPRU = wx.StaticText(box1, -1, '')
        self.wxCashPRU.SetSizerProps(valign='center')

        # Pane#1 Box #1 Row #3 : PR in portfolio
        label = wx.StaticText(box1, -1, message('decision_pp'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCashPR = wx.StaticText(box1, -1, '')
        self.wxCashPR.SetSizerProps(valign='center')

        # Pane#1 Box #1 Row #4 : Profit in portfolio
        label = wx.StaticText(
            box1, -1,
            message('decision_profit') % quote.currency_symbol())
        label.SetSizerProps(valign='center', halign='right')

        self.wxCashProfit = wx.StaticText(box1, -1, '')
        self.wxCashProfit.SetSizerProps(valign='center')

        # Pane#1 Box #1 Row #5 : Profit Percent in portfolio
        label = wx.StaticText(box1, -1, message('decision_profitpercent'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCashProfitPercent = wx.StaticText(box1, -1, '')
        self.wxCashProfitPercent.SetSizerProps(valign='center')

        # --- separator -------------------------------------------------------

        line = wx.StaticLine(self, -1, size=(-1, 20), style=wx.LI_VERTICAL)
        line.SetSizerProps(expand=True)

        # --- resizable pane #2 : Marging Position on the value ---------------

        pane2 = sc.SizedPanel(self, -1)
        pane2.SetSizerType("vertical")
        pane2.SetSizerProps(expand=True)

        # Pane#2 Row #2
        label = wx.StaticText(pane2, -1,
                              message('decision_positiononquote_credit'))
        label.SetSizerProps(valign='center')

        # Pane#2 Box #2
        box2 = sc.SizedPanel(pane2, -1)
        box2.SetSizerType("form")
        box2.SetSizerProps(expand=True)

        # Pane#2 Box #2 Row #1 : number of shares in portfolio
        label = wx.StaticText(box2, -1, message('decision_numofshares'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCreditNumOfShares = wx.StaticText(box2, -1, '')
        self.wxCreditNumOfShares.SetSizerProps(valign='center')

        # Pane#2 Box #2 Row #2 : PRU in portfolio
        label = wx.StaticText(box2, -1, message('decision_upp'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCreditPRU = wx.StaticText(box2, -1, '')
        self.wxCreditPRU.SetSizerProps(valign='center')

        # Pane#2 Box #2 Row #3 : PR in portfolio
        label = wx.StaticText(box2, -1, message('decision_pp'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCreditPR = wx.StaticText(box2, -1, '')
        self.wxCreditPR.SetSizerProps(valign='center')

        # Pane#2 Box #2 Row #4 : Profit in portfolio
        label = wx.StaticText(
            box2, -1,
            message('decision_profit') % quote.currency_symbol())
        label.SetSizerProps(valign='center', halign='right')

        self.wxCreditProfit = wx.StaticText(box2, -1, '')
        self.wxCreditProfit.SetSizerProps(valign='center')

        # Pane#2 Box #2 Row #5 : Profit Percent in portfolio
        label = wx.StaticText(box2, -1, message('decision_profitpercent'))
        label.SetSizerProps(valign='center', halign='right')

        self.wxCreditProfitPercent = wx.StaticText(box2, -1, '')
        self.wxCreditProfitPercent.SetSizerProps(valign='center')

        # --- separator -------------------------------------------------------

        line = wx.StaticLine(self, -1, size=(-1, 20), style=wx.LI_VERTICAL)
        line.SetSizerProps(expand=True)

        # --- resizable pane #3 : Purchasing Power ----------------------------
        pane3 = sc.SizedPanel(self, -1)
        pane3.SetSizerType("vertical")
        pane3.SetSizerProps(expand=True)

        # Pane#3 Row #1
        label = wx.StaticText(pane3, -1, message('decision_purchasingpower'))
        label.SetSizerProps(valign='center')

        # Pane#3 Box #1
        box1 = sc.SizedPanel(pane3, -1)
        box1.SetSizerType("form")
        box1.SetSizerProps(expand=True)

        # Pane#3 Box #1 Row #1 : Available Cash in portfolio currency
        label = wx.StaticText(
            box1, -1,
            message('decision_availablecash') % portfolio.currency_symbol())
        label.SetSizerProps(valign='center', halign='right')

        self.wxAvailableCash = wx.StaticText(box1, -1, '')
        self.wxAvailableCash.SetSizerProps(valign='center')

        # Pane#3 Box #1 Row #2 : Available Cash in quote currency
        self.wxLabelAvailableCashQC = wx.StaticText(
            box1, -1,
            message('decision_availablecash') % quote.currency_symbol())
        self.wxLabelAvailableCashQC.SetSizerProps(valign='center',
                                                  halign='right')

        self.wxAvailableCashQC = wx.StaticText(box1, -1, '')
        self.wxAvailableCashQC.SetSizerProps(valign='center')

        # Pane#3 Box #1 Row #3 : Committed Credit
        label = wx.StaticText(
            box1, -1,
            message('decision_committedcredit') % portfolio.currency_symbol())
        label.SetSizerProps(valign='center', halign='right')

        self.wxCommittedCredit = wx.StaticText(box1, -1, '')
        self.wxCommittedCredit.SetSizerProps(valign='center')

        # Pane#3 Box #1 Row #4 : Available Credit in portfolio currency
        label = wx.StaticText(
            box1, -1,
            message('decision_availablecredit') % portfolio.currency_symbol())
        label.SetSizerProps(valign='center', halign='right')

        self.wxAvailableCredit = wx.StaticText(box1, -1, '')
        self.wxAvailableCredit.SetSizerProps(valign='center')

        # Pane#3 Box #1 Row #5 : Available Credit in quote currency
        self.wxLabelAvailableCreditQC = wx.StaticText(
            box1, -1,
            message('decision_availablecredit') % quote.currency_symbol())
        self.wxLabelAvailableCreditQC.SetSizerProps(valign='center',
                                                    halign='right')

        self.wxAvailableCreditQC = wx.StaticText(box1, -1, '')
        self.wxAvailableCreditQC.SetSizerProps(valign='center')

        # refresh everything
        self.refresh()
    def __init__(self,
                 parent,
                 quote,
                 filter=False,
                 market=None,
                 filterEnabled=True,
                 tradableOnly=False):

        iTradeSizedDialog.__init__(self,
                                   parent,
                                   -1,
                                   message('quote_select_title'),
                                   size=(460, 460),
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER)

        self.m_parent = parent

        # init
        if quote:
            self.m_isin = quote.isin()
            self.m_ticker = quote.ticker()
            self.m_market = quote.market()
            self.m_place = quote.place()
        else:
            self.m_isin = ''
            self.m_ticker = ''
            self.m_market = market
            self.m_place = market2place(market)

        self.m_filter = filter
        self.m_qlist = QLIST_SYSTEM
        self.m_qlist_tradableOnly = tradableOnly

        self.m_editing = True

        tID = wx.NewId()
        self.m_imagelist = wx.ImageList(16, 16)
        self.sm_q = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'quote.png')))
        self.sm_i = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'invalid.png')))
        self.sm_up = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_up.png')))
        self.sm_dn = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_down.png')))

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("horizontal")
        pane.SetSizerProps(expand=True)

        # pane : ISIN or Name selection
        label = wx.StaticText(pane, -1, message('quote_select_isin'))
        label.SetSizerProps(valign='center')

        tID = wx.NewId()
        self.wxIsinCtrl = wx.TextCtrl(pane, tID, self.m_isin)
        self.wxIsinCtrl.SetSizerProps(expand=True)
        wx.EVT_TEXT(self, tID, self.OnISINEdited)

        label = wx.StaticText(pane, -1, message('quote_select_ticker'))
        label.SetSizerProps(valign='center')

        tID = wx.NewId()
        self.wxTickerCtrl = wx.TextCtrl(pane, tID, self.m_ticker)
        self.wxTickerCtrl.SetSizerProps(expand=True)
        wx.EVT_TEXT(self, tID, self.OnTickerEdited)

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("horizontal")
        pane.SetSizerProps(expand=True)

        # pane : market & list filters
        self.wxLabelMarketCtrl = wx.StaticText(pane, -1,
                                               message('quote_select_market'))
        self.wxLabelMarketCtrl.SetSizerProps(valign='center')

        self.wxMarketCtrl = wx.ComboBox(pane,
                                        -1,
                                        "",
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.wxMarketCtrl.SetSizerProps(expand=True)
        wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket)

        count = 0
        idx = 0
        for eachCtrl in list_of_markets(bFilterMode=False):
            self.wxMarketCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_market:
                idx = count
            count = count + 1

        self.wxMarketCtrl.SetSelection(idx)

        self.wxLabelQListCtrl = wx.StaticText(pane, -1,
                                              message('quote_select_list'))
        self.wxLabelQListCtrl.SetSizerProps(valign='center')

        self.wxQListCtrl = wx.ComboBox(pane,
                                       -1,
                                       "",
                                       style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.wxQListCtrl.SetSizerProps(expand=True)
        wx.EVT_COMBOBOX(self, self.wxQListCtrl.GetId(), self.OnQuoteList)

        self.wxQListCtrl.Append(message('quote_select_alllist'), QLIST_ALL)
        self.wxQListCtrl.Append(message('quote_select_syslist'), QLIST_SYSTEM)
        self.wxQListCtrl.Append(message('quote_select_usrlist'), QLIST_USER)
        if not self.m_qlist_tradableOnly:
            self.wxQListCtrl.Append(message('quote_select_indiceslist'),
                                    QLIST_INDICES)
        self.wxQListCtrl.Append(message('quote_select_trackerslist'),
                                QLIST_TRACKERS)
        self.wxQListCtrl.Append(message('quote_select_bondslist'), QLIST_BONDS)
        self.wxQListCtrl.SetSelection(self.m_qlist)

        # select traded or not
        tID = wx.NewId()
        self.wxFilterCtrl = wx.CheckBox(container, tID,
                                        message('quote_select_filterfield'))
        self.wxFilterCtrl.SetValue(self.m_filter)
        wx.EVT_CHECKBOX(self, tID, self.OnFilter)
        self.wxFilterCtrl.Enable(filterEnabled)

        # List
        self.m_list = iTradeSelectorListCtrl(container,
                                             tID,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER,
                                             size=(440, 380))
        self.m_list.SetSizerProps(expand=True)
        self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL)

        # Now that the list exists we can init the other base class,
        # see wxPython/lib/mixins/listctrl.py
        wxl.ColumnSorterMixin.__init__(self, 5)

        wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick)
        wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated)
        wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        self.wxOK = wx.Button(btnpane, wx.ID_OK, message('valid'))
        self.wxOK.SetDefault()
        self.wxOK.SetHelpText(message('valid_desc'))
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # set the right filter and fit everything
        self.OnFilter()

        EVT_POSTINIT(self, self.OnPostInit)
        wx.PostEvent(self, PostInitEvent())
 def desc(self):
     return message('login_fortuneo_desc')
 def setTitle(self):
     self.SetTitle("%s %s - %s" % (message('quote_title'),self.m_quote.ticker(),self.m_quote.market()))
Example #40
0
    setLevel(logging.INFO)

    app = wx.App(False)

    iRet = iTradeYesNo(None, "message without cancel and default to Yes",
                       "caption")
    if iRet == wx.ID_YES:
        iRet = iTradeYesNo(None,
                           "message with cancel and default to No",
                           "caption",
                           bCanCancel=True,
                           bYesDefault=False)
        if iRet == wx.ID_YES:
            iTradeInformation(
                None,
                message('portfolio_exist_info') %
                "message with some accents in French ... איט")
        elif iRet == wx.ID_NO:
            iTradeInformation(None, "unconfirmation message")
        else:
            iTradeInformation(
                None,
                "cancellation message .............................. very long ........................... message ........... at least three (3) lines !!!!!!!!!!!"
            )
    else:
        iTradeError(None, "test aborted message")

# ============================================================================
# That's all folks !
# ============================================================================
Example #41
0
    def __init__(self, parent, quote, bAdd=True):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        if bAdd:
            title = message('stops_add_caption') % quote.name()
        else:
            title = message('stops_edit_caption') % quote.name()
        pre.Create(parent, -1, title, size=(420, 420))
        self.PostCreate(pre)

        # init
        self.m_add = bAdd
        self.m_quote = quote
        self.m_parent = parent

        # sizers
        sizer = wx.BoxSizer(wx.VERTICAL)

        # current quote
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, quote.name())
        box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        label = wx.StaticText(self, -1, message('stops_last'))
        box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        label = wx.StaticText(self, -1, quote.sv_close(bDispCurrency=True))
        box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # Thresholds
        if quote.nv_number() == 0:
            msgb = message('stops_noshares_loss')
            msgh = message('stops_noshares_win')
        else:
            msgb = message('stops_shares_loss')
            msgh = message('stops_shares_win')

            box = wx.BoxSizer(wx.HORIZONTAL)

            label = wx.StaticText(
                self, -1,
                message('stops_portfolio') %
                (quote.nv_number(), quote.sv_pr(bDispCurrency=True)))
            box.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 5)

            sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, msgb)
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        self.wxLoss = masked.Ctrl(self,
                                  integerWidth=6,
                                  fractionWidth=2,
                                  controlType=masked.controlTypes.NUMBER,
                                  allowNegative=False,
                                  groupChar=getGroupChar(),
                                  decimalChar=getDecimalChar())
        box.Add(self.wxLoss, 0,
                wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)
        if quote.hasStops(): self.wxLoss.SetValue(quote.nv_stoploss())

        label = wx.StaticText(self, -1, quote.currency_symbol())
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, msgh)
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        self.wxWin = masked.Ctrl(self,
                                 integerWidth=6,
                                 fractionWidth=2,
                                 controlType=masked.controlTypes.NUMBER,
                                 allowNegative=False,
                                 groupChar=getGroupChar(),
                                 decimalChar=getDecimalChar())
        box.Add(self.wxWin, 0,
                wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)
        if quote.hasStops(): self.wxWin.SetValue(quote.nv_stopwin())

        label = wx.StaticText(self, -1, quote.currency_symbol())
        box.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # Commands (OK / CANCEL / Help)
        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # OK
        if bAdd:
            msg = message('stops_add')
            msgdesc = message('stops_add_desc')
        else:
            msg = message('stops_edit')
            msgdesc = message('stops_edit_desc')

        btn = wx.Button(self, wx.ID_OK, msg)
        btn.SetDefault()
        btn.SetHelpText(msgdesc)
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(self, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
Example #42
0
def YesButton(makedefault=1):
    return Button(message('yes'), ` wx.ID_YES `, makedefault)
Example #43
0
def ApplyButton(makedefault=0):
    return Button(message('valid'), ` wx.ID_APPLY `, makedefault)
    def __init__(self, parent, username, password, connector):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent,
                   -1,
                   message('login_title') + ' - ' + connector.name(),
                   size=(420, 420))
        self.PostCreate(pre)

        self.m_username = username
        self.m_password = password
        self.m_connector = connector

        wx.EVT_SIZE(self, self.OnSize)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # info
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, connector.desc())
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # username
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('login_username'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxUsernameCtrl = wx.TextCtrl(self,
                                          -1,
                                          self.m_username,
                                          size=(180, -1))
        box.Add(self.wxUsernameCtrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # password
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('login_password'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxPasswordCtrl = wx.TextCtrl(self,
                                          -1,
                                          self.m_password,
                                          size=(180, -1))
        box.Add(self.wxPasswordCtrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # OK and Cancel
        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # OK
        btn = wx.Button(self, wx.ID_OK, message('login_set'))
        btn.SetDefault()
        btn.SetHelpText(message('login_setdesc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # TEST
        btn = wx.Button(self, wx.ID_REFRESH, message('login_test'))
        btn.SetHelpText(message('login_testdesc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_REFRESH, self.OnTest)

        # CANCEL
        btn = wx.Button(self, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
Example #45
0
def NoButton(makedefault=0):
    return Button(message('no'), ` wx.ID_NO `, makedefault)
Example #46
0
    def __init__(self, parent, quote, qmode):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)

        # pre-init
        self.qmode = qmode

        self.m_parent = parent

        if quote:
            self.m_isin = quote.isin()
            self.m_ticker = quote.ticker()
            self.m_name = quote.name()
            self.m_market = quote.market()
            self.m_place = quote.place()
            self.m_currency = quote.currency()
            self.m_country = quote.country()
        else:
            self.m_isin = ''
            self.m_ticker = ''
            self.m_name = ''
            self.m_place = 'PAR'
            self.m_market = 'EURONEXT'
            self.m_currency = 'EUR'
            self.m_country = 'FR'

        if qmode == QLIST_MODIFY:
            self.tt = message('listquote_modify_title') % quote.key()
            tb = message('listquote_edit')
        elif qmode == QLIST_ADD:
            self.tt = message('listquote_new_title')
            tb = message('listquote_new')
        elif qmode == QLIST_DELETE:
            self.tt = message('listquote_delete_title') % quote.key()
            tb = message('listquote_delete')
        else:
            self.tt = '??'
            tb = '??'

        # post-init
        pre.Create(parent, -1, self.tt, size=(420, 420))
        self.PostCreate(pre)

        #
        sizer = wx.BoxSizer(wx.VERTICAL)

        # isin
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_isin'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        tID = wx.NewId()
        self.editISIN = wx.TextCtrl(self,
                                    tID,
                                    self.m_isin,
                                    size=wx.Size(180, -1),
                                    style=wx.TE_LEFT)
        wx.EVT_TEXT(self, tID, self.OnISINEdited)
        box.Add(self.editISIN, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # ticker and name
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_ticker'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.editTicker = wx.TextCtrl(self,
                                      -1,
                                      self.m_ticker,
                                      size=wx.Size(60, -1),
                                      style=wx.TE_LEFT)
        box.Add(self.editTicker, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_name'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.editName = wx.TextCtrl(self,
                                    -1,
                                    self.m_name,
                                    size=wx.Size(210, -1),
                                    style=wx.TE_LEFT)
        box.Add(self.editName, 0, wx.ALIGN_CENTRE_VERTICAL | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # market
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_market'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.editMarket = wx.ComboBox(self,
                                      -1,
                                      "",
                                      size=wx.Size(200, -1),
                                      style=wx.CB_DROPDOWN | wx.CB_READONLY)
        box.Add(self.editMarket, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_COMBOBOX(self, self.editMarket.GetId(), self.OnMarket)

        count = 0
        for eachCtrl in list_of_markets(ifLoaded=True):
            self.editMarket.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_market:
                idx = count
            count = count + 1

        self.editMarket.SetSelection(idx)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # separator
        box = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # country & place & currency
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_country'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.dispCountry = wx.StaticText(self, -1, self.m_country)
        box.Add(self.dispCountry, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_place'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        tID = wx.NewId()
        self.editPlace = wx.ComboBox(self,
                                     tID,
                                     "",
                                     size=wx.Size(60, -1),
                                     style=wx.CB_DROPDOWN | wx.CB_READONLY)
        box.Add(self.editPlace, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_COMBOBOX(self, tID, self.OnPlace)
        self.fillPlaces()

        label = wx.StaticText(self, -1, message('prop_currency'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        tID = wx.NewId()
        self.editCurrency = wx.ComboBox(self,
                                        tID,
                                        "",
                                        size=wx.Size(80, -1),
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        box.Add(self.editCurrency, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_COMBOBOX(self, tID, self.OnCurrency)

        count = 0
        for eachCtrl in list_of_currencies():
            #print eachCtrl
            self.editCurrency.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_currency:
                idx = count
            count = count + 1

        self.editCurrency.SetSelection(idx)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # buttons
        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # OK
        btn = wx.Button(self, wx.ID_OK, tb)
        btn.SetDefault()
        btn.SetHelpText(message('ok_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(self, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        wx.EVT_SIZE(self, self.OnSize)

        self.checkEnability()
        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)
        self.Layout()
    def __init__(self,parent,id,quote,root):
        wx.Panel.__init__(self, parent, id)
        self.m_id = id
        self.m_quote = quote
        self.m_parent = parent
        self.m_wincb = root
        self.m_parent.aRet = False

        # vertical general layout
        self._sizer = wx.BoxSizer(wx.VERTICAL)

        # ---[ info : ISIN / Ticker / Name : <Rename> <Reload> ... ]---
        box = wx.StaticBox(self, -1, message('prop_reference'))
        thebox = wx.StaticBoxSizer(box,wx.VERTICAL)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_ref'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.key())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_isin'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.isin())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_ticker'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.editTicker = wx.TextCtrl(self, -1, self.m_quote.ticker(), size=wx.Size(80,-1), style = wx.TE_LEFT)
        box.Add(self.editTicker, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_name'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.editName = wx.TextCtrl(self, -1, self.m_quote.name(), size=wx.Size(300,-1), style = wx.TE_LEFT)
        box.Add(self.editName, 0, wx.ALIGN_CENTRE_VERTICAL|wx.ALL, 5)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_restore'))
        btn.SetHelpText(message('prop_desc_restore'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnRestoreReference)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_rename'))
        btn.SetHelpText(message('prop_desc_rename'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnRename)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_reload'))
        btn.SetHelpText(message('prop_desc_reload'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnReload)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_import'))
        btn.SetHelpText(message('prop_desc_import'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnImport)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_export'))
        btn.SetHelpText(message('prop_desc_export'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnExport)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        self._sizer.AddSizer(thebox, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        # ---[ market ]---
        box = wx.StaticBox(self, -1, message('prop_marketandconnector'))
        thebox = wx.StaticBoxSizer(box,wx.VERTICAL)

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_market'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.market())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_country'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.country())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_place'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.place())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_currency'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, self.m_quote.currency())
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_typeofclock'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.liveText = wx.StaticText(self, -1, self.m_quote.sv_type_of_clock(bDisplayTime=True))
        box.Add(self.liveText, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        # ---[ Connectors ]---

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_liveconnector'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.editLiveConnector = wx.ComboBox(self,-1, "", size=wx.Size(120,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY)
        box.Add(self.editLiveConnector, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        label = wx.StaticText(self, -1, message('prop_impconnector'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.editImportConnector = wx.ComboBox(self,-1, "", size=wx.Size(120,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY)
        box.Add(self.editImportConnector, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.fillConnectors()

        # ---[ Restore/Set Market / Connectors Properties ]---

        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('prop_connhelp'))
        box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_restore'))
        btn.SetHelpText(message('prop_desc_restore'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnRestoreConnector)

        nid = wx.NewId()
        btn = wx.Button(self, nid, message('prop_set'))
        btn.SetHelpText(message('prop_desc_set'))
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(self, nid, self.OnSetConnector)

        thebox.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        self._sizer.AddSizer(thebox, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        # auto layout
        self.SetAutoLayout(True)
        self.SetSizer(self._sizer)
        self.Layout()
Example #48
0
    def PopulateList(self, curquote=None):
        wx.SetCursor(wx.HOURGLASS_CURSOR)

        self.m_list.ClearAll()

        # but since we want images on the column header we have to do it the hard way:
        self.m_list.InsertColumn(IDC_ISIN, message('isin'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_TICKER, message('ticker'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_NAME, message('name'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_PLACE, message('place'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_MARKET, message('market'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_LIVE, message('clive'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_IMPORT, message('cimport'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)

        count = 0
        self.currentItem = -1

        self.itemDataMap = {}
        self.itemQuoteMap = {}
        self.itemLineMap = {}

        for eachQuote in quotes.list():
            if self.m_qlist == QLIST_ALL or self.m_qlist == eachQuote.list():
                self.itemDataMap[count] = (eachQuote.isin(),
                                           eachQuote.ticker(),
                                           eachQuote.name(), eachQuote.place(),
                                           eachQuote.market(),
                                           eachQuote.liveconnector().name(),
                                           eachQuote.importconnector().name())

                self.itemQuoteMap[count] = eachQuote
                count = count + 1

        items = self.itemDataMap.items()
        line = 0
        curline = -1
        for x in range(len(items)):
            key, data = items[x]
            if self.m_market == None or (self.m_market == data[4]):
                if data[0] != '':
                    self.m_list.InsertImageStringItem(line, data[0], self.sm_q)
                else:
                    self.m_list.InsertImageStringItem(line, data[0], self.sm_i)
                self.m_list.SetStringItem(line, IDC_TICKER, data[1])
                self.m_list.SetStringItem(line, IDC_NAME, data[2])
                self.m_list.SetStringItem(line, IDC_PLACE, data[3])
                self.m_list.SetStringItem(line, IDC_MARKET, data[4])
                self.m_list.SetStringItem(line, IDC_LIVE, data[5])
                self.m_list.SetStringItem(line, IDC_IMPORT, data[6])
                self.m_list.SetItemData(line, key)
                self.itemLineMap[data[1]] = line
                if self.itemQuoteMap[key] == curquote:
                    curline = line
                line += 1

        self.m_list.SetColumnWidth(IDC_ISIN, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_TICKER, wx.LIST_AUTOSIZE_USEHEADER)
        self.m_list.SetColumnWidth(IDC_NAME, 16 * 10)
        self.m_list.SetColumnWidth(IDC_PLACE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_MARKET, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_LIVE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_IMPORT, wx.LIST_AUTOSIZE)

        if curline != -1:
            self.SetCurrentItem(curline)

        if line == 0:
            self.wxCount.SetLabel(message('listquote_items_zero'))
        elif line == 1:
            self.wxCount.SetLabel(message('listquote_items_one'))
        else:
            self.wxCount.SetLabel(message('listquote_items_n') % line)

        wx.SetCursor(wx.STANDARD_CURSOR)
Example #49
0
 def type_desc(self):
     return message(alert_type_desc[self.m_type])
Example #50
0
    dlg = iTradeDialog(parent=parent,caption=caption,text=text,style=style)
    idRet = dlg.CentreOnParent()
    idRet = dlg.ShowModal()
    dlg.Destroy()
    return idRet

# ============================================================================
# Test me
# ============================================================================

if __name__=='__main__':
    setLevel(logging.INFO)

    app = wx.PySimpleApp()

    iRet = iTradeYesNo(None,"message without cancel and default to Yes","caption")
    if iRet == wx.ID_YES:
        iRet = iTradeYesNo(None,"message with cancel and default to No","caption",bCanCancel=True,bYesDefault=False)
        if iRet == wx.ID_YES:
            iTradeInformation(None,message('portfolio_exist_info')% "message with some accents in French ... איט")
        elif iRet == wx.ID_NO:
            iTradeInformation(None,"unconfirmation message")
        else:
            iTradeInformation(None,"cancellation message .............................. very long ........................... message ........... at least three (3) lines !!!!!!!!!!!")
    else:
        iTradeError(None,"test aborted message")

# ============================================================================
# That's all folks !
# ============================================================================
Example #51
0
    def __init__(self, parent, market):
        # context help
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        title = message('quote_list_title')
        pre.Create(parent, -1, title, size=(590, 460))
        self.PostCreate(pre)

        self.m_parent = parent
        self.m_dirty = False

        self.m_market = market
        self.m_qlist = QLIST_SYSTEM

        tID = wx.NewId()
        self.m_imagelist = wx.ImageList(16, 16)
        self.sm_q = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'quote.png')))
        self.sm_i = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'invalid.png')))
        self.sm_up = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_up.png')))
        self.sm_dn = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_down.png')))

        self.m_list = iTradeSelectorListCtrl(self,
                                             tID,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER,
                                             size=(570, 380))
        self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL)

        # Now that the list exists we can init the other base class,
        # see wxPython/lib/mixins/listctrl.py
        wxl.ColumnSorterMixin.__init__(self, 7)

        wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick)
        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated)
        wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # market selection
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, message('quote_select_market'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxMarketCtrl = wx.ComboBox(self,
                                        -1,
                                        "",
                                        size=wx.Size(200, -1),
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        box.Add(self.wxMarketCtrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket)

        count = 0
        idx = 0
        for eachCtrl in list_of_markets(bFilterMode=True):
            self.wxMarketCtrl.Append(eachCtrl, eachCtrl)
            if eachCtrl == self.m_market:
                idx = count
            count = count + 1

        self.wxMarketCtrl.SetSelection(idx)

        # list selection

        label = wx.StaticText(self, -1, message('quote_select_list'))
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.wxQListCtrl = wx.ComboBox(self,
                                       -1,
                                       "",
                                       size=wx.Size(140, -1),
                                       style=wx.CB_DROPDOWN | wx.CB_READONLY)
        box.Add(self.wxQListCtrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_COMBOBOX(self, self.wxQListCtrl.GetId(), self.OnQuoteList)

        self.wxQListCtrl.Append(message('quote_select_alllist'), QLIST_ALL)
        self.wxQListCtrl.Append(message('quote_select_syslist'), QLIST_SYSTEM)
        self.wxQListCtrl.Append(message('quote_select_usrlist'), QLIST_USER)
        self.wxQListCtrl.Append(message('quote_select_indiceslist'),
                                QLIST_INDICES)
        self.wxQListCtrl.Append(message('quote_select_trackerslist'),
                                QLIST_TRACKERS)
        self.wxQListCtrl.Append(message('quote_select_bondslist'), QLIST_BONDS)
        self.wxQListCtrl.SetSelection(self.m_qlist)

        self.wxCount = wx.StaticText(self, -1, '--')
        box.Add(self.wxCount, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        box.Add(self.m_list, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        box2 = wx.BoxSizer(wx.VERTICAL)

        self.wxNEW = wx.Button(self, wx.ID_NEW, message('listquote_new'))
        self.wxNEW.SetHelpText(message('listquote_new_desc'))
        box2.Add(self.wxNEW, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_NEW, self.OnNewQuote)

        self.wxPROP = wx.Button(self, wx.ID_PROPERTIES,
                                message('listquote_edit'))
        self.wxPROP.SetHelpText(message('listquote_edit_desc'))
        box2.Add(self.wxPROP, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_PROPERTIES, self.OnEditQuote)

        self.wxDELETE = wx.Button(self, wx.ID_DELETE,
                                  message('listquote_delete'))
        self.wxDELETE.SetHelpText(message('listquote_delete_desc'))
        box2.Add(self.wxDELETE, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_DELETE, self.OnDeleteQuote)

        box.Add(box2, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # CANCEL
        btn = wx.Button(self, wx.ID_CANCEL, message('close'))
        btn.SetHelpText(message('close_desc'))
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # SAVE
        btn.SetDefault()
        self.wxSAVE = wx.Button(self, wx.ID_APPLY, message('listquote_save'))
        self.wxSAVE.SetHelpText(message('listquote_save_desc'))
        box.Add(self.wxSAVE, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_APPLY, self.OnSave)

        # DOWNLOAD
        self.wxOK = wx.Button(self, wx.ID_OK, '')
        self.wxOK.SetHelpText('')
        box.Add(self.wxOK, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnDownload)

        # CLEAR
        self.wxCLEAR = wx.Button(self, wx.ID_CLEAR, '')
        self.wxCLEAR.SetHelpText('')
        box.Add(self.wxCLEAR, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        wx.EVT_BUTTON(self, wx.ID_CLEAR, self.OnClear)

        sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)

        EVT_POSTINIT(self, self.OnPostInit)
        wx.PostEvent(self, PostInitEvent())
Example #52
0
    def __init__(self, parent, portfolio, operation, except_portfolio=None):
        iTradeSizedDialog.__init__(self,
                                   parent,
                                   -1,
                                   message('portfolio_%s_title' % operation),
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER,
                                   size=(420, 420))

        # init
        if portfolio:
            self.m_name = portfolio.filename()
            self.m_accountref = portfolio.accountref()
        else:
            self.m_name = ''
            self.m_accountref = ''
        self.m_except = except_portfolio

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # Row 1
        label = wx.StaticText(pane, -1, message('portfolio_select_textfield'))
        label.SetSizerProps(valign='center')
        self.wxNameCtrl = wx.TextCtrl(pane, -1, self.m_name, size=(80, -1))
        self.wxNameCtrl.SetSizerProps(expand=True)

        # Row 2 :
        tID = wx.NewId()
        self.m_imagelist = wx.ImageList(16, 16)
        self.sm_q = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'quote.png')))
        self.sm_i = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'invalid.png')))
        self.sm_up = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_up.png')))
        self.sm_dn = self.m_imagelist.Add(
            wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_down.png')))

        self.m_list = iTradeSelectorListCtrl(container,
                                             tID,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER,
                                             size=(400, 380))
        self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL)
        self.m_list.SetSizerProps(expand=True)

        self.PopulateList()

        # Now that the list exists we can init the other base class,
        # see wxPython/lib/mixins/listctrl.py
        wxl.ColumnSorterMixin.__init__(self, 3)

        wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick)
        wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated)
        wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        if operation == 'delete':
            msg = message('portfolio_properties_btndelete')
            msgdesc = message('portfolio_properties_btndeletedesc')
        elif operation == 'select':
            msg = message('portfolio_properties_btnselect')
            msgdesc = message('portfolio_properties_btnselectdesc')
        else:
            msg = message('valid')
            msgdesc = message('valid_desc')

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, msg)
        btn.SetDefault()
        btn.SetHelpText(msgdesc)
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())

        self.wxNameCtrl.SetFocus()
Example #53
0
    def __init__(self,parent,caption,text,size=(420, 380),style=wx.OK | wx.YES_DEFAULT):
        iTradeSizedDialog.__init__(self,parent,-1,caption,size,style=wx.DEFAULT_DIALOG_STYLE)

        image = None
        if style & wx.ICON_INFORMATION == wx.ICON_INFORMATION:
            image = os.path.join(itrade_config.dirRes, "box_info.png")
        if style & wx.ICON_ERROR == wx.ICON_ERROR:
            image = os.path.join(itrade_config.dirRes, "box_alert.png")
        if style & wx.ICON_QUESTION == wx.ICON_QUESTION:
            image = os.path.join(itrade_config.dirRes, "box_yesno.png")

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # First Row : image + text
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("horizontal")
        pane.SetSizerProps(expand=True)

        if image:
            image = wx.Bitmap(image)
            if image:
                bmp = wx.StaticBitmap(pane, -1, image)
                bmp.SetSizerProps(valign='center')

        if len(text)>96:
            h = 48
        else:
            h = 32
        txt = wx.StaticText(pane, -1, text, size=(260,h))
        txt.SetFont(wx.Font(10, wx.SWISS , wx.NORMAL, wx.NORMAL))

        txt.SetSizerProps(expand=True,valign='center',halign='center')

        # Last Row : OK, ..., Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(halign='center')

        # context help
        if style & wx.HELP == wx.HELP:
            if wx.Platform != "__WXMSW__":
                btn = wx.ContextHelpButton(btnpane)

        # OK
        if style & wx.OK == wx.OK:
            btn = wx.Button(btnpane, wx.ID_OK, message('ok'))
            btn.SetDefault()
            btn.SetHelpText(message('ok_desc'))
            wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)

        # YES
        if style & wx.YES == wx.YES:
            btn = wx.Button(btnpane, wx.ID_YES, message('yes'))
            if style & wx.YES_DEFAULT == wx.YES_DEFAULT: btn.SetDefault()
            #btn.SetHelpText(message('yes_desc'))
            wx.EVT_BUTTON(self, wx.ID_YES, self.OnYES)

        # NO
        if style & wx.NO == wx.NO:
            btn = wx.Button(btnpane, wx.ID_NO, message('no'))
            if style & wx.NO_DEFAULT == wx.NO_DEFAULT: btn.SetDefault()
            #btn.SetHelpText(message('no_desc'))
            wx.EVT_BUTTON(self, wx.ID_NO, self.OnNO)

        # CANCEL
        if style & wx.CANCEL == wx.CANCEL:
            btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
            btn.SetHelpText(message('cancel_desc'))
            wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
Example #54
0
    def __init__(self, parent, wn, quote):
        #debug('iTrade_wxLive::__init__')
        wx.Panel.__init__(self, parent, -1)
        self.m_parent = wn
        self.m_quote = quote
        self.m_live = quote.liveconnector()

        self.m_font = wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL)
        self.SetFont(self.m_font)

        # column mapping
        #    nb qt ach ven qt  nb  hou qte price clock
        X = (10, 60, 130, 190, 250, 320, 380, 450, 520, 380)
        W = (50, 70, 60, 60, 70, 50, 70, 70, 60, 70)

        # notebook
        title = wx.StaticText(self,
                              -1,
                              message('live_notebook'),
                              wx.Point(X[0], 5),
                              wx.Size(W[0] + W[1] + W[2] + W[3] + W[4] + W[5],
                                      15),
                              style=wx.ALIGN_CENTRE)
        title.SetBackgroundColour('sea green')
        nb = wx.StaticText(self,
                           -1,
                           message('live_number'),
                           wx.Point(X[0], 20),
                           wx.Size(W[0], 15),
                           style=wx.ALIGN_RIGHT)
        qte = wx.StaticText(self,
                            -1,
                            message('live_qty'),
                            wx.Point(X[1], 20),
                            wx.Size(W[1], 15),
                            style=wx.ALIGN_RIGHT)
        price = wx.StaticText(self,
                              -1,
                              message('live_buy'),
                              wx.Point(X[2], 20),
                              wx.Size(W[2], 15),
                              style=wx.ALIGN_RIGHT)
        price = wx.StaticText(self,
                              -1,
                              message('live_sell'),
                              wx.Point(X[3], 20),
                              wx.Size(W[3], 15),
                              style=wx.ALIGN_RIGHT)
        qte = wx.StaticText(self,
                            -1,
                            message('live_qty'),
                            wx.Point(X[4], 20),
                            wx.Size(W[4], 15),
                            style=wx.ALIGN_RIGHT)
        nb = wx.StaticText(self,
                           -1,
                           message('live_number'),
                           wx.Point(X[5], 20),
                           wx.Size(W[5], 15),
                           style=wx.ALIGN_RIGHT)

        y = 35
        self.nba = {}
        self.qtea = {}
        self.pricea = {}
        self.pricev = {}
        self.qtev = {}
        self.nbv = {}
        for i in range(0, NBLINES):
            self.nba[i] = wx.StaticText(self,
                                        -1,
                                        "-",
                                        wx.Point(X[0], y),
                                        wx.Size(W[0], 15),
                                        style=wx.ALIGN_RIGHT
                                        | wx.ST_NO_AUTORESIZE)
            self.qtea[i] = wx.StaticText(self,
                                         -1,
                                         "-",
                                         wx.Point(X[1], y),
                                         wx.Size(W[1], 15),
                                         style=wx.ALIGN_RIGHT
                                         | wx.ST_NO_AUTORESIZE)
            self.pricea[i] = wx.StaticText(self,
                                           -1,
                                           "-",
                                           wx.Point(X[2], y),
                                           wx.Size(W[2], 15),
                                           style=wx.ALIGN_RIGHT
                                           | wx.ST_NO_AUTORESIZE)
            self.pricev[i] = wx.StaticText(self,
                                           -1,
                                           "-",
                                           wx.Point(X[3], y),
                                           wx.Size(W[3], 15),
                                           style=wx.ALIGN_RIGHT
                                           | wx.ST_NO_AUTORESIZE)
            self.qtev[i] = wx.StaticText(self,
                                         -1,
                                         "-",
                                         wx.Point(X[4], y),
                                         wx.Size(W[4], 15),
                                         style=wx.ALIGN_RIGHT
                                         | wx.ST_NO_AUTORESIZE)
            self.nbv[i] = wx.StaticText(self,
                                        -1,
                                        "-",
                                        wx.Point(X[5], y),
                                        wx.Size(W[5], 15),
                                        style=wx.ALIGN_RIGHT
                                        | wx.ST_NO_AUTORESIZE)
            y = y + 15

        fmp = wx.StaticText(self,
                            -1,
                            message('live_FMP'),
                            wx.Point(X[1], y),
                            wx.Size(W[1], 15),
                            style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
        self.fmpa = wx.StaticText(self,
                                  -1,
                                  "-",
                                  wx.Point(X[2], y),
                                  wx.Size(W[2], 15),
                                  style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
        self.fmpv = wx.StaticText(self,
                                  -1,
                                  "-",
                                  wx.Point(X[3], y),
                                  wx.Size(W[3], 15),
                                  style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)

        # last trades
        title = wx.StaticText(self,
                              -1,
                              message('live_lasttrades'),
                              wx.Point(X[6], 5),
                              wx.Size(W[6] + W[7] + W[8], 15),
                              style=wx.ALIGN_CENTRE)
        title.SetBackgroundColour('sea green')
        hours = wx.StaticText(self,
                              -1,
                              message('live_hours'),
                              wx.Point(X[6], 20),
                              wx.Size(W[6], 15),
                              style=wx.ALIGN_RIGHT)
        qte = wx.StaticText(self,
                            -1,
                            message('live_qty'),
                            wx.Point(X[7], 20),
                            wx.Size(W[7], 15),
                            style=wx.ALIGN_RIGHT)
        price = wx.StaticText(self,
                              -1,
                              message('live_price'),
                              wx.Point(X[8], 20),
                              wx.Size(W[8], 15),
                              style=wx.ALIGN_RIGHT)

        y = 35
        self.qtelt = {}
        self.hourlt = {}
        self.pricelt = {}
        for i in range(0, LTLINES):
            self.hourlt[i] = wx.StaticText(self,
                                           -1,
                                           "::",
                                           wx.Point(X[6], y),
                                           wx.Size(W[6], 15),
                                           style=wx.ALIGN_RIGHT
                                           | wx.ST_NO_AUTORESIZE)
            self.qtelt[i] = wx.StaticText(self,
                                          -1,
                                          "-",
                                          wx.Point(X[7], y),
                                          wx.Size(W[7], 15),
                                          style=wx.ALIGN_RIGHT
                                          | wx.ST_NO_AUTORESIZE)
            self.pricelt[i] = wx.StaticText(self,
                                            -1,
                                            "-",
                                            wx.Point(X[8], y),
                                            wx.Size(W[8], 15),
                                            style=wx.ALIGN_RIGHT
                                            | wx.ST_NO_AUTORESIZE)
            y = y + 15

        cmp = wx.StaticText(self,
                            -1,
                            message('live_CMP'),
                            wx.Point(X[7], y),
                            wx.Size(W[7], 15),
                            style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
        self.cmplt = wx.StaticText(self,
                                   -1,
                                   "-",
                                   wx.Point(X[8], y),
                                   wx.Size(W[8], 15),
                                   style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)

        self.m_sclock = wx.StaticText(self,
                                      -1,
                                      " ",
                                      wx.Point(X[9], y),
                                      wx.Size(W[9], 15),
                                      style=wx.ALIGN_CENTRE
                                      | wx.ST_NO_AUTORESIZE)

        self.refresh()
Example #55
0
def OKButton(makedefault=1):
    return Button(message('ok'), ` wx.ID_OK `, makedefault)
Example #56
0
    def __init__(self, parent, server, auth, timeout):
        iTradeSizedDialog.__init__(self,
                                   parent,
                                   -1,
                                   message('connection_title'),
                                   size=(420, 420),
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER)

        if server != "":
            ip, self.m_port = server.split(':')
            a, b, c, d = ip.split('.')
            self.m_ip = '%3i.%3i.%3i.%3i' % (int(a), int(b), int(c), int(d))
            self.m_port = int(self.m_port)
        else:
            self.m_ip = "   .   .   .   "
            self.m_port = 0
        if auth != "":
            self.m_user, self.m_pwd = auth.split(':')
        else:
            self.m_user = ""
            self.m_pwd = ""
        self.m_timeout = timeout

        # container
        container = self.GetContentsPane()
        container.SetSizerType("vertical")

        # resizable pane
        pane = sc.SizedPanel(container, -1)
        pane.SetSizerType("form")
        pane.SetSizerProps(expand=True)

        # Row 1 : server / proxy="172.30.0.3:8080"
        label = wx.StaticText(pane, -1, message('proxy_server_ip'))
        label.SetSizerProps(valign='center')
        self.wxIPCtrl = masked.Ctrl(pane,
                                    -1,
                                    controlType=masked.controlTypes.IPADDR,
                                    size=(120, -1))
        self.wxIPCtrl.SetValue(self.m_ip)

        label = wx.StaticText(pane, -1, message('proxy_server_port'))
        label.SetSizerProps(valign='center')
        self.wxPortCtrl = masked.Ctrl(pane,
                                      integerWidth=4,
                                      fractionWidth=0,
                                      controlType=masked.controlTypes.NUMBER,
                                      allowNegative=False,
                                      groupDigits=False,
                                      size=(80, -1),
                                      selectOnEntry=True)
        self.wxPortCtrl.SetValue(self.m_port)

        # Row2 : auth = "user:password"
        label = wx.StaticText(pane, -1, message('proxy_auth_user'))
        label.SetSizerProps(valign='center')
        self.wxUserCtrl = wx.TextCtrl(pane, -1, self.m_user, size=(120, -1))
        #self.wxUserCtrl.SetSizerProps(expand=True)

        label = wx.StaticText(pane, -1, message('proxy_auth_pwd'))
        label.SetSizerProps(valign='center')
        self.wxPwdCtrl = wx.TextCtrl(pane, -1, self.m_pwd, size=(120, -1))
        #self.wxPwdCtrl.SetSizerProps(expand=True)

        # Row3 : timeout
        label = wx.StaticText(pane, -1, message('connection_timeout'))
        label.SetSizerProps(valign='center')
        self.wxTimeoutCtrl = masked.Ctrl(
            pane,
            integerWidth=3,
            fractionWidth=0,
            controlType=masked.controlTypes.NUMBER,
            allowNegative=False,
            groupDigits=False,
            size=(80, -1),
            selectOnEntry=True)
        self.wxTimeoutCtrl.SetValue(self.m_timeout)
        #self.wxTimeoutCtrl.SetSizerProps(expand=False)

        # Last Row : OK and Cancel
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        # context help
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(btnpane)

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, message('valid'))
        btn.SetDefault()
        btn.SetHelpText(message('valid_desc'))
        wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid)

        # CANCEL
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel'))
        btn.SetHelpText(message('cancel_desc'))

        # a little trick to make sure that you can't resize the dialog to
        # less screen space than the controls need
        self.Fit()
        self.SetMinSize(self.GetSize())
Example #57
0
def CancelButton(makedefault=0):
    return Button(message('cancel'), ` wx.ID_CANCEL `, makedefault)
    def PopulateList(self, bDuringInit=False):
        wx.SetCursor(wx.HOURGLASS_CURSOR)

        # clear list
        self.m_list.ClearAll()
        self.currentItem = -1

        # but since we want images on the column header we have to do it the hard way:
        self.m_list.InsertColumn(IDC_ISIN, message('isin'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_TICKER, message('ticker'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_NAME, message('name'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_PLACE, message('place'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)
        self.m_list.InsertColumn(IDC_MARKET, message('market'),
                                 wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE)

        x = 0

        self.itemDataMap = {}
        self.itemQuoteMap = {}
        self.itemLineMap = {}

        for eachQuote in quotes.list():
            if (not self.m_filter or eachQuote.isMatrix()) and self.isFiltered(
                    eachQuote, bDuringInit):
                self.itemDataMap[x] = (eachQuote.isin(), eachQuote.ticker(),
                                       eachQuote.name(), eachQuote.place(),
                                       eachQuote.market())
                self.itemQuoteMap[x] = eachQuote
                x = x + 1

        items = self.itemDataMap.items()
        line = 0
        curline = -1
        for x in range(len(items)):
            key, data = items[x]
            if data[0] != '':
                self.m_list.InsertImageStringItem(line, data[0], self.sm_q)
            else:
                self.m_list.InsertImageStringItem(line, data[0], self.sm_i)
            if data[0] == self.m_isin and data[1] == self.m_ticker and data[
                    3] == self.m_place and data[4] == self.m_market:
                # current selection
                curline = line
            self.m_list.SetStringItem(line, IDC_TICKER, data[1])
            self.m_list.SetStringItem(line, IDC_NAME, data[2])
            self.m_list.SetStringItem(line, IDC_PLACE, data[3])
            self.m_list.SetStringItem(line, IDC_MARKET, data[4])
            self.m_list.SetItemData(line, key)
            self.itemLineMap[data[1]] = line
            line += 1

        self.m_list.SetColumnWidth(IDC_ISIN, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_TICKER, wx.LIST_AUTOSIZE_USEHEADER)
        self.m_list.SetColumnWidth(IDC_NAME, 16 * 10)
        self.m_list.SetColumnWidth(IDC_PLACE, wx.LIST_AUTOSIZE)
        self.m_list.SetColumnWidth(IDC_MARKET, wx.LIST_AUTOSIZE)
        self.SetCurrentItem(curline)

        wx.SetCursor(wx.STANDARD_CURSOR)