#89 Generating ids

closed
2015-12-30
2005-10-14
TemPRImuS
No

There are three problems if I want to generate the
enums automatically.

(the modifications are in codegen_cpp.py)

  1. The enumeration goes from '1000' and not
    'wxID_HIGHEST + 1000' . So I suggest the modification of:

1171c1168
< val = 'wxID_HIGHEST + ' + str(_last_generated_id)


    val = str(_last_generated_id)
  1. The enums value increases with each save because
    _last_generated_id's value is defined too global. I
    solved it this way:

284c284
< _use_gettext, _overwrite, _last_generated_id


       _use_gettext, _overwrite

290,292d289
< # set global _last_generated_id
< _last_generated_id = 1000
<
1151a1148
_last_generated_id = 1000

  1. The value difference between enums is 2 and not 1.
    Maybe this has a reason, but if I Only increase the the
    value of _last_generated_id if it is not called from
    codegen_cpp.py then the problem doesn't occur.

Discussion

  • Alberto Griggio

    Alberto Griggio - 2005-10-14

    Logged In: YES
    user_id=375945

    I've fixed the first two issues, but I'm not sure I
    understand the third: can you please make an example? Thanks!

     
  • TemPRImuS

    TemPRImuS - 2005-10-14

    Logged In: YES
    user_id=1359436

    In the header the generated ids part is:

    // begin wxGlade: SettingsDialog::ids
    enum {
    BUTTON_OK = wxID_HIGHEST + 1000,
    BUTTON_Apply = wxID_HIGHEST + 1002,
    BUTTON_Cancel = wxID_HIGHEST + 1004
    };
    // end wxGlade

    and not the expected:

    // begin wxGlade: SettingsDialog::ids
    enum {
    BUTTON_OK = wxID_HIGHEST + 1000,
    BUTTON_Apply = wxID_HIGHEST + 1001,
    BUTTON_Cancel = wxID_HIGHEST + 1002
    };
    // end wxGlade

    Maybe you can see what happens if I write down what I did to
    avoid this behaviour:

    489c485
    < id_name, id = generate_code_id(sub_obj,
    None, False)


                id_name, id = generate_code_id(sub_obj)
    

    1153c1150
    < def generate_code_id(obj, id=None, auto_incr=True):


    def generate_code_id(obj, id=None):
    1172c1169
    < if auto_incr : _last_generated_id += 1


        _last_generated_id += 1
    

    1426c1424
    < id_name, id = generate_code_id(obj, None, False)


    id_name, id = generate_code_id(obj)
    
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks