Changeset 100 for pykoticon/trunk/bin

Show
Ignore:
Timestamp:
01/27/06 14:56:57 (19 years ago)
Author:
jerome
Message:

More generic notification.
Test program has now been successfully run from a prehook directive
in pykota.conf : additionnal arguments are concatenated to produce
an informational message (with only an OK button)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykoticon/trunk/bin/pykoticon

    r97 r100  
    9090        return True 
    9191         
    92     def export_openConfirmDialog(self, printername, username, jobid, jobtitle, jobsize) :     
    93         """Opens a dialog to ask the user to confirm or cancel the print job. 
    94          
    95            Returns True to confirm, False to cancel. 
    96         """    
    97         wx.CallAfter(self.frame.askConfirmation, printername, username, jobid, jobtitle, jobsize) 
    98          
     92    def export_showDialog(self, message, yesno) : 
     93        """Opens a notification or confirmation dialog.""" 
     94        wx.CallAfter(self.frame.showDialog, message, yesno) 
    9995        # ugly, isn't it ? 
    100         while self.frame.askConfirmationResult is None : 
     96        while self.frame.dialogAnswer is None : 
    10197            time.sleep(0.1) 
    102         retcode = self.frame.askConfirmationResult     
    103         self.frame.askConfirmationResult = None # prepare for next call, just in case 
     98        retcode = self.frame.dialogAnswer     
     99        self.frame.dialogAnswer = None # prepare for next call, just in case 
    104100        return retcode 
    105101         
     
    126122    def mainloop(self) : 
    127123        """XML-RPC Server's main loop.""" 
    128         self.register_function(self.export_openConfirmDialog) 
     124        self.register_function(self.export_showDialog) 
    129125        self.register_function(self.export_quitApplication) 
    130126        self.register_function(self.export_nop) 
     
    137133    """Main class.""" 
    138134    def __init__(self, parent, id): 
    139         self.askConfirmationResult = None 
     135        self.dialogAnswer = None 
    140136        wx.Frame.__init__(self, parent, wx.ID_ANY, \ 
    141137               _("PyKota info for  %s") % getCurrentUserName(), \ 
     
    224220        self.Close() 
    225221         
    226     def askConfirmation(self, printername, username, jobid, jobtitle, jobsize) : 
    227         """Asks for confirmation before printing.""" 
    228         message = _("""Hello %(username)s, 
    229          
    230 You sent job %(jobid)s (%(jobtitle)s) to printer %(printername)s. 
    231  
    232 This job seems to be %(jobsize)s pages long.  
    233  
    234 Do you really want to print it ?""") % locals() 
    235                       
    236         dialog = wx.MessageDialog(self, message, _("Confirmation"), \ 
    237                  wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION | wx.STAY_ON_TOP) 
    238         self.askConfirmationResult = ((dialog.ShowModal() == wx.ID_NO) and "CANCEL") or "OK" 
     222    def showDialog(self, message, yesno) : 
     223        """Opens a notification dialog.""" 
     224        self.dialogAnswer = None 
     225        if yesno : 
     226            caption = _("Confirmation") 
     227            style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION 
     228        else : 
     229            caption = _("Information") 
     230            style = wx.OK | wx.ICON_INFORMATION 
     231        style |= wx.STAY_ON_TOP     
     232        dialog = wx.MessageDialog(self, message, caption, style) 
     233        self.dialogAnswer = ((dialog.ShowModal() == wx.ID_NO) and "CANCEL") or "OK" 
    239234        dialog.Destroy() 
     235         
    240236 
    241237class PyKotIconApp(wx.PySimpleApp):