示例#1
0
文件: main.py 项目: yltang52/pyzo
def loadIcons():
    """ loadIcons()
    Load all icons in the icon dir.
    """
    # Get directory containing the icons
    iconDir = os.path.join(pyzo.pyzoDir, 'resources', 'icons')
    
    # Construct other icons
    dummyIcon = IconArtist().finish()
    pyzo.icons = ssdf.new()
    for fname in os.listdir(iconDir):
        if fname.endswith('.png'):
            try:
                # Short and full name
                name = fname.split('.')[0]
                name = name.replace('pyzo_', '')  # discart prefix
                ffname = os.path.join(iconDir,fname)
                # Create icon
                icon = QtGui.QIcon() 
                icon.addFile(ffname, QtCore.QSize(16,16))
                # Store
                pyzo.icons[name] = icon
            except Exception as err:
                pyzo.icons[name] = dummyIcon
                print('Could not load icon %s: %s' % (fname, str(err)))
示例#2
0
文件: main.py 项目: stonebig/pyzo
def loadIcons():
    """ loadIcons()
    Load all icons in the icon dir.
    """
    # Get directory containing the icons
    iconDir = os.path.join(pyzo.pyzoDir, "resources", "icons")

    # Construct other icons
    dummyIcon = IconArtist().finish()
    pyzo.icons = ssdf.new()
    for fname in os.listdir(iconDir):
        if fname.endswith(".png"):
            try:
                # Short and full name
                name = fname.split(".")[0]
                name = name.replace("pyzo_", "")  # discart prefix
                ffname = os.path.join(iconDir, fname)
                # Create icon
                icon = QtGui.QIcon()
                icon.addFile(ffname, QtCore.QSize(16, 16))
                # Store
                pyzo.icons[name] = icon
            except Exception as err:
                pyzo.icons[name] = dummyIcon
                print("Could not load icon %s: %s" % (fname, str(err)))
示例#3
0
 def addStarredDir(self, path):
     """Add the given path to the starred directories."""
     # Create new dict
     newProject = ssdf.new()
     newProject.path = op.normcase(path)  # Normalize case!
     newProject.name = op.basename(path)
     newProject.addToPythonpath = False
     # Add it to the config
     self.parent().config.starredDirs.append(newProject)
     # Update list
     self._projects.updateProjectList()
示例#4
0
 def addStarredDir(self, path):
     """ Add the given path to the starred directories.
     """
     # Create new dict
     newProject = ssdf.new()
     newProject.path = op.normcase(path) # Normalize case!
     newProject.name = op.basename(path)
     newProject.addToPythonpath = False
     # Add it to the config
     self.parent().config.starredDirs.append(newProject)
     # Update list
     self._projects.updateProjectList()
示例#5
0
文件: __init__.py 项目: solversa/pyzo
    def __init__(self, parent):
        QtWidgets.QWidget.__init__(self, parent)

        # Get config
        toolId = self.__class__.__name__.lower(
        ) + "2"  # This is v2 of the file browser
        if toolId not in pyzo.config.tools:
            pyzo.config.tools[toolId] = ssdf.new()
        self.config = pyzo.config.tools[toolId]

        # Ensure three main attributes in config
        for name in ["expandedDirs", "starredDirs"]:
            if name not in self.config:
                self.config[name] = []

        # Ensure path in config
        if "path" not in self.config or not isdir(self.config.path):
            self.config.path = op.expanduser("~")

        # Check expandedDirs and starredDirs.
        # Make path objects and remove invalid dirs. Also normalize case,
        # should not be necessary, but maybe the config was manually edited.
        expandedDirs, starredDirs = [], []
        for d in self.config.starredDirs:
            if "path" in d and "name" in d and "addToPythonpath" in d:
                if isdir(d.path):
                    d.path = op.normcase(cleanpath(d.path))
                    starredDirs.append(d)
        for p in set([str(p) for p in self.config.expandedDirs]):
            if isdir(p):
                p = op.normcase(cleanpath(p))
                # Add if it is a subdir of a starred dir
                for d in starredDirs:
                    if p.startswith(d.path):
                        expandedDirs.append(p)
                        break
        self.config.expandedDirs, self.config.starredDirs = expandedDirs, starredDirs

        # Create browser(s).
        self._browsers = []
        for i in [0]:
            self._browsers.append(Browser(self, self.config))

        # Layout
        layout = QtWidgets.QVBoxLayout(self)
        self.setLayout(layout)
        layout.addWidget(self._browsers[0])
        layout.setSpacing(0)
        # set margins
        margin = pyzo.config.view.widgetMargin
        layout.setContentsMargins(margin, margin, margin, margin)
示例#6
0
文件: __init__.py 项目: ghisvail/pyzo
    def loadTool(self, toolId, splitWith=None):
        """ Load a tool by creating a dock widget containing the tool widget.
        """

        # A tool id should always be lower case
        toolId = toolId.lower()

        # Close old one
        if toolId in self._activeTools:
            old = self._activeTools[toolId].widget()
            self._activeTools[toolId].setWidget(QtGui.QWidget(pyzo.main))
            if old:
                old.close()
                old.deleteLater()

        # Get tool class (returns None on failure)
        toolClass = self.getToolClass(toolId)
        if toolClass is None:
            return

        # Already loaded? reload!
        if toolId in self._activeTools:
            self._activeTools[toolId].reload(toolClass)
            return

        # Obtain name from buffered list of names
        for toolDes in self._toolInfo:
            if toolDes.id == toolId:
                name = toolDes.name
                break
        else:
            name = toolId

        # Make sure there is a config entry for this tool
        if not hasattr(pyzo.config.tools, toolId):
            pyzo.config.tools[toolId] = ssdf.new()

        # Create dock widget and add in the main window
        dock = ToolDockWidget(pyzo.main, self)
        dock.setTool(toolId, name, toolClass)

        if splitWith and splitWith in self._activeTools:
            otherDock = self._activeTools[splitWith]
            pyzo.main.splitDockWidget(otherDock, dock, QtCore.Qt.Horizontal)
        else:
            pyzo.main.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        # Add to list
        self._activeTools[toolId] = dock
        self.updateToolInstances()
示例#7
0
文件: __init__.py 项目: ysalmon/pyzo
 def loadTool(self, toolId, splitWith=None):
     """ Load a tool by creating a dock widget containing the tool widget.
     """
     
     # A tool id should always be lower case
     toolId = toolId.lower()
     
     # Close old one
     if toolId in self._activeTools:
         old = self._activeTools[toolId].widget()
         self._activeTools[toolId].setWidget(QtWidgets.QWidget(pyzo.main))
         if old:
             old.close()
             old.deleteLater()
     
     # Get tool class (returns None on failure)
     toolClass = self.getToolClass(toolId)
     if toolClass is None:
         return
     
     # Already loaded? reload!
     if toolId in self._activeTools:
         self._activeTools[toolId].reload(toolClass)
         return
     
     # Obtain name from buffered list of names
     for toolDes in self._toolInfo:
         if toolDes.id == toolId:
             name = toolDes.name
             break
     else:
         name = toolId
     
     # Make sure there is a config entry for this tool
     if not hasattr(pyzo.config.tools, toolId):
         pyzo.config.tools[toolId] = ssdf.new()
     
     # Create dock widget and add in the main window
     dock = ToolDockWidget(pyzo.main, self)
     dock.setTool(toolId, name, toolClass)
     
     if splitWith and splitWith in self._activeTools:
         otherDock = self._activeTools[splitWith]
         pyzo.main.splitDockWidget(otherDock, dock, QtCore.Qt.Horizontal)
     else:
         pyzo.main.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
     
     # Add to list
     self._activeTools[toolId] = dock
     self.updateToolInstances()
示例#8
0
文件: __init__.py 项目: pyzo/pyzo
    def __init__(self, parent):
        QtWidgets.QWidget.__init__(self, parent)

        # Get config
        toolId = self.__class__.__name__.lower() + "2"  # This is v2 of the file browser
        if toolId not in pyzo.config.tools:
            pyzo.config.tools[toolId] = ssdf.new()
        self.config = pyzo.config.tools[toolId]

        # Ensure three main attributes in config
        for name in ["expandedDirs", "starredDirs"]:
            if name not in self.config:
                self.config[name] = []

        # Ensure path in config
        if "path" not in self.config or not isdir(self.config.path):
            self.config.path = op.expanduser("~")

        # Check expandedDirs and starredDirs.
        # Make path objects and remove invalid dirs. Also normalize case,
        # should not be necessary, but maybe the config was manually edited.
        expandedDirs, starredDirs = [], []
        for d in self.config.starredDirs:
            if "path" in d and "name" in d and "addToPythonpath" in d:
                if isdir(d.path):
                    d.path = op.normcase(cleanpath(d.path))
                    starredDirs.append(d)
        for p in set([str(p) for p in self.config.expandedDirs]):
            if isdir(p):
                p = op.normcase(cleanpath(p))
                # Add if it is a subdir of a starred dir
                for d in starredDirs:
                    if p.startswith(d.path):
                        expandedDirs.append(p)
                        break
        self.config.expandedDirs, self.config.starredDirs = expandedDirs, starredDirs

        # Create browser(s).
        self._browsers = []
        for i in [0]:
            self._browsers.append(Browser(self, self.config))

        # Layout
        layout = QtWidgets.QVBoxLayout(self)
        self.setLayout(layout)
        layout.addWidget(self._browsers[0])
        layout.setSpacing(0)
        layout.setContentsMargins(4, 4, 4, 4)
示例#9
0
文件: __init__.py 项目: ghisvail/pyzo
    # Create main window, using the selected locale
    frame = MainWindow(None, appLocale)

    # Enter the main loop
    QtGui.qApp.exec_()


## Init

# List of names that are later overriden (in main.py)
editors = None # The editor stack instance
shells = None # The shell stack instance
main = None # The mainwindow
icon = None # The icon
parser = None # The source parser
status = None # The statusbar (or None)

# Get directories of interest
pyzoDir, appDataDir = getResourceDirs()

# Whether the config file should be saved
_saveConfigFile = True

# Create ssdf in module namespace, and fill it
config = ssdf.new()
loadConfig()

# Init default style name (set in main.restorePyzoState())
defaultQtStyleName = ''
示例#10
0
    # Create main window, using the selected locale
    MainWindow(None, appLocale)

    # Enter the main loop
    QtWidgets.qApp.exec_()


## Init

# List of names that are later overriden (in main.py)
editors = None  # The editor stack instance
shells = None  # The shell stack instance
main = None  # The mainwindow
icon = None  # The icon
parser = None  # The source parser
status = None  # The statusbar (or None)

# Get directories of interest
pyzoDir, appDataDir = getResourceDirs()

# Whether the config file should be saved
_saveConfigFile = True

# Create ssdf in module namespace, and fill it
config = ssdf.new()
loadConfig()

# Init default style name (set in main.restorePyzoState())
defaultQtStyleName = ''
示例#11
0
# List of names that are later overriden (in main.py)
pyzo.editors = None  # The editor stack instance
pyzo.shells = None  # The shell stack instance
pyzo.main = None  # The mainwindow
pyzo.icon = None  # The icon
pyzo.parser = None  # The source parser
pyzo.status = None  # The statusbar (or None)

# Get directories of interest
pyzo.pyzoDir, pyzo.appDataDir, pyzo.appConfigDir = getResourceDirs()

# Whether the config file should be saved
pyzo._saveConfigFile = True

# Create ssdf in module namespace, and fill it
pyzo.config = ssdf.new()
loadConfig()

try:
    # uses the fact that float("") raises ValueError to be NOP when qtscalefactor setting is not set
    os.environ["QT_SCREEN_SCALE_FACTORS"] = str(
        float(pyzo.config.settings.qtscalefactor))
except Exception:
    pass

# Create style dict and fill it
pyzo.themes = {}
loadThemes()
# Init default style name (set in main.restorePyzoState())
pyzo.defaultQtStyleName = ""