def CreateBitmap(self, artid, client, size): """ Overrides CreateBitmap from wx.ArtProvider. This method looks in the AvoPlot icons directory (as returned by avoplot.get_avoplot_icons_dir()) for the icon specified by artid. The icons are split up into subfolders by size (for example "16x16") and this method will only look in the relevant size subfolder for the requested icon. """ if size.width == -1: sizerq = wx.ArtProvider.GetSizeHint(client) if sizerq.width == -1: sizerq = wx.Size(64,64) else: sizerq = size avail_size = self._get_nearest_avail_size(sizerq.width) if avail_size is None: return wx.NullBitmap filename = os.path.join(avoplot.get_avoplot_icons_dir(), '%dx%d'%(avail_size, avail_size), artid+'.png') return wx.Bitmap(filename, wx.BITMAP_TYPE_PNG)
def CreateBitmap(self, artid, client, size): """ Overrides CreateBitmap from wx.ArtProvider. This method looks in the AvoPlot icons directory (as returned by avoplot.get_avoplot_icons_dir()) for the icon specified by artid. The icons are split up into subfolders by size (for example "16x16") and this method will only look in the relevant size subfolder for the requested icon. """ if size.width == -1: sizerq = wx.ArtProvider.GetSizeHint(client) if sizerq.width == -1: sizerq = wx.Size(64, 64) else: sizerq = size avail_size = self._get_nearest_avail_size(sizerq.width) if avail_size is None: return wx.NullBitmap filename = os.path.join(avoplot.get_avoplot_icons_dir(), '%dx%d' % (avail_size, avail_size), artid + '.png') return wx.Bitmap(filename, wx.BITMAP_TYPE_PNG)
def create_desktop_file(install_paths): """ Function to create the .desktop file for Linux installations. """ import avoplot apps_folder = os.path.join(install_paths['prefix'],'share','applications') if not os.path.isdir(apps_folder): try: os.makedirs(apps_folder) except OSError: print ("Warning! Failed to create avoplot.desktop file. Unable to " "create folder \'%s\'."%apps_folder) return desktop_file_path = os.path.join(apps_folder,'avoplot.desktop') with open(desktop_file_path,'w') as ofp: ofp.write('[Desktop Entry]\n') ofp.write('Version=%s\n'%avoplot.VERSION) ofp.write('Type=Application\n') ofp.write('Exec=%s\n'%os.path.join(install_paths['script_dir'], 'AvoPlot.py')) ofp.write('Comment=%s\n'%avoplot.SHORT_DESCRIPTION) ofp.write('NoDisplay=false\n') ofp.write('Categories=Science;Education;\n') ofp.write('Name=%s\n'%avoplot.PROG_SHORT_NAME) ofp.write('Icon=%s\n'%os.path.join(avoplot.get_avoplot_icons_dir(), '64x64','avoplot.png')) return_code = os.system("chmod 644 " + os.path.join(apps_folder, 'avoplot.desktop')) if return_code != 0: print ("Error! Failed to change permissions on \'" + os.path.join(apps_folder, 'avoplot.desktop') + "\'")
def __init__(self): wx.ArtProvider.__init__(self) #create a list of available icon sizes based on the names of the #subfolders in the icons folder icon_dir = os.path.join(avoplot.get_avoplot_icons_dir(), '*x*') szs = [int(os.path.basename(f).split('x')[-1]) for f in glob.glob(icon_dir)] self.avail_sizes = numpy.array(szs)
def __init__(self): wx.ArtProvider.__init__(self) #create a list of available icon sizes based on the names of the #subfolders in the icons folder icon_dir = os.path.join(avoplot.get_avoplot_icons_dir(), '*x*') szs = [ int(os.path.basename(f).split('x')[-1]) for f in glob.glob(icon_dir) ] self.avail_sizes = numpy.array(szs)
def create_desktop_file(install_paths): """ Function to create the .desktop file for Linux installations. """ import avoplot apps_folder = os.path.join(install_paths['prefix'], 'share', 'applications') if not os.path.isdir(apps_folder): try: os.makedirs(apps_folder) except OSError: print( "Warning! Failed to create avoplot.desktop file. Unable to " "create folder \'%s\'." % apps_folder) return desktop_file_path = os.path.join(apps_folder, 'avoplot.desktop') with open(desktop_file_path, 'w') as ofp: ofp.write('[Desktop Entry]\n') ofp.write('Version=%s\n' % avoplot.VERSION) ofp.write('Type=Application\n') ofp.write('Exec=%s\n' % os.path.join(install_paths['script_dir'], 'AvoPlot.py')) ofp.write('Comment=%s\n' % avoplot.SHORT_DESCRIPTION) ofp.write('NoDisplay=false\n') ofp.write('Categories=Science;Education;\n') ofp.write('Name=%s\n' % avoplot.PROG_SHORT_NAME) ofp.write('Icon=%s\n' % os.path.join(avoplot.get_avoplot_icons_dir(), '64x64', 'avoplot.png')) return_code = os.system("chmod 644 " + os.path.join(apps_folder, 'avoplot.desktop')) if return_code != 0: print("Error! Failed to change permissions on \'" + os.path.join(apps_folder, 'avoplot.desktop') + "\'")
import cPickle import avoplot if sys.argv[1] == "-install": # find where the AvoPlot.py script got installed to - this will be in the same # folder as the postinstall script (i.e. this script) script_dir = os.path.abspath(os.path.dirname(sys.argv[0])) script_path = os.path.join(script_dir, "AvoPlot.py") desktop_folder = get_special_folder_path("CSIDL_DESKTOPDIRECTORY") start_menu_folder = get_special_folder_path("CSIDL_STARTMENU") avoplot_prog_name = avoplot.PROG_SHORT_NAME + ".lnk" icon_path = os.path.join(avoplot.get_avoplot_icons_dir(), "avoplot.ico") create_shortcut( os.path.join(sys.prefix, "pythonw.exe"), # program avoplot.SHORT_DESCRIPTION, # description avoplot_prog_name, # filename script_path, # parameters "", # workdir icon_path, # iconpath ) # move shortcut from current directory to Start menu shutil.move(os.path.join(os.getcwd(), avoplot_prog_name), os.path.join(start_menu_folder, avoplot_prog_name)) # tell windows installer that we created another # file which should be deleted on uninstallation file_created(os.path.join(start_menu_folder, avoplot_prog_name))
import shutil import cPickle import avoplot if sys.argv[1] == '-install': #find where the AvoPlot.py script got installed to - this will be in the same #folder as the postinstall script (i.e. this script) script_dir = os.path.abspath(os.path.dirname(sys.argv[0])) script_path = os.path.join(script_dir, 'AvoPlot.py') desktop_folder = get_special_folder_path("CSIDL_DESKTOPDIRECTORY") start_menu_folder = get_special_folder_path("CSIDL_STARTMENU") avoplot_prog_name = avoplot.PROG_SHORT_NAME + '.lnk' icon_path = os.path.join(avoplot.get_avoplot_icons_dir(), 'avoplot.ico') create_shortcut( os.path.join(sys.prefix, 'pythonw.exe'), # program avoplot.SHORT_DESCRIPTION, # description avoplot_prog_name, # filename script_path, # parameters '', # workdir icon_path, # iconpath ) # move shortcut from current directory to Start menu shutil.move(os.path.join(os.getcwd(), avoplot_prog_name), os.path.join(start_menu_folder, avoplot_prog_name)) # tell windows installer that we created another # file which should be deleted on uninstallation