Skip to content
Permalink
Browse files

[sextante] Improvements in commander

  • Loading branch information
volaya committed Apr 26, 2013
1 parent 4065d57 commit c635578d9fc5a8b2783505ee666e961c1a107407
@@ -54,12 +54,13 @@ def __init__(self, iface):
Sextante.setInterface(iface)
Sextante.setPlugin(self)

def initGui(self):
def initGui(self):
self.commander = None
self.toolbox = SextanteToolbox(self.iface)
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
Sextante.addAlgListListener(self.toolbox)

self.menu = QMenu(self.iface.mainWindow())
self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))

@@ -100,7 +101,7 @@ def initGui(self):
self.iface.mainWindow())
self.commanderAction.triggered.connect(self.openCommander)
self.menu.addAction(self.commanderAction)
self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")
self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")

def unload(self):
self.toolbox.setVisible(False)
@@ -112,10 +113,13 @@ def unload(self):

self.iface.unregisterMainWindowAction(self.commanderAction)

def openCommander(self):
dlg = CommanderWindow(self.iface.mainWindow(), self.iface.mapCanvas())
dlg.show()
dlg.exec_()
def openCommander(self):
if self.commander is None:
self.commander = CommanderWindow(self.iface.mainWindow(), self.iface.mapCanvas())
Sextante.addAlgListListener(self.commander)
self.commander.prepareGui()
self.commander.show()
#dlg.exec_()


def openToolbox(self):
@@ -42,8 +42,8 @@ class CommanderWindow(QtGui.QDialog):
def __init__(self, parent, canvas):
self.canvas = canvas
QtGui.QDialog.__init__(self, parent, Qt.FramelessWindowHint)
self.setModal(True)
self.commands = imp.load_source("commands", self.commandsFile())
#self.setModal(True)
self.commands = imp.load_source("commands", self.commandsFile())
self.initGui()

def commandsFolder(self):
@@ -65,29 +65,14 @@ def commandsFile(self):
out.close()
return f

def algsListHasChanged(self):
self.fillCombo()

def initGui(self):
self.combo= ExtendedComboBox()
#add algorithm
for providerName in Sextante.algs.keys():
provider = Sextante.algs[providerName]
algs = provider.values()
for alg in algs:
self.combo.addItem("SEXTANTE algorithm: " + alg.name)
#add functions
for command in dir(self.commands):
if isinstance(self.commands.__dict__.get(command), types.FunctionType):
self.combo.addItem("Command: " + command);
#add menu entries
menuActions = []
actions = Sextante.getInterface().mainWindow().menuBar().actions()
for action in actions:
menuActions.extend(self.getActions(action))
for action in menuActions:
self.combo.addItem("Menu action: " + unicode(action.text()))
self.combo= ExtendedComboBox()
self.fillCombo()

self.combo.setEditable(True)
self.combo.setEditText("")
self.label = QtGui.QLabel("Enter command:")
self.errorLabel = QtGui.QLabel("Enter command:")
self.vlayout = QtGui.QVBoxLayout()
@@ -104,6 +89,31 @@ def initGui(self):
self.vlayout.addSpacerItem(QtGui.QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding));
self.setLayout(self.vlayout)
self.combo.lineEdit().returnPressed.connect(self.run)
self.prepareGui()

def fillCombo(self):
self.combo.clear()
#add algorithms
for providerName in Sextante.algs.keys():
provider = Sextante.algs[providerName]
algs = provider.values()
for alg in algs:
self.combo.addItem("SEXTANTE algorithm: " + alg.name)
#add functions
for command in dir(self.commands):
if isinstance(self.commands.__dict__.get(command), types.FunctionType):
self.combo.addItem("Command: " + command);
#add menu entries
menuActions = []
actions = Sextante.getInterface().mainWindow().menuBar().actions()
for action in actions:
menuActions.extend(self.getActions(action))
for action in menuActions:
self.combo.addItem("Menu action: " + unicode(action.text()))


def prepareGui(self):
self.combo.setEditText("")
self.combo.setMaximumSize(QtCore.QSize(self.canvas.rect().width() - 2 * OFFSET, ITEMHEIGHT))
self.combo.view().setStyleSheet("min-height: 150px")
self.combo.setFocus(Qt.OtherFocusReason)
@@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from sextante.gui import TestTools

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -26,6 +25,7 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.gui import TestTools
from sextante.core.SextanteLog import SextanteLog
from sextante.ui.ui_DlgHistory import Ui_DlgHistory

0 comments on commit c635578

Please sign in to comment.
You can’t perform that action at this time.