本文整理汇总了Python中spyderlib.qt.QtGui.QListWidget.currentItem方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.currentItem方法的具体用法?Python QListWidget.currentItem怎么用?Python QListWidget.currentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QListWidget
的用法示例。
在下文中一共展示了QListWidget.currentItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PathManager
# 需要导入模块: from spyderlib.qt.QtGui import QListWidget [as 别名]
# 或者: from spyderlib.qt.QtGui.QListWidget import currentItem [as 别名]
#.........这里部分代码省略.........
def synchronize(self):
"""
Synchronize Spyder's path list with PYTHONPATH environment variable
Only apply to: current user, on Windows platforms
"""
answer = QMessageBox.question(self, _("Synchronize"),
_("This will synchronize Spyder's path list with "
"<b>PYTHONPATH</b> environment variable for current user, "
"allowing you to run your Python modules outside Spyder "
"without having to configure sys.path. "
"<br>Do you want to clear contents of PYTHONPATH before "
"adding Spyder's path list?"),
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
if answer == QMessageBox.Cancel:
return
elif answer == QMessageBox.Yes:
remove = True
else:
remove = False
from spyderlib.utils.environ import (get_user_env, set_user_env,
listdict2envdict)
env = get_user_env()
if remove:
ppath = self.pathlist+self.ro_pathlist
else:
ppath = env.get('PYTHONPATH', [])
if not isinstance(ppath, list):
ppath = [ppath]
ppath = [path for path in ppath
if path not in (self.pathlist+self.ro_pathlist)]
ppath.extend(self.pathlist+self.ro_pathlist)
env['PYTHONPATH'] = ppath
set_user_env( listdict2envdict(env), parent=self )
def get_path_list(self):
"""Return path list (does not include the read-only path list)"""
return self.pathlist
def update_list(self):
"""Update path list"""
self.listwidget.clear()
for name in self.pathlist+self.ro_pathlist:
item = QListWidgetItem(name)
item.setIcon(get_std_icon('DirClosedIcon'))
if name in self.ro_pathlist:
item.setFlags(Qt.NoItemFlags)
self.listwidget.addItem(item)
self.refresh()
def refresh(self, row=None):
"""Refresh widget"""
for widget in self.selection_widgets:
widget.setEnabled(self.listwidget.currentItem() is not None)
not_empty = self.listwidget.count() > 0
if self.sync_button is not None:
self.sync_button.setEnabled(not_empty)
def move_to(self, absolute=None, relative=None):
index = self.listwidget.currentRow()
if absolute is not None:
if absolute:
new_index = len(self.pathlist)-1
else:
new_index = 0
else:
new_index = index + relative
new_index = max(0, min(len(self.pathlist)-1, new_index))
path = self.pathlist.pop(index)
self.pathlist.insert(new_index, path)
self.update_list()
self.listwidget.setCurrentRow(new_index)
def remove_path(self):
answer = QMessageBox.warning(self, _("Remove path"),
_("Do you really want to remove selected path?"),
QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
self.pathlist.pop(self.listwidget.currentRow())
self.update_list()
def add_path(self):
self.emit(SIGNAL('redirect_stdio(bool)'), False)
directory = getexistingdirectory(self, _("Select directory"),
self.last_path)
self.emit(SIGNAL('redirect_stdio(bool)'), True)
if directory:
directory = osp.abspath(directory)
self.last_path = directory
if directory in self.pathlist:
answer = QMessageBox.question(self, _("Add path"),
_("This directory is already included in Spyder path "
"list.<br>Do you want to move it to the top of "
"the list?"),
QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
self.pathlist.remove(directory)
else:
return
self.pathlist.insert(0, directory)
self.update_list()