Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

NameError when trying to use the designer

Help
Chelonian
2006-10-21
2013-05-01
  • Chelonian
    Chelonian
    2006-10-21

    I am trying, using Boa Constructor, to have the label of a staticText be composed of a string + a variable, something like this:

    now = datetime.datetime.now()
    d = str(now.date())

    self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, label="Today's date is: " + d, name='staticText1', parent=self.panel1, pos=wx.Point(24, 24), size=wx.Size(144, 32),style=0)

    And when I run it it works fine.  However, when I try to use the Designer, I get either of these two errors:

    NameError:  name 'd' is not defined
    File: "C\Python25\Lib\site-packages\boa-constructor\Views\Inspectable  Vies.py", line 152, in initObjCreator

    Am I doing something wrong here or is this a bug, and if so, how can I fix it? 

     
    • Riaan Booysen
      Riaan Booysen
      2006-10-21

      Hi,

      You definitely can't use expressions as string values in the IDE.

      What must the poor Designer make of them?!

      If you want to use variables in the designed source please use the supported mechanism, called
      frame attributes.

      See Examples/advanced/SpecialAttributes/*

      Cheers,
      Riaan.

       
    • Chelonian
      Chelonian
      2006-10-22

      Thank you, that works great.