Changeset 100
- Timestamp:
- 01/27/06 14:56:57 (19 years ago)
- Location:
- pykoticon/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykoticon/trunk/bin/pykoticon
r97 r100 90 90 return True 91 91 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) 99 95 # ugly, isn't it ? 100 while self.frame. askConfirmationResultis None :96 while self.frame.dialogAnswer is None : 101 97 time.sleep(0.1) 102 retcode = self.frame. askConfirmationResult103 self.frame. askConfirmationResult= None # prepare for next call, just in case98 retcode = self.frame.dialogAnswer 99 self.frame.dialogAnswer = None # prepare for next call, just in case 104 100 return retcode 105 101 … … 126 122 def mainloop(self) : 127 123 """XML-RPC Server's main loop.""" 128 self.register_function(self.export_ openConfirmDialog)124 self.register_function(self.export_showDialog) 129 125 self.register_function(self.export_quitApplication) 130 126 self.register_function(self.export_nop) … … 137 133 """Main class.""" 138 134 def __init__(self, parent, id): 139 self. askConfirmationResult= None135 self.dialogAnswer = None 140 136 wx.Frame.__init__(self, parent, wx.ID_ANY, \ 141 137 _("PyKota info for %s") % getCurrentUserName(), \ … … 224 220 self.Close() 225 221 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" 239 234 dialog.Destroy() 235 240 236 241 237 class PyKotIconApp(wx.PySimpleApp): -
pykoticon/trunk/tests/test.py
r98 r100 30 30 def main(arguments) : 31 31 """Main function.""" 32 printername = os.environ.get("PYKOTAPRINTERNAME") 33 username = os.environ.get("PYKOTAUSERNAME") 34 jobid = os.environ.get("PYKOTAJOBID") 35 jobtitle = os.environ.get("PYKOTATITLE") 36 jobsize = os.environ.get("PYKOTAPRECOMPUTEDJOBSIZE") 37 try : 38 server = xmlrpclib.ServerProxy("http://%s:%s" % (arguments[0], arguments[1])) 39 result = server.openConfirmDialog(printername, username, jobid, jobtitle, jobsize) 40 except : 41 sys.stderr.write("An error occured !\n") 42 if result != "OK" : 32 printername = os.environ.get("PYKOTAPRINTERNAME", "Unknown") 33 username = os.environ.get("PYKOTAUSERNAME", "Unknown") 34 jobid = os.environ.get("PYKOTAJOBID", "Unknown") 35 jobtitle = os.environ.get("PYKOTATITLE", "Unknown") 36 jobsize = os.environ.get("PYKOTAPRECOMPUTEDJOBSIZE", "Unknown") 37 38 if len(arguments) < 3 : 39 message = """Hello %(username)s, 40 41 You sent job %(jobid)s (%(jobtitle)s) to printer %(printername)s. 42 43 This job seems to be %(jobsize)s pages long. 44 45 Do you really want to print it ?""" % locals() 46 yesno = True 47 else : 48 message = "\n".join(arguments[2:]) 49 yesno = False 50 51 server = xmlrpclib.ServerProxy("http://%s:%s" % (arguments[0], arguments[1])) 52 result = server.showDialog(message, yesno) 53 if yesno and (result != "OK") : 43 54 print result 44 55 45 56 if __name__ == "__main__" : 46 if len(sys.argv) !=3 :57 if len(sys.argv) < 3 : 47 58 sys.stderr.write("usage : %s printing_client_hostname_or_ip_address printing_client_TCPPort\n" % sys.argv[0]) 48 59 else :