Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Private Attributes
pynche.PyncheWidget.PyncheWidget Class Reference

List of all members.

Public Member Functions

def __init__
def start
def window
def withdraw
def deiconify

Private Member Functions

def __quit
def __bell
def __okay
def __cancel
def __keepalive
def __popup_about
def __popup_usage
def __load

Private Attributes

 __sb
 __version
 __textwin
 __listwin
 __detailswin
 __helpwin
 __dialogstate
 __modal
 __tkroot
 __menubar
 __filemenu
 __root

Detailed Description

Definition at line 18 of file PyncheWidget.py.


Constructor & Destructor Documentation

def pynche.PyncheWidget.PyncheWidget.__init__ (   self,
  version,
  switchboard,
  master = None,
  extrapath = [] 
)

Definition at line 19 of file PyncheWidget.py.

00019 
00020     def __init__(self, version, switchboard, master=None, extrapath=[]):
00021         self.__sb = switchboard
00022         self.__version = version
00023         self.__textwin = None
00024         self.__listwin = None
00025         self.__detailswin = None
00026         self.__helpwin = None
00027         self.__dialogstate = {}
00028         modal = self.__modal = not not master
00029         # If a master was given, we are running as a modal dialog servant to
00030         # some other application.  We rearrange our UI in this case (there's
00031         # no File menu and we get `Okay' and `Cancel' buttons), and we do a
00032         # grab_set() to make ourselves modal
00033         if modal:
00034             self.__tkroot = tkroot = Toplevel(master, class_='Pynche')
00035             tkroot.grab_set()
00036             tkroot.withdraw()
00037         else:
00038             # Is there already a default root for Tk, say because we're
00039             # running under Guido's IDE? :-) Two conditions say no, either the
00040             # import fails or _default_root is None.
00041             tkroot = None
00042             try:
00043                 from Tkinter import _default_root
00044                 tkroot = self.__tkroot = _default_root
00045             except ImportError:
00046                 pass
00047             if not tkroot:
00048                 tkroot = self.__tkroot = Tk(className='Pynche')
00049             # but this isn't our top level widget, so make it invisible
00050             tkroot.withdraw()
00051         # create the menubar
00052         menubar = self.__menubar = Menu(tkroot)
00053         #
00054         # File menu
00055         #
00056         filemenu = self.__filemenu = Menu(menubar, tearoff=0)
00057         filemenu.add_command(label='Load palette...',
00058                              command=self.__load,
00059                              underline=0)
00060         if not modal:
00061             filemenu.add_command(label='Quit',
00062                                  command=self.__quit,
00063                                  accelerator='Alt-Q',
00064                                  underline=0)
00065         #
00066         # View menu
00067         #
00068         views = make_view_popups(self.__sb, self.__tkroot, extrapath)
00069         viewmenu = Menu(menubar, tearoff=0)
00070         for v in views:
00071             viewmenu.add_command(label=v.menutext(),
00072                                  command=v.popup,
00073                                  underline=v.underline())
00074         #
00075         # Help menu
00076         #
00077         helpmenu = Menu(menubar, name='help', tearoff=0)
00078         helpmenu.add_command(label='About Pynche...',
00079                              command=self.__popup_about,
00080                              underline=0)
00081         helpmenu.add_command(label='Help...',
00082                              command=self.__popup_usage,
00083                              underline=0)
00084         #
00085         # Tie them all together
00086         #
00087         menubar.add_cascade(label='File',
00088                             menu=filemenu,
00089                             underline=0)
00090         menubar.add_cascade(label='View',
00091                             menu=viewmenu,
00092                             underline=0)
00093         menubar.add_cascade(label='Help',
00094                             menu=helpmenu,
00095                             underline=0)
00096 
00097         # now create the top level window
00098         root = self.__root = Toplevel(tkroot, class_='Pynche', menu=menubar)
00099         root.protocol('WM_DELETE_WINDOW',
00100                       modal and self.__bell or self.__quit)
00101         root.title('Pynche %s' % version)
00102         root.iconname('Pynche')
00103         # Only bind accelerators for the File->Quit menu item if running as a
00104         # standalone app
00105         if not modal:
00106             root.bind('<Alt-q>', self.__quit)
00107             root.bind('<Alt-Q>', self.__quit)
00108         else:
00109             # We're a modal dialog so we have a new row of buttons
00110             bframe = Frame(root, borderwidth=1, relief=RAISED)
00111             bframe.grid(row=4, column=0, columnspan=2,
00112                         sticky='EW',
00113                         ipady=5)
00114             okay = Button(bframe,
00115                           text='Okay',
00116                           command=self.__okay)
00117             okay.pack(side=LEFT, expand=1)
00118             cancel = Button(bframe,
00119                             text='Cancel',
00120                             command=self.__cancel)
00121             cancel.pack(side=LEFT, expand=1)

Here is the caller graph for this function:


Member Function Documentation

def pynche.PyncheWidget.PyncheWidget.__bell (   self,
  event = None 
) [private]

Definition at line 125 of file PyncheWidget.py.

00125 
00126     def __bell(self, event=None):
00127         self.__tkroot.bell()

def pynche.PyncheWidget.PyncheWidget.__cancel (   self,
  event = None 
) [private]

Definition at line 133 of file PyncheWidget.py.

00133 
00134     def __cancel(self, event=None):
00135         self.__sb.canceled()
00136         self.__okay()

Here is the call graph for this function:

Definition at line 137 of file PyncheWidget.py.

00137 
00138     def __keepalive(self):
00139         # Exercise the Python interpreter regularly so keyboard interrupts get
00140         # through.
00141         self.__tkroot.tk.createtimerhandler(KEEPALIVE_TIMER, self.__keepalive)

Here is the call graph for this function:

Here is the caller graph for this function:

def pynche.PyncheWidget.PyncheWidget.__load (   self,
  event = None 
) [private]

Definition at line 167 of file PyncheWidget.py.

00167 
00168     def __load(self, event=None):
00169         while 1:
00170             idir, ifile = os.path.split(self.__sb.colordb().filename())
00171             file = filedialog.askopenfilename(
00172                 filetypes=[('Text files', '*.txt'),
00173                            ('All files', '*'),
00174                            ],
00175                 initialdir=idir,
00176                 initialfile=ifile)
00177             if not file:
00178                 # cancel button
00179                 return
00180             try:
00181                 colordb = ColorDB.get_colordb(file)
00182             except IOError:
00183                 messagebox.showerror('Read error', '''\
00184 Could not open file for reading:
00185 %s''' % file)
00186                 continue
00187             if colordb is None:
00188                 messagebox.showerror('Unrecognized color file type', '''\
00189 Unrecognized color file type in file:
00190 %s''' % file)
00191                 continue
00192             break
00193         self.__sb.set_colordb(colordb)

def pynche.PyncheWidget.PyncheWidget.__okay (   self,
  event = None 
) [private]

Definition at line 128 of file PyncheWidget.py.

00128 
00129     def __okay(self, event=None):
00130         self.__sb.withdraw_views()
00131         self.__tkroot.grab_release()
00132         self.__quit()

Here is the call graph for this function:

Here is the caller graph for this function:

def pynche.PyncheWidget.PyncheWidget.__popup_about (   self,
  event = None 
) [private]

Definition at line 150 of file PyncheWidget.py.

00150 
00151     def __popup_about(self, event=None):
00152         from Main import __version__
00153         messagebox.showinfo('About Pynche ' + __version__,
00154                               '''\
00155 Pynche %s
00156 The PYthonically Natural
00157 Color and Hue Editor
00158 
00159 For information
00160 contact: Barry A. Warsaw
00161 email:   bwarsaw@python.org''' % __version__)

def pynche.PyncheWidget.PyncheWidget.__popup_usage (   self,
  event = None 
) [private]

Definition at line 162 of file PyncheWidget.py.

00162 
00163     def __popup_usage(self, event=None):
00164         if not self.__helpwin:
00165             self.__helpwin = Helpwin(self.__root, self.__quit)
00166         self.__helpwin.deiconify()

Here is the call graph for this function:

def pynche.PyncheWidget.PyncheWidget.__quit (   self,
  event = None 
) [private]

Definition at line 122 of file PyncheWidget.py.

00122 
00123     def __quit(self, event=None):
00124         self.__tkroot.quit()

Here is the caller graph for this function:

Definition at line 197 of file PyncheWidget.py.

00197 
00198     def deiconify(self):
00199         self.__root.deiconify()
00200 
00201 


Definition at line 142 of file PyncheWidget.py.

00142 
00143     def start(self):
00144         if not self.__modal:
00145             self.__keepalive()
00146         self.__tkroot.mainloop()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file PyncheWidget.py.

00147 
00148     def window(self):
00149         return self.__root

Definition at line 194 of file PyncheWidget.py.

00194 
00195     def withdraw(self):
00196         self.__root.withdraw()


Member Data Documentation

Definition at line 24 of file PyncheWidget.py.

Definition at line 26 of file PyncheWidget.py.

Definition at line 55 of file PyncheWidget.py.

Definition at line 25 of file PyncheWidget.py.

Definition at line 23 of file PyncheWidget.py.

Definition at line 51 of file PyncheWidget.py.

Definition at line 27 of file PyncheWidget.py.

Definition at line 97 of file PyncheWidget.py.

Definition at line 20 of file PyncheWidget.py.

Definition at line 22 of file PyncheWidget.py.

Definition at line 33 of file PyncheWidget.py.

Definition at line 21 of file PyncheWidget.py.


The documentation for this class was generated from the following file: