Gnome backgrounds, scanner app for VIP Express (circa Jun 2004)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

86 lines
2.4 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: UTF8 -*-
  3. # Python module denso.py
  4. # Autogenerated from denso.glade
  5. # Generated on Mon Mar 28 09:49:06 2005
  6. # Warning: Do not delete or modify comments related to context
  7. # They are required to keep user's code
  8. import os, gtk
  9. from SimpleGladeApp import SimpleGladeApp
  10. glade_dir = ""
  11. # Put your modules and data here
  12. selected = False
  13. # From here through main() codegen inserts/updates a class for
  14. # every top-level widget in the .glade file.
  15. class Window1(SimpleGladeApp):
  16. def __init__(self, glade_path="denso.glade", root="window1", domain=None):
  17. glade_path = os.path.join(glade_dir, glade_path)
  18. SimpleGladeApp.__init__(self, glade_path, root, domain)
  19. def new(self):
  20. #context Window1.new {
  21. pass
  22. #context Window1.new }
  23. #context Window1 custom methods {
  24. def scan(self):
  25. id = self.status.get_context_id("scan")
  26. self.status.push(id, "Scanning...")
  27. scanargs = '--brightness 30 --mode Gray --resolution 160'
  28. scanpnm = 'scanimage %s > %s%s' % (scanargs,temp,pnmfile)
  29. os.system(scanpnm)
  30. def convert(self):
  31. id = self.status.get_context_id("scan")
  32. self.status.push(id, "Converting...")
  33. convert = 'pnmscale 0.5 %s%s | pnmtojpeg > %s%s' % (temp,pnmfile,path,jpgfile)
  34. cleanup = 'rm -f %s%s' % (temp,pnmfile)
  35. os.system(convert)
  36. os.system(cleanup)
  37. #context Window1 custom methods }
  38. def on_calendar_day_selected(self, widget, *args):
  39. #context Window1.on_calendar_day_selected {
  40. global file, temp, path, selected, pnmfile, jpgfile
  41. year,month,day = self.calendar.get_date()
  42. mo = month + 1
  43. dy = day
  44. yr = year - 2000
  45. path = '~/Denso/'
  46. temp = '/tmp/'
  47. file = 'dar%02d%02d%02d' % (mo,dy,yr)
  48. selection = '%02d/%02d/%02d' % (mo,dy,yr)
  49. pnmfile = file + '.pnm'
  50. jpgfile = file + '.jpg'
  51. id = self.status.get_context_id("select")
  52. self.status.push(id, selection)
  53. selected = True
  54. #context Window1.on_calendar_day_selected }
  55. def on_scan_clicked(self, widget, *args):
  56. #context Window1.on_scan_clicked {
  57. id = self.status.get_context_id("click")
  58. if not selected:
  59. self.status.push(id, "Please select a date first!")
  60. else:
  61. self.scan()
  62. self.convert()
  63. result = 'Saved: %s%s' % (path,jpgfile)
  64. self.status.push(id, result)
  65. #context Window1.on_scan_clicked }
  66. def main():
  67. window1 = Window1()
  68. window1.run()
  69. if __name__ == "__main__":
  70. main()