1

I am not sure if this is a clear question.

I work on a python project that is based on terminal(console), for which I am planning to implement a GUI.

I am not major in CS so I really have no idea about how to effectively design a message system such that:

  1. In console, it provide nice look info when runtime.
  2. In GUI, it is directed to a certain widget, let's say, a text label, or a bottom bar, or a hide-able frame.

Do you have any suggestions?

Currently, I am using print function to provide essential information on stdout during runtime. So a lot of print .... are distributed here and there among the code.

I am thinking to use macro-like variables such as 'FILE_NOT_EXTIS_MESSAGE' for printing, and define the variables in one file. Is this a standard way that people always do? How about I introduce a logging system?

In sum, I am ask for a pattern that people are commonly using for handling of screen output information with high effectiveness and adaptivity.

0

2 Answers 2

1

The scope of this question is too wide to answer on this platform.

However, I can suggest some tips which may help,

  • Keep your core program module and the modules that display / log information as separate as you can.

  • Have an interface to your core program module that can be used by console output module and/or your GUI output module and / or your logging module.

  • The core module need not be aware which of the output modules are currently hooked in.

  • Check the Observer design pattern, if the core module is primarily only sending out information that needs to be displayed / logged.

The best way to learn is by trying out different ways of structuring your code, then read more about design and then go back and refactor your design. Iterate until you run out of time.

0

What you're describing is indeed a logger. Python provides facilities for that: logging documentation (Py 3.3). The logger class basically collects all the messages you dump into it and can output them for use in whatever form you like.

I personally like to have a little extra status window with messages, but I write scientific software, so i'm always in debug-mode. For common endusers, I would stick with a logfile (if you use advanced text editors (notepad++, etc) you can tell them to reload continuously and scroll to the last line, which is pretty close to a console output)

1
  • I second @phi's answer of using python logger capability. You can direct this output to windows by Wxpython txt ctrl for example Commented Jan 17, 2014 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.