4.2. wxpython

4.2.1. gnumed.py

main wrapper setting up global brokers, logging, command line argument handling, i18n, etc.
GNUmed
======
This is the launcher for the main GNUmed GUI client. It is
intended to be used as a standalone program.

Command line arguments:

--quiet
 Be extra quiet and show only _real_ errors in the log.
--debug
 Be extra verbose and report nearly everything that's going
 on. Useful for, well, debugging :-)
--text-domain=<< a_text_domain > Set this to change the name of the language file to be loaded.
 Note, this does not change the directory the file is searched in,
 only the name of the file where messages are loaded from. The
 standard textdomain is, of course, "gnumed.mo".
--log-file=< a_log_file> > Use this to change the name of the log file.
 See gmLog.py to find out where the standard log file would
 end up.
--help, -h, or -?
 Well, show this help.



further action:
- import gmLog
- import gmI18N, gmGuiBroker, gmGuiMain
- import gmTalkback if necessary

jump to gmGuiMain.main()

4.2.2. gmGuiMain.py


GNUMed GUI client
The application framework and main window of the
all signing all dancing GNUMed reference client.

from wxPython.wx import *
from wxPython.html import *

import gmLogFrame, gmGuiBroker, gmPG, gmSQLSimpleSearch, gmSelectPerson, gmConf, gmLog, gmPlugin
import images
import images_gnuMedGP_Toolbar                 #bitmaps for use on the toolbar
import images_gnuMedGP_TabbedLists             #bitmaps for tabs on notebook
import gmGuiElement_HeadingCaptionPanel        #panel class to display top headings
import gmGuiElement_DividerCaptionPanel        #panel class to display sub-headings or divider headings 
import gmGuiElement_AlertCaptionPanel          #panel to hold flashing alert messages
import gmGP_PatientPicture                     #panel to display patients picture 
import gmGP_Toolbar                            #panel with two toolbars on top of the screen

from gmI18N import gmTimeformat

class MainFrame(wxFrame):
	GNUmed client's main windows frame
	This is where it all happens. Avoid popping up any other windows.
	Most user interaction should happen to and from widgets within this frame

	def __init__(self, parent, id, title, size=wxPyDefaultSize):
		You'll have to browse the source to understand what the constructor does

		# initialize the gui broker
		# allow access to a safe exit function for all modules in case of "emergencies"
		# setup status bar
		# allow all modules to access our status bar
    	    	
		# connect to backend

    	    	# get current user and display it

    	    	# setup platform dependent data
		# create menus
		# setup accelerators
		# register events

		# create the  the main sizer to contain all the others on the form
		# create a top vertical box sizer for the main window
	
		# create a horizontal sizer which will contain all windows at the top of the
		# screen (ie menu's and picture panel - which are on sub sizers)
		# add a wxPanel to this sizer which sits on the left and occupies 90% of width
		# followed by panel for the patients picture which occupies 10%. Add labels for
		# demo patients

		# setup the "top row", where all important patient data is always on display
		# set up the main notebook (gmNotebook)
		# relate plugins to the notebook (via gmPlugin.GetAllPlugins ('gui'))
		# position the Window on the desktop and show it


	def SetupPlatformDependent(self):
		#do the platform dependent stuff

	def OnNotebook (self, event):
		Called when notebook changes

	def RegisterEvents(self):
		#register events we want to react to

	def OnAbout(self, event):
		" A simple 'about' dialog box"

	def SetupAccelerators(self):
	def SetupStatusBar(self):
		#add time and date display to the right corner of the status bar
		#update every second

	def Notify(self):
		Displays date and local time in the second slot of the status bar"

	def CreateMenu(self):
		Create the main menu entries. Individual entries are
		farmed out to the modules

	def Lock(self):
		Lock GNUmed client against unauthorized access"

	def Unlock(self):
		Unlock the main notebook widgets
		As long as we are not logged into the database backend,
		all pages but the 'login' page of the main notebook widget
		are locked; i.e. not accessible by the user

		#unlock notebook pages
		# go straight to patient selection

	def OnFileExit(self, event):

	def CleanExit(self):
		This function should ALWAYS be called when this
		program is to be terminated.
		ANY code that should be executed before a regular shutdown
		should go in here
    
    	def OnClose(self,event):

	def OnIdle(self, event):
		Here we can process any background tasks

	def OnIconize(self, event):

	def OnMaximize(self, event):

	def OnPageChanged(self, event):

class gmApp(wxApp):
	def OnInit(self):
		# do platform dependent stuff
		# create a static GUI element dictionary;
    	    	# show the login window
		# create the MainFrame		

def main():
	GNUmed client written in Python
	to run this application simply call main() or run the module as "main"
	#create an instance of our GNUmed main application
	#and enter the main event loop

gnumed.py calls gmGuiMain.main() 
gmGuiMain.main() creates gmApp
gmApp creates MainFrame
MainFrame sets up the toolbar, top row, Menus (items will be added by the plugins)
main sizers and loads all plugins in directory wxpython/gui

gmApp enters wx event loop, waiting for some action


4.2.3. gmAppoint.py

# gmAppoint - A simple interface to the appointments book.
#             INCOMPLETE, do not link in to rest of app.

4.2.4. gmCryptoWidget.py


This module implements a ""crypto"" aware text widget

This text widget allows arbitrary text to be entered via keyboard,
cut'n paste via clipboard, or text files via drag'n drop
Right clicking pops up a menu that allows to encrypt or decrypt
the selected text segment.

class gmTextctrlFileDropTarget(wxFileDropTarget):
     a generic text control widget that accepts dropped files 

    def __init__(self, textwindow):
    def OnDropFiles(self, x, y, filenames):
        inserts the dropped file(s) content(s) at the cursor position

class gmCryptoText(wxTextCtrl):
    A special text widget that supports cryptography

    A right mouse click pops up a manu that allows to encrypt
    or decrypt selected text segments.
    You can drag and drop any number of text files into the text
    widget, and that text will be inserted at the current cursor
    position

    def __init__(self, parent, id, size=wxPyDefaultSize, style=wxTE_MULTILINE|wxTE_RICH, defaulttext=None):

    def OnRightClick(self, event):
        A right mouse click triggers a popup menu for cryptographic
	functionality"

    def OnContextMenu(self, event):

    def OnEncrypt(self, event):
        triggered by popup contect menu event

    def OnDecrypt(self, event):
    def OnSetPassphrase(self, event):
    def OnRightDown(self, event):
        dummy function; if this event was not intercepted, GTK would
        clear the text selection the very moment the mouse button is clicked

    def AskForPassphrase(self):
        asks for a pass phrase and returns it

    def Encrypt(self, cleartext, key):
        override this function for your own crypto funcs

    def Decrypt(self, ciphertext, key, identtag):
        override this function for your own crypto funcs

    def StripIdentTag(self, text):
        Remove the 'ident tag' from text and return both tag and test
    def GetIdentTag(self):
        This is a 'virtual' function which should be overridden to provide your own meaningful tag

    def SetFuzzyMargin(self, margin):
        The fuzzy margin is the number of characters on each side of the text selection
        the decryption algorithm will search for correct delimiters. It should be at least as long as
        the IdentTag is plus an extra 3 characters to allow for the crypto tag

    def FuzzyScanSelection(self, frompos, topos, margin):

4.2.5. gmEditArea.py

The classes in this file are not used until now. 

class  EditAreaTextBox(wxTextCtrl):
#text control class to be later replaced by the gmPhraseWheel
	def __init__ (self, parent, id, wxDefaultPostion, wxDefaultSize):

class EditAreaPromptLabel(wxStaticText):
#Class which shows a blue bold label left justified
	def __init__(self, parent, id, prompt, aColor = richards_blue):

class EditAreaPrompts(wxPanel):
#create the editorprompts class which expects a dictionary of labels passed to it
#with prompts relevent to the editing area.
	def __init__(self,parent,id,prompt_array):

class EditTextBoxes(wxPanel):
#Class central to gnumed data input
#allows data entry of multiple different types.e.g scripts,
#referrals, measurements, recalls etc
#section = calling section eg allergies, script

have a look at the source code if you want to know what it is doing.

4.2.6. gmGuiElement_AlertCaptionPanel.py

base classes for captioned alert divider on left hand side of
notebook page "patient"

4.2.7. gmGuiElement_DividerCaptionPanel.py

base classes for captioned dividers on left hand side of
notebook page "patient"

4.2.8. gmGuiElement_HeadingCaptionPanel.py

base classes for captioned heading divider on left hand side of
notebook page "patient"

gmGuiMain.py
- inits wxPython GUI framework

4.2.9. gmLogFrame.py

not used anymore, really

4.2.10. gmLoginDialog.py

encapsulates the first dialog, the login window.
should be del()ed after use, actually

4.2.11. gmLogin.py

- encapsulates the login information as a python object

4.2.12. gmMDWImporter.py

- not related to framework
- implements data import from on commercial australian medical
  software

4.2.13. gmShadow.py

- encapsulates custom widget shadow object to be used on all
  Richard-Terry-Style widgets (possibly more)

4.2.14. gmTalkback.py

- encapsulates talkback app

4.2.15. gmUserAdmin.py

- unrelated to framework as of now