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

'''
Util for supporting WxPython 3 & 4
'''
import wx
try:
import wx.adv
except ImportError:
pass
isLatestVersion = wx.version().startswith('4')
class Constants:
if isLatestVersion:
WX_FONTSTYLE_NORMAL = wx.FONTSTYLE_NORMAL
WX_DP_DROPDOWN = wx.adv.DP_DROPDOWN
else:
WX_FONTSTYLE_NORMAL = wx.FONTWEIGHT_NORMAL
WX_DP_DROPDOWN = wx.DP_DROPDOWN
class Classes:
if isLatestVersion:
DatePickerCtrl = wx.adv.DatePickerCtrl
else:
DatePickerCtrl = wx.DatePickerCtrl
def imageFromBitmap(bitmap):
if isLatestVersion:
return bitmap.ConvertToImage()
else:
return wx.ImageFromBitmap(bitmap)
def bitmapFromImage(image):
if isLatestVersion:
return wx.Bitmap(image)
else:
return wx.BitmapFromImage(image)
def bitmapFromBufferRGBA(im, rgba):
if isLatestVersion:
return wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
else:
return wx.BitmapFromBufferRGBA(im.size[0], im.size[1], rgba)
def AboutDialog():
if isLatestVersion:
return wx.adv.AboutDialogInfo()
else:
return wx.AboutDialogInfo()
def AboutBox(aboutDialog):
return (wx.adv.AboutBox(aboutDialog)
if isLatestVersion
else wx.AboutBox(aboutDialog))