Fortune graph in Python

Reading KZKG ^ Gaara's article on "fortune", I remembered the Python script I wrote a while ago so that I could see the messages from "fortune" in a window.

You need to have python installed (obviously), with the libraries for gtk and gobject: pygtk, pygobject (In Ubuntu and derivatives install python-gtk2 and python-gobject packages)

To use it, the code must be copied into a plain text file, for example with the name fortune_gtk.py. It can be run from a terminal, locating in the directory where the file was saved and running:

python fortune_gtk.py

or give it execution permission and launch it like any application. (with double click, for example)

Window view with fortune

Window view with fortune

The script displays different messages one after the other, and ends when the window is closed.

Depending on the length of the text, the size of the window and the duration of the messages change for a better visualization. Also, if you click on the window, the text is copied, and it can be pasted into a text editor.

Take into account that the font is monospaced so that it is not misaligned.

Below the code. Enjoy it!!

(When downloading, save with name fortune_gtk.py)

PS: I'm not a programmer, just an amateur. Noticeable…:-)


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   KZKG ^ Gaara said

    Thanks for the contribution 😀

    1.    RubenGnu said

      On the contrary, thanks to you for your work!

  2.   RubenGnu said

    If you see that the message does not fit in the window, it is that the size of the font that your system shows is large. You can correct by increasing the size of the window. how? In the code…
    where says:
    self.factor = .2
    It means 0.2 -> window size is 20% of the screen
    Correct the factor to taste. For example, at 30% it will be:
    self.factor = .3
    Save the file and Done!

  3.   poor taku said

    I provided the application in debian 8 but it is not working very well, but thanks for the code, in a few years when I am a jedi of c ++ and it reaches python it will be a good didactic material

    1.    RubenGnu said

      What happened to you?