Exemplo n.º 1
0
    def __init__(self, parent, curSelected=(0, 1)):
        iTradeSizedDialog.__init__(self,
                                   parent,
                                   -1,
                                   message('converter_title'),
                                   size=(420, 420),
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER)

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

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

        # Row 1 : Org Currency Value
        self.wxOrgVal = masked.Ctrl(pane,
                                    integerWidth=9,
                                    fractionWidth=2,
                                    controlType=masked.controlTypes.NUMBER,
                                    allowNegative=False,
                                    groupDigits=True,
                                    groupChar=getGroupChar(),
                                    decimalChar=getDecimalChar(),
                                    selectOnEntry=True)
        self.wxOrgVal.SetValue(1)
        masked.EVT_NUM(self, self.wxOrgVal.GetId(), self.OnValueChange)

        self.wxOrgCur = wx.ComboBox(pane,
                                    -1,
                                    "",
                                    size=wx.Size(80, -1),
                                    style=wx.CB_DROPDOWN | wx.CB_READONLY)

        list = list_of_currencies()
        (curFrom, curTo) = curSelected

        for c in list:
            self.wxOrgCur.Append(c, c)

        self.wxOrgCur.SetSelection(curFrom)
        self.m_orgcur = list[curFrom]
        wx.EVT_COMBOBOX(self, self.wxOrgCur.GetId(), self.OnOrgCurrency)

        # Row 2 : Dest Currency Value
        self.wxDestVal = wx.StaticText(pane,
                                       -1,
                                       "",
                                       size=(100, -1),
                                       style=wx.ALIGN_RIGHT
                                       | wx.ST_NO_AUTORESIZE)
        self.wxDestVal.SetLabel('')
        self.wxDestVal.SetSizerProps(valign='center')
        self.wxDestCur = wx.ComboBox(pane,
                                     -1,
                                     "",
                                     size=wx.Size(80, -1),
                                     style=wx.CB_DROPDOWN | wx.CB_READONLY)

        for c in list:
            self.wxDestCur.Append(c, c)

        self.wxDestCur.SetSelection(curTo)
        self.m_destcur = list[curTo]
        wx.EVT_COMBOBOX(self, self.wxDestCur.GetId(), self.OnDestCurrency)

        # 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(self)

        # CLOSE
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('close'))
        btn.SetHelpText(message('close_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())

        EVT_UPDATE_CONVERT(self, self.OnUpdateConvert)

        # convert now
        self.convertValue()
Exemplo n.º 2
0
    def __init__(self, parent, curSelected=(0, 1)):
        iTradeSizedDialog.__init__(self,parent,-1,message('converter_title'),
                                   size=(420, 420),style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

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

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

        # Row 1 : Org Currency Value
        self.wxOrgVal = masked.Ctrl(pane, integerWidth=9, fractionWidth=2, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupDigits = True, groupChar=getGroupChar(), decimalChar=getDecimalChar(), selectOnEntry=True )
        self.wxOrgVal.SetValue(1)
        masked.EVT_NUM(self, self.wxOrgVal.GetId(), self.OnValueChange)

        self.wxOrgCur = wx.ComboBox(pane,-1, "", size=wx.Size(80,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY)

        list = list_of_currencies()
        (curFrom, curTo) = curSelected

        for c in list:
            self.wxOrgCur.Append(c,c)

        self.wxOrgCur.SetSelection(curFrom)
        self.m_orgcur = list[curFrom]
        wx.EVT_COMBOBOX(self,self.wxOrgCur.GetId(),self.OnOrgCurrency)

        # Row 2 : Dest Currency Value
        self.wxDestVal = wx.StaticText(pane, -1, "", size=(100,-1), style = wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
        self.wxDestVal.SetLabel('')
        self.wxDestVal.SetSizerProps(valign='center')
        self.wxDestCur = wx.ComboBox(pane,-1, "", size=wx.Size(80,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY)

        for c in list:
            self.wxDestCur.Append(c,c)

        self.wxDestCur.SetSelection(curTo)
        self.m_destcur = list[curTo]
        wx.EVT_COMBOBOX(self,self.wxDestCur.GetId(),self.OnDestCurrency)

        # 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(self)

        # CLOSE
        btn = wx.Button(btnpane, wx.ID_CANCEL, message('close'))
        btn.SetHelpText(message('close_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())

        EVT_UPDATE_CONVERT(self, self.OnUpdateConvert)

        # convert now
        self.convertValue()
Exemplo n.º 3
0
    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_ALL
        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.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 __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())
Exemplo n.º 5
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())
    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()
    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())
                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 __init__(self, parent, op, opmode, market=None, currency='EUR'):
        # pre-init
        self.opmode = opmode

        self.m_market = market

        if op:
            self.m_type = op.type()
            self.m_value = op.nv_value()
            self.m_expenses = op.nv_expenses()
            self.m_number = op.nv_number()
            if op.quote():
                if op.isQuote():
                    self.m_name = op.quote().key()
                    self.m_market = op.quote().market()
                else:
                    self.m_name = ""
            else:
                self.m_name = op.name()
            self.m_date = op.date()
            self.m_ref = op.ref()
        else:
            self.m_type = OPERATION_SELL
            self.m_value = 0.0
            self.m_expenses = 0.0
            self.m_number = 0
            self.m_name = ""
            self.m_date = date.today()
            self.m_ref = -1

        self.m_parent = parent

        if opmode == OPERATION_MODIFY:
            tb = message('portfolio_modify')
        elif opmode == OPERATION_ADD:
            tb = message('portfolio_new')
        elif opmode == OPERATION_DELETE:
            tb = message('portfolio_delete')
        else:
            tb = '??'
        tt = tb + ' %s - %s %s'
        if op:
            self.tt = tt % (op.date().strftime('%x'),op.operation(),op.description())
        else:
            self.tt = tb

        # init
        iTradeSizedDialog.__init__(self,parent, -1, self.tt, style=wx.DEFAULT_DIALOG_STYLE, size=(420, 480))

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

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

        # Row1 : date
        label = wx.StaticText(pane, -1, message('portfolio_date'))
        label.SetSizerProps(valign='center')

        ssdatetime = wx.DateTimeFromDMY(self.m_date.day,self.m_date.month-1,self.m_date.year)
        self.wxDateCtrl = wx.DatePickerCtrl(pane, -1, ssdatetime , size = (120,-1), style = wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        wx.EVT_DATE_CHANGED(self, self.wxDateCtrl.GetId(), self.OnDate)

        # Row 2 : kind of operation
        label = wx.StaticText(pane, -1, message('portfolio_operation'))
        label.SetSizerProps(valign='center')

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

        count = 0
        for k,v in operation_ctrl:
            #print '***',message(v),k
            self.wxTypeCtrl.Append(message(v),k)
            if k==self.m_type:
                idx = count
            count = count + 1

        self.wxTypeCtrl.SetSelection(idx)

        # Row 3 : quote
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        self.wxNameLabel = wx.StaticText(btnpane, -1, message('portfolio_description'))
        self.wxNameLabel.SetSizerProps(valign='center')

        bmp = wx.Bitmap(os.path.join(itrade_config.dirRes, 'quotes.png'))
        self.wxNameButton = wx.BitmapButton(btnpane, -1, bmp, size=wx.Size(bmp.GetWidth()+5, bmp.GetHeight()+5))
        wx.EVT_BUTTON(self, self.wxNameButton.GetId(), self.OnQuote)

        #print 'creating ctrl:',self.m_name
        self.wxNameCtrl = wx.TextCtrl(btnpane, -1, self.m_name, size=wx.Size(240,-1), style = wx.TE_LEFT)
        wx.EVT_TEXT( self, self.wxNameCtrl.GetId(), self.OnDescChange )
        self.wxNameCtrl.SetSizerProps(expand=True)

        # Row 4 : value
        btnpane = sc.SizedPanel(container, -1)
        btnpane.SetSizerType("horizontal")
        btnpane.SetSizerProps(expand=True)

        self.wxValueLabel = wx.StaticText(btnpane, -1, message('portfolio_field_credit'))
        self.wxValueLabel.SetSizerProps(valign='center')

        self.wxValueCtrl = masked.Ctrl(btnpane, integerWidth=9, fractionWidth=2, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupDigits = True, groupChar=getGroupChar(), decimalChar=getDecimalChar(), selectOnEntry=True )
        wx.EVT_TEXT( self, self.wxValueCtrl.GetId(), self.OnValueChange )

        self.wxValueTxt = wx.StaticText(btnpane, -1, currency2symbol(currency))
        self.wxValueTxt.SetSizerProps(valign='center')

        self.wxExpPreTxt = wx.StaticText(btnpane, -1, '')
        self.wxExpPreTxt.SetSizerProps(valign='center')

        self.wxExpensesCtrl = masked.Ctrl(btnpane, integerWidth=4, fractionWidth=2, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupDigits = True, groupChar=getGroupChar(), decimalChar=getDecimalChar(), selectOnEntry=True )
        wx.EVT_TEXT( self, self.wxExpensesCtrl.GetId(), self.OnExpensesChange )

        self.wxExpPostTxt = wx.StaticText(btnpane, -1, "%s %s" % (currency2symbol(currency),message('portfolio_post_expenses')))
        self.wxExpPostTxt.SetSizerProps(valign='center')

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

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

        self.wxNumberCtrl = masked.Ctrl(pane, integerWidth=9, fractionWidth=0, controlType=masked.controlTypes.NUMBER, allowNegative = False, groupChar=getGroupChar(), decimalChar=getDecimalChar() )
        wx.EVT_TEXT( self, self.wxNumberCtrl.GetId(), self.OnNumberChange )

        # 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)

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

        # OK
        btn = wx.Button(btnpane, wx.ID_OK, tb)
        btn.SetDefault()
        btn.SetHelpText(message('ok_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'))
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        self.refreshPage()
Exemplo n.º 9
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()
Exemplo n.º 10
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())