Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

General layouts & architecture for giving a command-line server a basic GUI in Ubuntu/Quckly?

A few years ago I wrote a python command-line utility for a local community radio station. The purpose of this job was to enhance a radio-stream with metadata obtained from Google Calendar. This meant that anybody listening to the radio station on the stream would be able to read a stream of up-to-date information about what was currently playing and how many minutes it would be until the next show starts.

Mostly this script worked very well and gave good service for years.

Recently a new requirement has come to me: The users of this application want to occasionally stop, start or reload the process (e.g. because schedule information has changed). Rather than teach every member of the studio staff how to use the command-line we thought of giving this tool a simple GUI.

Since the app will be developed and run only on Ubuntu, we selected Quickly as a simple development framework. It's well documented and provides low burdens on developers getting to know the platform.

We hope that the initial design of the application will consist of a browser-like ribbon of tool buttons (start, stop, reload). A large panel containing a scrolling status message. Below that there will be a small status-bar that will give some insight into the current internal state of the program.

Being completely new to GUI programming I'm still unsure how to structure the UI: Major mysteries remain:

  1. What kind of control should be used for the scrolling text-panel where log-messages will flow. This needs to be read-only but updated every time a log message is generated. I had planned to make a custom Python logging handler that redirects any log message to this panel - but what's the easiest way to do this?

  2. The script I have at the moment blocks when it's not doing anything with time.sleep() - that's clearly no good for a GUI, so what's the correct behavior for a process in a GUI app that's got nothing to do for a while?

  3. My process was originally designed to run as a single thread in a terminal. Given that I need it to run more or less as before does that mean I should consider putting the GUI stuff on a separate thread to the worker process. Are there any documented patterns for how to do this within the Quickly framework?

  4. Moving on - is there a good way to make applications developed with Quickly run on platforms other than Ubuntu? For example can I easily adapt my application to work on any other Linux-based OS. What about something unrelated like OSX or Windows?

Thanks!

like image 461
Salim Fadhley Avatar asked Nov 14 '22 03:11

Salim Fadhley


1 Answers

  1. You can use a GtkTextView, read-only. Maybe you can extend it to pipe-it with output.
  2. You can use idle_add() (available in Glib) to run call a method/function any time the program is idle.
  3. You might want to check How to work with threads in pygtk.
  4. PyGTK is portable. Quickly is a wrapper for create applications with PyGTK/PyGObject and some extra niceties. Depending on your code, it should not be very difficult to keep it portable.
like image 79
gpoo Avatar answered Nov 15 '22 18:11

gpoo