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.

68 lines
1.5 KiB

  1. '''
  2. Util for supporting WxPython 3 & 4
  3. '''
  4. import wx
  5. try:
  6. import wx.adv
  7. except ImportError:
  8. pass
  9. isLatestVersion = wx.version().startswith('4')
  10. class Constants:
  11. if isLatestVersion:
  12. WX_FONTSTYLE_NORMAL = wx.FONTSTYLE_NORMAL
  13. WX_DP_DROPDOWN = wx.adv.DP_DROPDOWN
  14. else:
  15. WX_FONTSTYLE_NORMAL = wx.FONTWEIGHT_NORMAL
  16. WX_DP_DROPDOWN = wx.DP_DROPDOWN
  17. class Classes:
  18. if isLatestVersion:
  19. DatePickerCtrl = wx.adv.DatePickerCtrl
  20. else:
  21. DatePickerCtrl = wx.DatePickerCtrl
  22. if isLatestVersion:
  23. TimePickerCtrl = wx.adv.TimePickerCtrl
  24. else:
  25. TimePickerCtrl = wx.TimePickerCtrl
  26. def imageFromBitmap(bitmap):
  27. if isLatestVersion:
  28. return bitmap.ConvertToImage()
  29. else:
  30. return wx.ImageFromBitmap(bitmap)
  31. def bitmapFromImage(image):
  32. if isLatestVersion:
  33. return wx.Bitmap(image)
  34. else:
  35. return wx.BitmapFromImage(image)
  36. def bitmapFromBufferRGBA(im, rgba):
  37. if isLatestVersion:
  38. return wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
  39. else:
  40. return wx.BitmapFromBufferRGBA(im.size[0], im.size[1], rgba)
  41. def AboutDialog():
  42. if isLatestVersion:
  43. return wx.adv.AboutDialogInfo()
  44. else:
  45. return wx.AboutDialogInfo()
  46. def AboutBox(aboutDialog):
  47. return (wx.adv.AboutBox(aboutDialog)
  48. if isLatestVersion
  49. else wx.AboutBox(aboutDialog))