/usr/share/pyspread/src/sysvars.py is in pyspread 0.3.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright Martin Manns
# Distributed under the terms of the GNU General Public License
# --------------------------------------------------------------------
# pyspread is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyspread is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyspread. If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------------------
"""
sysvars
=======
System environment access
"""
import os
import wx
# OS
def is_gtk():
return "__WXGTK__" in wx.PlatformInfo
# Paths
def get_program_path():
"""Returns the path in which pyspread is installed"""
return "/usr/share/pyspread/"
def get_help_path():
"""Returns the pyspread help path"""
return "/usr/share/doc/pyspread/"
def get_python_tutorial_path():
"""Returns the Python tutorial path"""
# If the OS has the Python tutorial installed locally, use it.
# the current path is for Debian
localpath = "/usr/share/doc/python-doc/html/tutorial/index.html"
if os.path.isfile(localpath):
return localpath
else:
return "http://docs.python.org/2/tutorial/"
# System settings
def get_dpi():
"""Returns screen dpi resolution"""
pxmm_2_dpi = lambda (pixels, length_mm): pixels * 25.6 / length_mm
return map(pxmm_2_dpi, zip(wx.GetDisplaySize(), wx.GetDisplaySizeMM()))
def get_color(name):
"""Returns system color from name"""
return wx.SystemSettings.GetColour(name)
def get_default_font():
"""Returns default font"""
return wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
def get_font_string(name):
"""Returns string representation of named system font"""
return wx.SystemSettings.GetFont(name).GetFaceName()
# Fonts
def get_font_list():
"""Returns a sorted list of all system font names"""
font_enum = wx.FontEnumerator()
font_enum.EnumerateFacenames(wx.FONTENCODING_SYSTEM)
font_list = font_enum.GetFacenames()
font_list.sort()
return font_list
def get_default_text_extent(text):
"""Returns the text extent for the default font"""
return wx.GetApp().GetTopWindow().GetTextExtent(text)
|