Editing Python Desk Top Applications

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 41: Line 41:
 
*[[Python Control of Smart Plugs]]
 
*[[Python Control of Smart Plugs]]
 
*[[Python Scheduling Application]]
 
*[[Python Scheduling Application]]
 +
 +
== Other Important Components ==
 +
 +
==== Logger ====
 +
Logger ( in logger.py ) and Parameters ( in parameters.py ). The controller creates one of each, and make them available to the other components. The other components can interact with them, and uses them respectively for logging events, and getting access to parameters ( those aspects of the application that are particularly easy to change ).  I describe more of this in [[My Python Coding Conventions]]
 +
 +
==== Parameters ====
 +
 +
This is a fairly big topic.  It is how you or your user easily controls some aspect of the program.  See '''[[Configuration Files For Python]]'''.
 +
 +
==== AppGlobal ====
 +
 +
Global Values: Yes I know that globals are bad, but they can be useful.  For example many class instances need to access the parameter file.  This can be done using the singleton class AppGlobal.
 +
It has values at the class level ( not instance ) that are available simply by importing the class.  Many values are originally defaulted to None, and are set to valid values as the application initializes and runs, starting, default values often come from parameters, or for instance variables from self as the instance is initialized.  Some values that used to be shared through an instance of the application are now shared through AppGlobal.  This code change is still in process.  AppGlobal has now expanded to include globally useful functions. 
 +
 +
==== RunningOn ====
 +
A new class RunningOn has fairly recently be added to gather information about the platform the system is running on.  This information is later used to adjust the system automatically to run when moved from system to system without any code or parameter changes.  It is a bit tricky because some of the functions it uses and value obtained vary from system to system.  Still seems to work pretty well.
 +
 +
Variables in RunningOn may be use in parameters to branch based OS or computer name or TCP IP address.  Occasionally values will be used in other code.
 +
 +
 +
==== Paths and File Names ====
 +
There are a couple of challenges with paths and file names:
 +
*Are they relative or absolute?
 +
*How to OS differences effect the code?
 +
 +
My current approach:
 +
 +
*For files that are "close" to the code, in your system for the application, I try to use file names that are relative to the installation location of the main Python application.  To facilitate that the application tries to determine the startup location of the application and change the default directory to that location.  Then notations like "./images/something.png" seem to work in the code.  Since slashes seem to work in windows I try to avoid back-slashes.
 +
 +
*For system resources, like your editor, I use both bare filenames -- the system can often find them through environmental paths, or full file names.  These are mostly in parameters.py so you can use what works for you.
 +
 +
==== Helper Tread ====
 +
 +
 +
 +
The application has a main thread running in a Tkinter mainloop.  There is also a second thread called a "helper" running which makes some processing much easier.  To make GUI mainloop responsive to both the GUI and its own processing it uses a pseudo event loop or a polling subroutine that is implemented in xxxxx. The frequency which polling occurs is set in parameters, the relatively low rate of 100 ms between calls ( .1 sec ) seems to give a perfectly responsive application in most cases.  I have run it as fast as once every 10 ms.  Have not tried to find a limit.
 +
 +
=== Database ===
  
 
== Development Environment ==
 
== Development Environment ==

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)