Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing an Python app that makes use of a Gtk.AboutDialog. Some of the information shown in the dialog comes from setting properties for bits of info I've just given elsewhere, and I'd like to avoid duplication.

For instance, in the code:

about = Gtk.AboutDialog()
about.set_program_name("Qreator")
about.set_version('0.1')

The program name and the version are already specified in setup.py (I'm using python-distutils-extra as the build system).

So is there a way to extract that information at runtime (be it from setup.py or somewhere else), so that I don't have to manually specify it again?

share|improve this question
up vote 5 down vote accepted

You can place a constants.py for example, in the python package for your program, and define the values there, instead of in setup.py. You can then import that module from setup.py or the code which shows the about dialog, and set the appropriate values from the appropriate constants.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.