class ProjectMetadata(QWidget): """Project Metadata widget class""" def __init__(self, parent): super(ProjectMetadata, self).__init__() self._parent = parent vbox = QVBoxLayout(self) vbox.addWidget(QLabel(translations.TR_PROJECT_METADATA_RELATED)) self.txt_projects = QPlainTextEdit() vbox.addWidget(self.txt_projects) vbox.addWidget(QLabel(translations.TR_PROJECT_METADATA_TIP)) paths = '\n'.join(self._parent.project.related_projects) self.txt_projects.setPlainText(paths) self.txt_projects.setToolTip(translations.TR_PROJECT_PATH_PER_LINE)
class ProjectExecution(QWidget): def __init__(self, parent): super(ProjectExecution, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(translations.TR_PROJECT_MAIN_FILE), 0, 0) self.path = QLineEdit() self.path.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'main.py')) ui_tools.LineEditButton(self.path, self.path.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.path.setText(self._parent.project.main_file) self.path.setReadOnly(True) self.btnBrowse = QPushButton(QIcon( self.style().standardPixmap(self.style().SP_FileIcon)), '') grid.addWidget(self.path, 0, 1) grid.addWidget(self.btnBrowse, 0, 2) # this should be changed, and ALL pythonPath names to # python_custom_interpreter or something like that. this is NOT the # PYTHONPATH self.txtPythonInterpreter = QLineEdit() self.txtPythonInterpreter.setText(self._parent.project.python_exec) self.txtPythonInterpreter.setCompleter(QCompleter(('python', 'python2', 'python3', 'python.exe', 'pythonw.exe'))) self.btnPythonPath = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel( translations.TR_PROJECT_PYTHON_INTERPRETER), 1, 0) grid.addWidget(self.txtPythonInterpreter, 1, 1) grid.addWidget(self.btnPythonPath, 1, 2) grid.addWidget(QLabel(translations.TR_PROJECT_PYTHON_PATH), 2, 0) self.txtPythonPath = QPlainTextEdit() # TODO : better widget self.txtPythonPath.setPlainText(self._parent.project.python_path) self.txtPythonPath.setToolTip(translations.TR_PROJECT_PATH_PER_LINE) grid.addWidget(self.txtPythonPath, 2, 1) # Additional builtins/globals for pyflakes grid.addWidget(QLabel(translations.TR_PROJECT_BUILTINS), 3, 0) self.additional_builtins = QLineEdit() self.additional_builtins.setText( ' '.join(self._parent.project.additional_builtins)) self.additional_builtins.setToolTip( translations.TR_PROJECT_BUILTINS_TOOLTIP) grid.addWidget(self.additional_builtins, 3, 1) self.txtPreExec = QLineEdit() ui_tools.LineEditButton(self.txtPreExec, self.txtPreExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPreExec.setReadOnly(True) self.txtPreExec.setText(self._parent.project.pre_exec_script) self.txtPreExec.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh')) self.btnPreExec = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_PRE_EXEC), 4, 0) grid.addWidget(self.txtPreExec, 4, 1) grid.addWidget(self.btnPreExec, 4, 2) self.txtPostExec = QLineEdit() ui_tools.LineEditButton(self.txtPostExec, self.txtPostExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPostExec.setReadOnly(True) self.txtPostExec.setText(self._parent.project.post_exec_script) self.txtPostExec.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh')) self.btnPostExec = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_POST_EXEC), 5, 0) grid.addWidget(self.txtPostExec, 5, 1) grid.addWidget(self.btnPostExec, 5, 2) grid.addItem(QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Expanding), 6, 0) # Properties grid.addWidget(QLabel(translations.TR_PROJECT_PROPERTIES), 7, 0) self.txtParams = QLineEdit() self.txtParams.setToolTip(translations.TR_PROJECT_PARAMS_TOOLTIP) self.txtParams.setText(self._parent.project.program_params) self.txtParams.setPlaceholderText('verbose, debug, force') grid.addWidget(QLabel(translations.TR_PROJECT_PARAMS), 8, 0) grid.addWidget(self.txtParams, 8, 1) #Widgets for virtualenv properties self.txtVenvPath = QLineEdit() ui_tools.LineEditButton(self.txtVenvPath, self.txtVenvPath.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtVenvPath.setText(self._parent.project.venv) self._dir_completer = QCompleter() self._dir_completer.setModel(QDirModel(self._dir_completer)) self.txtVenvPath.setCompleter(self._dir_completer) self.txtVenvPath.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'virtualenv')) self.btnVenvPath = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_VIRTUALENV), 9, 0) grid.addWidget(self.txtVenvPath, 9, 1) grid.addWidget(self.btnVenvPath, 9, 2) self.connect(self.btnBrowse, SIGNAL("clicked()"), self.select_file) self.connect(self.btnPythonPath, SIGNAL("clicked()"), self._load_python_path) self.connect(self.btnVenvPath, SIGNAL("clicked()"), self._load_python_venv) self.connect(self.btnPreExec, SIGNAL("clicked()"), self.select_pre_exec_script) self.connect(self.btnPostExec, SIGNAL("clicked()"), self.select_post_exec_script) def _load_python_path(self): path = QFileDialog.getOpenFileName( translations.TR_PROJECT_SELECT_PYTHON_PATH) self.txtPythonInterpreter.setText(path) def _load_python_venv(self): venv = QFileDialog.getExistingDirectory( translations.TR_PROJECT_SELECT_VIRTUALENV) if sys.platform == 'win32': venv = os.path.join(venv, 'Scripts', 'python.exe') else: venv = os.path.join(venv, 'bin', 'python') #check if venv folder exists if not os.path.exists(venv): QMessageBox.information(self, translations.TR_PROJECT_SELECT_VIRTUALENV_MESSAGE_TITLE, translations.TR_PROJECT_SELECT_VIRTUALENV_MESSAGE_BODY) self.txtVenvPath.setText("") else: self.txtVenvPath.setText(venv) def select_file(self): fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_MAIN_FILE, self._parent.project.path, 'PY(*.py);;*(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.path.setText(fileName) def select_pre_exec_script(self): fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_PRE_SCRIPT, self._parent.project.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.txtPreExec.setText(fileName) def select_post_exec_script(self): fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_POST_SCRIPT, self._parent.project.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.txtPostExec.setText(fileName)
class ProjectExecution(QWidget): def __init__(self, parent): super(ProjectExecution, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(self.tr("Main File:")), 0, 0) self.path = QLineEdit() ui_tools.LineEditButton(self.path, self.path.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.path.setText(self._parent._item.mainFile) self.path.setReadOnly(True) self.btnBrowse = QPushButton(QIcon( self.style().standardPixmap(self.style().SP_FileIcon)), '') grid.addWidget(self.path, 0, 1) grid.addWidget(self.btnBrowse, 0, 2) # this should be changed, and ALL pythonPath names to # python_custom_interpreter or something like that. this is NOT the # PYTHONPATH self.txtPythonPath = QLineEdit() self.txtPythonPath.setText(self._parent._item.pythonPath) self.btnPythonPath = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Python Custom Interpreter:")), 1, 0) grid.addWidget(self.txtPythonPath, 1, 1) grid.addWidget(self.btnPythonPath, 1, 2) # THIS IS THE MODAFUCKA REAL PYTHONPATH BRO, YEAH !!! grid.addWidget(QLabel(self.tr("Custom PYTHONPATH:")), 2, 0) self.PYTHONPATH = QPlainTextEdit() # TODO : better widget self.PYTHONPATH.setPlainText(self._parent._item.PYTHONPATH) self.PYTHONPATH.setToolTip(self.tr("One path per line")) grid.addWidget(self.PYTHONPATH, 2, 1) # Additional builtins/globals for pyflakes grid.addWidget(QLabel(self.tr("Additional builtins/globals:")), 3, 0) self.additional_builtins = QLineEdit() self.additional_builtins.setText( ' '.join(self._parent._item.additional_builtins)) self.additional_builtins.setToolTip(self.tr( "Space-separated list of symbols that will be considered as " "builtin in every file")) grid.addWidget(self.additional_builtins, 3, 1) self.txtPreExec = QLineEdit() ui_tools.LineEditButton(self.txtPreExec, self.txtPreExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPreExec.setReadOnly(True) self.txtPreExec.setText(self._parent._item.preExecScript) self.btnPreExec = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Pre-exec Script:")), 4, 0) grid.addWidget(self.txtPreExec, 4, 1) grid.addWidget(self.btnPreExec, 4, 2) self.txtPostExec = QLineEdit() ui_tools.LineEditButton(self.txtPostExec, self.txtPostExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPostExec.setReadOnly(True) self.txtPostExec.setText(self._parent._item.postExecScript) self.btnPostExec = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Post-exec Script:")), 5, 0) grid.addWidget(self.txtPostExec, 5, 1) grid.addWidget(self.btnPostExec, 5, 2) grid.addItem(QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Expanding), 6, 0) # Properties grid.addWidget(QLabel(self.tr("Properties:")), 7, 0) self.txtParams = QLineEdit() self.txtParams.setToolTip( self.tr("Separate the params with commas (ie: help, verbose)")) self.txtParams.setText(self._parent._item.programParams) grid.addWidget(QLabel(self.tr("Params (comma separated):")), 8, 0) grid.addWidget(self.txtParams, 8, 1) #Widgets for virtualenv properties self.txtVenvPath = QLineEdit() ui_tools.LineEditButton(self.txtVenvPath, self.txtVenvPath.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtVenvPath.setText(self._parent._item.venv) self._dir_completer = QCompleter() self._dir_completer.setModel(QDirModel(self._dir_completer)) self.txtVenvPath.setCompleter(self._dir_completer) self.btnVenvPath = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Virtualenv Folder:")), 9, 0) grid.addWidget(self.txtVenvPath, 9, 1) grid.addWidget(self.btnVenvPath, 9, 2) self.connect(self.btnBrowse, SIGNAL("clicked()"), self.select_file) self.connect(self.btnPythonPath, SIGNAL("clicked()"), self._load_python_path) self.connect(self.btnVenvPath, SIGNAL("clicked()"), self._load_python_venv) self.connect(self.btnPreExec, SIGNAL("clicked()"), self.select_pre_exec_script) self.connect(self.btnPostExec, SIGNAL("clicked()"), self.select_post_exec_script) def _load_python_path(self): path = QFileDialog.getOpenFileName( self, self.tr("Select Python Path")) self.txtPythonPath.setText(path) def _load_python_venv(self): venv = QFileDialog.getExistingDirectory( self, self.tr("Select Virtualenv Folder")) if sys.platform == 'win32': venv = os.path.join(venv, 'Scripts', 'python.exe') else: venv = os.path.join(venv, 'bin', 'python') #check if venv folder exists if not os.path.exists(venv): QMessageBox.information(self, self.tr("Virtualenv Folder"), self.tr("This is not a valid Virtualenv Folder")) self.txtVenvPath.setText("") else: self.txtVenvPath.setText(venv) def select_file(self): fileName = QFileDialog.getOpenFileName( self, self.tr("Select Main File"), self._parent._item.path, '(*.py);;(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.path.setText(fileName) def select_pre_exec_script(self): fileName = QFileDialog.getOpenFileName( self, self.tr("Select Pre Execution Script File"), self._parent._item.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.txtPreExec.setText(fileName) def select_post_exec_script(self): fileName = QFileDialog.getOpenFileName( self, self.tr("Select Post Execution Script File"), self._parent._item.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.txtPostExec.setText(fileName)
class ProjectExecution(QWidget): def __init__(self, parent): super(ProjectExecution, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(self.tr("Main File:")), 0, 0) self.path = QLineEdit() ui_tools.LineEditButton( self.path, self.path.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.path.setText(self._parent._item.mainFile) self.path.setReadOnly(True) self.btnBrowse = QPushButton( QIcon(self.style().standardPixmap(self.style().SP_FileIcon)), '') grid.addWidget(self.path, 0, 1) grid.addWidget(self.btnBrowse, 0, 2) # this should be changed, and ALL pythonPath names to # python_custom_interpreter or something like that. this is NOT the # PYTHONPATH self.txtPythonPath = QLineEdit() self.txtPythonPath.setText(self._parent._item.pythonPath) self.btnPythonPath = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Python Custom Interpreter:")), 1, 0) grid.addWidget(self.txtPythonPath, 1, 1) grid.addWidget(self.btnPythonPath, 1, 2) # THIS IS THE MODAFUCKA REAL PYTHONPATH BRO, YEAH !!! grid.addWidget(QLabel(self.tr("Custom PYTHONPATH:")), 2, 0) self.PYTHONPATH = QPlainTextEdit() # TODO : better widget self.PYTHONPATH.setPlainText(self._parent._item.PYTHONPATH) self.PYTHONPATH.setToolTip(self.tr("One path per line")) grid.addWidget(self.PYTHONPATH, 2, 1) self.txtPreExec = QLineEdit() ui_tools.LineEditButton( self.txtPreExec, self.txtPreExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPreExec.setReadOnly(True) self.txtPreExec.setText(self._parent._item.preExecScript) self.btnPreExec = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Pre-exec Script:")), 3, 0) grid.addWidget(self.txtPreExec, 3, 1) grid.addWidget(self.btnPreExec, 3, 2) self.txtPostExec = QLineEdit() ui_tools.LineEditButton( self.txtPostExec, self.txtPostExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPostExec.setReadOnly(True) self.txtPostExec.setText(self._parent._item.postExecScript) self.btnPostExec = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Post-exec Script:")), 4, 0) grid.addWidget(self.txtPostExec, 4, 1) grid.addWidget(self.btnPostExec, 4, 2) grid.addItem( QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Expanding), 5, 0) # Properties grid.addWidget(QLabel(self.tr("Properties:")), 6, 0) self.txtParams = QLineEdit() self.txtParams.setToolTip( self.tr("Separate the params with commas (ie: help, verbose)")) self.txtParams.setText(self._parent._item.programParams) grid.addWidget(QLabel(self.tr("Params (comma separated):")), 7, 0) grid.addWidget(self.txtParams, 7, 1) #Widgets for virtualenv properties self.txtVenvPath = QLineEdit() ui_tools.LineEditButton( self.txtVenvPath, self.txtVenvPath.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtVenvPath.setText(self._parent._item.venv) self.txtVenvPath.setReadOnly(True) self.btnVenvPath = QPushButton(QIcon(resources.IMAGES['open']), '') grid.addWidget(QLabel(self.tr("Virtualenv Folder:")), 8, 0) grid.addWidget(self.txtVenvPath, 8, 1) grid.addWidget(self.btnVenvPath, 8, 2) self.connect(self.btnBrowse, SIGNAL("clicked()"), self.select_file) self.connect(self.btnPythonPath, SIGNAL("clicked()"), self._load_python_path) self.connect(self.btnVenvPath, SIGNAL("clicked()"), self._load_python_venv) self.connect(self.btnPreExec, SIGNAL("clicked()"), self.select_pre_exec_script) self.connect(self.btnPostExec, SIGNAL("clicked()"), self.select_post_exec_script) def _load_python_path(self): path = QFileDialog.getOpenFileName(self, self.tr("Select Python Path")) self.txtPythonPath.setText(path) def _load_python_venv(self): venv = QFileDialog.getExistingDirectory( self, self.tr("Select Virtualenv Folder")) if sys.platform == 'win32': venv = os.path.join(venv, 'Scripts', 'python.exe') else: venv = os.path.join(venv, 'bin', 'python') #check if venv folder exists if not os.path.exists(venv): QMessageBox.information( self, self.tr("Virtualenv Folder"), self.tr("This is not a valid Virtualenv Folder")) self.txtVenvPath.setText("") else: self.txtVenvPath.setText(venv) def select_file(self): fileName = QFileDialog.getOpenFileName(self, self.tr("Select Main File"), self._parent._item.path, '(*.py);;(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.path.setText(fileName) def select_pre_exec_script(self): fileName = QFileDialog.getOpenFileName( self, self.tr("Select Pre Execution Script File"), self._parent._item.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.txtPreExec.setText(fileName) def select_post_exec_script(self): fileName = QFileDialog.getOpenFileName( self, self.tr("Select Post Execution Script File"), self._parent._item.path, '(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent._item.path, fileName) self.txtPostExec.setText(fileName)
class ProjectExecution(QWidget): """Project Execution widget class""" def __init__(self, parent): super(ProjectExecution, self).__init__() self._parent = parent grid = QGridLayout(self) grid.addWidget(QLabel(translations.TR_PROJECT_MAIN_FILE), 0, 0) self.path = QLineEdit() self.path.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'main.py')) ui_tools.LineEditButton( self.path, self.path.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.path.setText(self._parent.project.main_file) self.path.setReadOnly(True) self.btnBrowse = QPushButton( QIcon(self.style().standardPixmap(self.style().SP_FileIcon)), '') grid.addWidget(self.path, 0, 1) grid.addWidget(self.btnBrowse, 0, 2) # this should be changed, and ALL pythonPath names to # python_custom_interpreter or something like that. this is NOT the # PYTHONPATH self.txtPythonInterpreter = QLineEdit() self.txtPythonInterpreter.setText(self._parent.project.python_exec) self.txtPythonInterpreter.setCompleter( QCompleter( ('python', 'python2', 'python3', 'python.exe', 'pythonw.exe'))) self.txtPythonInterpreter.setPlaceholderText("python") self.btnPythonPath = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_PYTHON_INTERPRETER), 1, 0) grid.addWidget(self.txtPythonInterpreter, 1, 1) grid.addWidget(self.btnPythonPath, 1, 2) grid.addWidget(QLabel(translations.TR_PROJECT_PYTHON_PATH), 2, 0) self.txtPythonPath = QPlainTextEdit() # TODO : better widget self.txtPythonPath.setPlainText(self._parent.project.python_path) self.txtPythonPath.setToolTip(translations.TR_PROJECT_PATH_PER_LINE) grid.addWidget(self.txtPythonPath, 2, 1) # Additional builtins/globals for pyflakes grid.addWidget(QLabel(translations.TR_PROJECT_BUILTINS), 3, 0) self.additional_builtins = QLineEdit() self.additional_builtins.setText(' '.join( self._parent.project.additional_builtins)) self.additional_builtins.setToolTip( translations.TR_PROJECT_BUILTINS_TOOLTIP) grid.addWidget(self.additional_builtins, 3, 1) self.txtPreExec = QLineEdit() ui_tools.LineEditButton( self.txtPreExec, self.txtPreExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPreExec.setReadOnly(True) self.txtPreExec.setText(self._parent.project.pre_exec_script) self.txtPreExec.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh')) self.btnPreExec = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_PRE_EXEC), 4, 0) grid.addWidget(self.txtPreExec, 4, 1) grid.addWidget(self.btnPreExec, 4, 2) self.txtPostExec = QLineEdit() ui_tools.LineEditButton( self.txtPostExec, self.txtPostExec.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtPostExec.setReadOnly(True) self.txtPostExec.setText(self._parent.project.post_exec_script) self.txtPostExec.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh')) self.btnPostExec = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_POST_EXEC), 5, 0) grid.addWidget(self.txtPostExec, 5, 1) grid.addWidget(self.btnPostExec, 5, 2) grid.addItem( QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Expanding), 6, 0) # Properties grid.addWidget(QLabel(translations.TR_PROJECT_PROPERTIES), 7, 0) self.txtParams = QLineEdit() self.txtParams.setToolTip(translations.TR_PROJECT_PARAMS_TOOLTIP) self.txtParams.setText(self._parent.project.program_params) self.txtParams.setPlaceholderText('verbose, debug, force') grid.addWidget(QLabel(translations.TR_PROJECT_PARAMS), 8, 0) grid.addWidget(self.txtParams, 8, 1) #Widgets for virtualenv properties self.txtVenvPath = QLineEdit() ui_tools.LineEditButton( self.txtVenvPath, self.txtVenvPath.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.txtVenvPath.setText(self._parent.project.venv) self._dir_completer = QCompleter() self._dir_completer.setModel(QDirModel(self._dir_completer)) self.txtVenvPath.setCompleter(self._dir_completer) self.txtVenvPath.setPlaceholderText( os.path.join(os.path.expanduser("~"), 'path', 'to', 'virtualenv')) self.btnVenvPath = QPushButton(QIcon(":img/open"), '') grid.addWidget(QLabel(translations.TR_PROJECT_VIRTUALENV), 9, 0) grid.addWidget(self.txtVenvPath, 9, 1) grid.addWidget(self.btnVenvPath, 9, 2) self.connect(self.btnBrowse, SIGNAL("clicked()"), self.select_file) self.connect(self.btnPythonPath, SIGNAL("clicked()"), self._load_python_path) self.connect(self.btnVenvPath, SIGNAL("clicked()"), self._load_python_venv) self.connect(self.btnPreExec, SIGNAL("clicked()"), self.select_pre_exec_script) self.connect(self.btnPostExec, SIGNAL("clicked()"), self.select_post_exec_script) def _load_python_path(self): """Ask the user a python path and set its value""" path = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_PYTHON_PATH) self.txtPythonInterpreter.setText(path) def _load_python_venv(self): """Ask the user a python venv and set its value""" venv = QFileDialog.getExistingDirectory( self, translations.TR_PROJECT_SELECT_VIRTUALENV) if sys.platform == 'win32': venv = os.path.join(venv, 'Scripts', 'python.exe') else: venv = os.path.join(venv, 'bin', 'python') #check if venv folder exists if not os.path.exists(venv): QMessageBox.information( self, translations.TR_PROJECT_SELECT_VIRTUALENV_MESSAGE_TITLE, translations.TR_PROJECT_SELECT_VIRTUALENV_MESSAGE_BODY) self.txtVenvPath.setText("") else: self.txtVenvPath.setText(venv) def select_file(self): """Ask the user a python main file and set its value""" fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_MAIN_FILE, self._parent.project.path, 'Python PY(*.py);;Python Bytecode(*.py[codw]);;*(*.*)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.path.setText(fileName) def select_pre_exec_script(self): """Ask the user a python pre-exec script and set its value""" fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_PRE_SCRIPT, self._parent.project.path, '*(*.*);;Bash(*.sh);;Python PY(*.py);;Python Bytecode(*.py[codw]);;' 'Bat(*.bat);;Cmd(*.cmd);;Exe(*.exe);;Bin(*.bin);;App(*.app)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.txtPreExec.setText(fileName) def select_post_exec_script(self): """Ask the user a python post-exec script and set its value""" fileName = QFileDialog.getOpenFileName( self, translations.TR_PROJECT_SELECT_POST_SCRIPT, self._parent.project.path, '*(*.*);;Bash(*.sh);;Python PY(*.py);;Python Bytecode(*.py[codw]);;' 'Bat(*.bat);;Cmd(*.cmd);;Exe(*.exe);;Bin(*.bin);;App(*.app)') if fileName != '': fileName = file_manager.convert_to_relative( self._parent.project.path, fileName) self.txtPostExec.setText(fileName)