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.

63 lines
1.3 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. def imageFromBitmap(bitmap):
  23. if isLatestVersion:
  24. return bitmap.ConvertToImage()
  25. else:
  26. return wx.ImageFromBitmap(bitmap)
  27. def bitmapFromImage(image):
  28. if isLatestVersion:
  29. return wx.Bitmap(image)
  30. else:
  31. return wx.BitmapFromImage(image)
  32. def bitmapFromBufferRGBA(im, rgba):
  33. if isLatestVersion:
  34. return wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
  35. else:
  36. return wx.BitmapFromBufferRGBA(im.size[0], im.size[1], rgba)
  37. def AboutDialog():
  38. if isLatestVersion:
  39. return wx.adv.AboutDialogInfo()
  40. else:
  41. return wx.AboutDialogInfo()
  42. def AboutBox(aboutDialog):
  43. return (wx.adv.AboutBox(aboutDialog)
  44. if isLatestVersion
  45. else wx.AboutBox(aboutDialog))