Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/Tools/pynche/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/Tools/pynche/__pycache__/Switchboard.cpython-33.pyc

�
��f�c@s5dZddlZddlZGdd�d�ZdS(u�Switchboard class.

This class is used to coordinate updates among all Viewers.  Every Viewer must
conform to the following interface:

    - it must include a method called update_yourself() which takes three
      arguments; the red, green, and blue values of the selected color.

    - When a Viewer selects a color and wishes to update all other Views, it
      should call update_views() on the Switchboard object.  Note that the
      Viewer typically does *not* update itself before calling update_views(),
      since this would cause it to get updated twice.

Optionally, Viewers can also implement:

    - save_options() which takes an optiondb (a dictionary).  Store into this
      dictionary any values the Viewer wants to save in the persistent
      ~/.pynche file.  This dictionary is saved using marshal.  The namespace
      for the keys is ad-hoc; make sure you don't clobber some other Viewer's
      keys!

    - withdraw() which takes no arguments.  This is called when Pynche is
      unmapped.  All Viewers should implement this.

    - colordb_changed() which takes a single argument, an instance of
      ColorDB.  This is called whenever the color name database is changed and
      gives a chance for the Viewers to do something on those events.  See
      ListViewer for details.

External Viewers are found dynamically.  Viewer modules should have names such
as FooViewer.py.  If such a named module has a module global variable called
ADDTOVIEW and this variable is true, the Viewer will be added dynamically to
the `View' menu.  ADDTOVIEW contains a string which is used as the menu item
to display the Viewer (one kludge: if the string contains a `%', this is used
to indicate that the next character will get an underline in the menu,
otherwise the first character is underlined).

FooViewer.py should contain a class called FooViewer, and its constructor
should take two arguments, an instance of Switchboard, and optionally a Tk
master window.

iNcBs�|EeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zddd�Z
dd�ZdS(uSwitchboardcCs�||_d|_i|_g|_d|_d|_d|_d|_d}|r�z{yYt	|d�}t
j|�|_t|jt
�s�td|dtj�i|_nWntttfk
r�YnXWd|r�|j�nXndS(Niurbu"Problem reading options from file:ufile(u_Switchboard__initfileuNoneu_Switchboard__colordbu_Switchboard__optiondbu_Switchboard__viewsu_Switchboard__redu_Switchboard__greenu_Switchboard__blueu_Switchboard__canceleduopenumarshaluloadu
isinstanceudictuprintusysustderruIOErroruEOFErroru
ValueErroruclose(uselfuinitfileufp((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyu__init__2s,								
	uSwitchboard.__init__cCs|jj|�dS(N(u_Switchboard__viewsuappend(uselfuview((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuadd_viewLsuSwitchboard.add_viewcCsF||_||_||_x$|jD]}|j|||�q%WdS(N(u_Switchboard__redu_Switchboard__greenu_Switchboard__blueu_Switchboard__viewsuupdate_yourself(uselfuredugreenublueuv((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuupdate_viewsOs
			uSwitchboard.update_viewscCs |j|j|j|j�dS(N(uupdate_viewsu_Switchboard__redu_Switchboard__greenu_Switchboard__blue(uself((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuupdate_views_currentVsu Switchboard.update_views_currentcCs|j|j|jfS(N(u_Switchboard__redu_Switchboard__greenu_Switchboard__blue(uself((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyucurrent_rgbYsuSwitchboard.current_rgbcCs|jS(N(u_Switchboard__colordb(uself((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyucolordb\suSwitchboard.colordbcCsJ||_x0|jD]%}t|d�r|j|�qqW|j�dS(Nucolordb_changed(u_Switchboard__colordbu_Switchboard__viewsuhasattrucolordb_changeduupdate_views_current(uselfucolordbuv((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuset_colordb_s
	uSwitchboard.set_colordbcCs|jS(N(u_Switchboard__optiondb(uself((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuoptiondbfsuSwitchboard.optiondbcCs�|j|jd<|j|jd<|j|jd<x3|jD](}t|d�r:|j|j�q:q:W|jj�|jd<d}z[yt
|jd�}Wn+tk
r�t
d|jdtj�YnXtj|j|�Wd|r�|j�nXdS(	NuREDuGREENuBLUEusave_optionsuDBFILEuwbuCannot write options to file:ufile(u_Switchboard__redu_Switchboard__optiondbu_Switchboard__greenu_Switchboard__blueu_Switchboard__viewsuhasattrusave_optionsu_Switchboard__colordbufilenameuNoneuopenu_Switchboard__initfileuIOErroruprintusysustderrumarshaludumpuclose(uselfuvufp((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyu
save_viewsis"
uSwitchboard.save_viewscCs4x-|jD]"}t|d�r
|j�q
q
WdS(Nuwithdraw(u_Switchboard__viewsuhasattruwithdraw(uselfuv((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuwithdraw_views�suSwitchboard.withdraw_viewsicCs
||_dS(N(u_Switchboard__canceled(uselfuflag((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyucanceled�suSwitchboard.canceledcCs|jS(N(u_Switchboard__canceled(uself((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyu
canceled_p�suSwitchboard.canceled_pN(u__name__u
__module__u__qualname__u__init__uadd_viewuupdate_viewsuupdate_views_currentucurrent_rgbucolordbuset_colordbuoptiondbu
save_viewsuwithdraw_viewsucanceledu
canceled_p(u
__locals__((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyuSwitchboard1suSwitchboard(u__doc__usysumarshaluSwitchboard(((u=/opt/alt/python33/lib64/python3.3/Tools/pynche/Switchboard.pyu<module>*s