本文整理汇总了Python中spyderlib.qt.QtGui.QListWidget类的典型用法代码示例。如果您正苦于以下问题:Python QListWidget类的具体用法?Python QListWidget怎么用?Python QListWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QListWidget类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
def keyPressEvent(self, event):
text, key = event.text(), event.key()
alt = event.modifiers() & Qt.AltModifier
shift = event.modifiers() & Qt.ShiftModifier
ctrl = event.modifiers() & Qt.ControlModifier
modifier = shift or ctrl or alt
if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
or key == Qt.Key_Tab:
self.item_selected()
elif key in (Qt.Key_Return, Qt.Key_Enter,
Qt.Key_Left, Qt.Key_Right) or text in ('.', ':'):
self.hide()
self.textedit.keyPressEvent(event)
elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
Qt.Key_Home, Qt.Key_End,
Qt.Key_CapsLock) and not modifier:
QListWidget.keyPressEvent(self, event)
elif len(text) or key == Qt.Key_Backspace:
self.textedit.keyPressEvent(event)
self.update_current()
elif modifier:
self.textedit.keyPressEvent(event)
else:
self.hide()
QListWidget.keyPressEvent(self, event)
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:25,代码来源:base.py
示例2: __init__
def __init__(self, parent, ancestor):
QListWidget.__init__(self, ancestor)
self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint)
self.textedit = parent
self.completion_list = None
self.case_sensitive = False
self.enter_select = None
self.hide()
self.connect(self, SIGNAL("itemActivated(QListWidgetItem*)"), self.item_selected)
开发者ID:sys-bio,项目名称:Spyderplugin_ratelaws,代码行数:9,代码来源:base.py
示例3: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.contents_widget = QListWidget()
self.button_reset = QPushButton(_('Reset to defaults'))
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
# Widgets setup
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(ima.icon('configure'))
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
self.contents_widget.setCurrentRow(0)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addWidget(self.button_reset)
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
# Signals and slots
self.button_reset.clicked.connect(self.main.reset_spyder)
self.pages_widget.currentChanged.connect(self.current_page_changed)
self.contents_widget.currentRowChanged.connect(
self.pages_widget.setCurrentIndex)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
bbox.clicked.connect(self.button_clicked)
# Ensures that the config is present on spyder first run
CONF.set('main', 'interface_language', load_lang_conf())
开发者ID:gyenney,项目名称:Tools,代码行数:53,代码来源:configdialog.py
示例4: __init__
def __init__(self, parent=None, pathlist=None, ro_pathlist=None, sync=True):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
assert isinstance(pathlist, list)
self.pathlist = pathlist
if ro_pathlist is None:
ro_pathlist = []
self.ro_pathlist = ro_pathlist
self.last_path = getcwd()
self.setWindowTitle(_("PYTHONPATH manager"))
self.setWindowIcon(get_icon('pythonpath.png'))
self.resize(500, 300)
self.selection_widgets = []
layout = QVBoxLayout()
self.setLayout(layout)
top_layout = QHBoxLayout()
layout.addLayout(top_layout)
self.toolbar_widgets1 = self.setup_top_toolbar(top_layout)
self.listwidget = QListWidget(self)
self.connect(self.listwidget, SIGNAL("currentRowChanged(int)"),
self.refresh)
layout.addWidget(self.listwidget)
bottom_layout = QHBoxLayout()
layout.addLayout(bottom_layout)
self.sync_button = None
self.toolbar_widgets2 = self.setup_bottom_toolbar(bottom_layout, sync)
# Buttons configuration
bbox = QDialogButtonBox(QDialogButtonBox.Close)
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
bottom_layout.addWidget(bbox)
self.update_list()
self.refresh()
开发者ID:jromang,项目名称:spyderlib,代码行数:47,代码来源:pathmanager.py
示例5: __init__
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.contents_widget = QListWidget()
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply
|QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
self.button_clicked)
self.pages_widget = QStackedWidget()
self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
self.current_page_changed)
self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
self.pages_widget.setCurrentIndex)
self.contents_widget.setCurrentRow(0)
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
self.setWindowTitle(_("Preferences"))
self.setWindowIcon(get_icon("configure.png"))
开发者ID:jromang,项目名称:spyderlib,代码行数:45,代码来源:configdialog.py
示例6: hide
def hide(self):
QListWidget.hide(self)
self.textedit.setFocus()
开发者ID:dhirschfeld,项目名称:spyderlib,代码行数:3,代码来源:base.py
示例7: __init__
def __init__(self, parent, tabs, data):
QDialog.__init__(self, parent)
# Variables
self.tabs = tabs # Editor stack tabs
self.data = data # Editor data
self.mode = self.FILE_MODE # By default start in this mode
self.initial_cursors = None # {fullpath: QCursor}
self.initial_path = None # Fullpath of initial active editor
self.initial_editor = None # Initial active editor
self.line_number = None # Selected line number in filer
help_text = _("Press <b>Enter</b> to switch files or <b>Esc</b> to "
"cancel.<br><br>Type to filter filenames.<br><br>"
"Use <b>:number</b> to go to a line, e.g. "
"<b><code>main:42</code></b><br>"
"Use <b>@symbol_text</b> to go to a symbol, e.g. "
"<b><code>@init</code></b>"
"<br><br> Press <b>Ctrl+W</b> to close current tab.<br>")
# Either allow searching for a line number or a symbol but not both
regex = QRegExp("([A-Za-z0-9_]{0,100}@[A-Za-z0-9_]{0,100})|" +
"([A-Za-z]{0,100}:{0,1}[0-9]{0,100})")
# Widgets
self.edit = QLineEdit(self)
self.help = HelperToolButton()
self.list = QListWidget(self)
self.filter = KeyPressFilter()
regex_validator = QRegExpValidator(regex, self.edit)
# Widgets setup
self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
self.setWindowOpacity(0.95)
self.edit.installEventFilter(self.filter)
self.edit.setValidator(regex_validator)
self.help.setToolTip(help_text)
self.list.setItemDelegate(HTMLDelegate(self))
# Layout
edit_layout = QHBoxLayout()
edit_layout.addWidget(self.edit)
edit_layout.addWidget(self.help)
layout = QVBoxLayout()
layout.addLayout(edit_layout)
layout.addWidget(self.list)
self.setLayout(layout)
# Signals
self.rejected.connect(self.restore_initial_state)
self.filter.sig_up_key_pressed.connect(self.previous_row)
self.filter.sig_down_key_pressed.connect(self.next_row)
self.edit.returnPressed.connect(self.accept)
self.edit.textChanged.connect(self.setup)
self.list.itemSelectionChanged.connect(self.item_selection_changed)
self.list.clicked.connect(self.edit.setFocus)
# Setup
self.save_initial_state()
self.set_dialog_position()
self.setup()
开发者ID:ming-hai,项目名称:spyder,代码行数:61,代码来源:file_switcher.py
示例8: FileSwitcher
class FileSwitcher(QDialog):
"""A Sublime-like file switcher."""
sig_goto_file = Signal(int)
sig_close_file = Signal(int)
# Constants that define the mode in which the list widget is working
# FILE_MODE is for a list of files, SYMBOL_MODE if for a list of symbols
# in a given file when using the '@' symbol.
FILE_MODE, SYMBOL_MODE = [1, 2]
def __init__(self, parent, tabs, data):
QDialog.__init__(self, parent)
# Variables
self.tabs = tabs # Editor stack tabs
self.data = data # Editor data
self.mode = self.FILE_MODE # By default start in this mode
self.initial_cursors = None # {fullpath: QCursor}
self.initial_path = None # Fullpath of initial active editor
self.initial_editor = None # Initial active editor
self.line_number = None # Selected line number in filer
help_text = _("Press <b>Enter</b> to switch files or <b>Esc</b> to "
"cancel.<br><br>Type to filter filenames.<br><br>"
"Use <b>:number</b> to go to a line, e.g. "
"<b><code>main:42</code></b><br>"
"Use <b>@symbol_text</b> to go to a symbol, e.g. "
"<b><code>@init</code></b>"
"<br><br> Press <b>Ctrl+W</b> to close current tab.<br>")
# Either allow searching for a line number or a symbol but not both
regex = QRegExp("([A-Za-z0-9_]{0,100}@[A-Za-z0-9_]{0,100})|" +
"([A-Za-z]{0,100}:{0,1}[0-9]{0,100})")
# Widgets
self.edit = QLineEdit(self)
self.help = HelperToolButton()
self.list = QListWidget(self)
self.filter = KeyPressFilter()
regex_validator = QRegExpValidator(regex, self.edit)
# Widgets setup
self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
self.setWindowOpacity(0.95)
self.edit.installEventFilter(self.filter)
self.edit.setValidator(regex_validator)
self.help.setToolTip(help_text)
self.list.setItemDelegate(HTMLDelegate(self))
# Layout
edit_layout = QHBoxLayout()
edit_layout.addWidget(self.edit)
edit_layout.addWidget(self.help)
layout = QVBoxLayout()
layout.addLayout(edit_layout)
layout.addWidget(self.list)
self.setLayout(layout)
# Signals
self.rejected.connect(self.restore_initial_state)
self.filter.sig_up_key_pressed.connect(self.previous_row)
self.filter.sig_down_key_pressed.connect(self.next_row)
self.edit.returnPressed.connect(self.accept)
self.edit.textChanged.connect(self.setup)
self.list.itemSelectionChanged.connect(self.item_selection_changed)
self.list.clicked.connect(self.edit.setFocus)
# Setup
self.save_initial_state()
self.set_dialog_position()
self.setup()
# --- Properties
@property
def editors(self):
return [self.tabs.widget(index) for index in range(self.tabs.count())]
@property
def line_count(self):
return [editor.get_line_count() for editor in self.editors]
@property
def save_status(self):
return [getattr(td, 'newly_created', False) for td in self.data]
@property
def paths(self):
return [getattr(td, 'filename', None) for td in self.data]
@property
def filenames(self):
return [self.tabs.tabText(index) for index in range(self.tabs.count())]
@property
def current_path(self):
return self.paths_by_editor[self.get_editor()]
@property
def paths_by_editor(self):
return dict(zip(self.editors, self.paths))
#.........这里部分代码省略.........
开发者ID:ming-hai,项目名称:spyder,代码行数:101,代码来源:file_switcher.py
示例9: ConfigDialog
class ConfigDialog(QDialog):
"""Spyder configuration ('Preferences') dialog box"""
# Signals
check_settings = Signal()
size_change = Signal(QSize)
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.main = parent
# Widgets
self.pages_widget = QStackedWidget()
self.contents_widget = QListWidget()
self.button_reset = QPushButton(_('Reset to defaults'))
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
# Widgets setup
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(ima.icon('configure'))
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
self.contents_widget.setCurrentRow(0)
# Layout
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addWidget(self.button_reset)
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
# Signals and slots
self.button_reset.clicked.connect(self.main.reset_spyder)
self.pages_widget.currentChanged.connect(self.current_page_changed)
self.contents_widget.currentRowChanged.connect(
self.pages_widget.setCurrentIndex)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
bbox.clicked.connect(self.button_clicked)
# Ensures that the config is present on spyder first run
CONF.set('main', 'interface_language', load_lang_conf())
def get_current_index(self):
"""Return current page index"""
return self.contents_widget.currentRow()
def set_current_index(self, index):
"""Set current page index"""
self.contents_widget.setCurrentRow(index)
def get_page(self, index=None):
"""Return page widget"""
if index is None:
widget = self.pages_widget.currentWidget()
else:
widget = self.pages_widget.widget(index)
return widget.widget()
@Slot()
def accept(self):
"""Reimplement Qt method"""
for index in range(self.pages_widget.count()):
configpage = self.get_page(index)
if not configpage.is_valid():
return
configpage.apply_changes()
QDialog.accept(self)
def button_clicked(self, button):
if button is self.apply_btn:
# Apply button was clicked
configpage = self.get_page()
if not configpage.is_valid():
return
configpage.apply_changes()
def current_page_changed(self, index):
widget = self.get_page(index)
self.apply_btn.setVisible(widget.apply_callback is not None)
self.apply_btn.setEnabled(widget.is_modified)
#.........这里部分代码省略.........
开发者ID:gyenney,项目名称:Tools,代码行数:101,代码来源:configdialog.py
示例10: PathManager
class PathManager(QDialog):
def __init__(self, parent=None, pathlist=None, ro_pathlist=None, sync=True):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
assert isinstance(pathlist, list)
self.pathlist = pathlist
if ro_pathlist is None:
ro_pathlist = []
self.ro_pathlist = ro_pathlist
self.last_path = getcwd()
self.setWindowTitle(_("PYTHONPATH manager"))
self.setWindowIcon(get_icon('pythonpath.png'))
self.resize(500, 300)
self.selection_widgets = []
layout = QVBoxLayout()
self.setLayout(layout)
top_layout = QHBoxLayout()
layout.addLayout(top_layout)
self.toolbar_widgets1 = self.setup_top_toolbar(top_layout)
self.listwidget = QListWidget(self)
self.connect(self.listwidget, SIGNAL("currentRowChanged(int)"),
self.refresh)
layout.addWidget(self.listwidget)
bottom_layout = QHBoxLayout()
layout.addLayout(bottom_layout)
self.sync_button = None
self.toolbar_widgets2 = self.setup_bottom_toolbar(bottom_layout, sync)
# Buttons configuration
bbox = QDialogButtonBox(QDialogButtonBox.Close)
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
bottom_layout.addWidget(bbox)
self.update_list()
self.refresh()
def _add_widgets_to_layout(self, layout, widgets):
layout.setAlignment(Qt.AlignLeft)
for widget in widgets:
layout.addWidget(widget)
def setup_top_toolbar(self, layout):
toolbar = []
movetop_button = create_toolbutton(self,
text=_("Move to top"),
icon=get_icon('2uparrow.png'),
triggered=lambda: self.move_to(absolute=0),
text_beside_icon=True)
toolbar.append(movetop_button)
moveup_button = create_toolbutton(self,
text=_("Move up"),
icon=get_icon('1uparrow.png'),
triggered=lambda: self.move_to(relative=-1),
text_beside_icon=True)
toolbar.append(moveup_button)
movedown_button = create_toolbutton(self,
text=_("Move down"),
icon=get_icon('1downarrow.png'),
triggered=lambda: self.move_to(relative=1),
text_beside_icon=True)
toolbar.append(movedown_button)
movebottom_button = create_toolbutton(self,
text=_("Move to bottom"),
icon=get_icon('2downarrow.png'),
triggered=lambda: self.move_to(absolute=1),
text_beside_icon=True)
toolbar.append(movebottom_button)
self.selection_widgets.extend(toolbar)
self._add_widgets_to_layout(layout, toolbar)
return toolbar
def setup_bottom_toolbar(self, layout, sync=True):
toolbar = []
add_button = create_toolbutton(self, text=_("Add path"),
icon=get_icon('edit_add.png'),
triggered=self.add_path,
text_beside_icon=True)
toolbar.append(add_button)
remove_button = create_toolbutton(self, text=_("Remove path"),
icon=get_icon('edit_remove.png'),
triggered=self.remove_path,
text_beside_icon=True)
toolbar.append(remove_button)
self.selection_widgets.append(remove_button)
self._add_widgets_to_layout(layout, toolbar)
layout.addStretch(1)
if os.name == 'nt' and sync:
#.........这里部分代码省略.........
开发者ID:jromang,项目名称:spyderlib,代码行数:101,代码来源:pathmanager.py
示例11: ConfigDialog
class ConfigDialog(QDialog):
"""Spyder configuration ('Preferences') dialog box"""
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.contents_widget = QListWidget()
self.contents_widget.setMovement(QListView.Static)
self.contents_widget.setSpacing(1)
bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply
|QDialogButtonBox.Cancel)
self.apply_btn = bbox.button(QDialogButtonBox.Apply)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
self.button_clicked)
self.pages_widget = QStackedWidget()
self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
self.current_page_changed)
self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
self.pages_widget.setCurrentIndex)
self.contents_widget.setCurrentRow(0)
hsplitter = QSplitter()
hsplitter.addWidget(self.contents_widget)
hsplitter.addWidget(self.pages_widget)
btnlayout = QHBoxLayout()
btnlayout.addStretch(1)
btnlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(hsplitter)
vlayout.addLayout(btnlayout)
self.setLayout(vlayout)
self.setWindowTitle(_("Preferences"))
self.setWindowIcon(get_icon("configure.png"))
def get_current_index(self):
"""Return current page index"""
return self.contents_widget.currentRow()
def set_current_index(self, index):
"""Set current page index"""
self.contents_widget.setCurrentRow(index)
def get_page(self, index=None):
"""Return page widget"""
if index is None:
widget = self.pages_widget.currentWidget()
else:
widget = self.pages_widget.widget(index)
return widget.widget()
def accept(self):
"""Reimplement Qt method"""
for index in range(self.pages_widget.count()):
configpage = self.get_page(index)
if not configpage.is_valid():
return
configpage.apply_changes()
QDialog.accept(self)
def button_clicked(self, button):
if button is self.apply_btn:
# Apply button was clicked
configpage = self.get_page()
if not configpage.is_valid():
return
configpage.apply_changes()
def current_page_changed(self, index):
widget = self.get_page(index)
self.apply_btn.setVisible(widget.apply_callback is not None)
self.apply_btn.setEnabled(widget.is_modified)
def add_page(self, widget):
self.connect(self, SIGNAL('check_settings()'), widget.check_settings)
self.connect(widget, SIGNAL('show_this_page()'),
lambda row=self.contents_widget.count():
self.contents_widget.setCurrentRow(row))
self.connect(widget, SIGNAL("apply_button_enabled(bool)"),
self.apply_btn.setEnabled)
scrollarea = QScrollArea(self)
scrollarea.setWidgetResizable(True)
scrollarea.setWidget(widget)
self.pages_widget.addWidget(scrollarea)
item = QListWidgetItem(self.contents_widget)
item.setIcon(widget.get_icon())
item.setText(widget.get_name())
#.........这里部分代码省略.........
开发者ID:jromang,项目名称:spyderlib,代码行数:101,代码来源:configdialog.py
示例12: __init__
def __init__(self, parent, max_entries=100):
""" Creates a very basic window with some text """
"""
RATE_LAW_MESSAGE = \
"The Plugins for Spyder consists out of three main classes: \n\n" \
"1. HelloWorld\n\n" \
"\tThe HelloWorld class inherits all its methods from\n" \
"\tSpyderPluginMixin and the HelloWorldWidget and performs all\n" \
"\tthe processing required by the GU. \n\n" \
"2. HelloWorldConfigPage\n\n" \
"\tThe HelloWorldConfig class inherits all its methods from\n" \
"\tPluginConfigPage to create a configuration page that can be\n" \
"\tfound under Tools -> Preferences\n\n" \
"3. HelloWorldWidget\n\n" \
"\tThe HelloWorldWidget class inherits all its methods from\n" \
"\tQWidget to create the actual plugin GUI interface that \n" \
"\tdisplays this message on screen\n\n"
"""
#Testing access editor on plugin initialization
RATE_LAW_MESSAGE = ""
displaynamelist = []
#displaylist = []
infixlist = []
desclist = []
parameterstringlist = []
xmldoc = minidom.parse('\\.spyder2\\ratelaw2_0_3.xml')
#xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
lawlistxml = xmldoc.getElementsByTagName('law')
#i is the number of laws currently in the xml file
i = 0
for s in lawlistxml:
#RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
RATE_LAW_MESSAGE += s.getAttribute('display') + "\n"
#displaynamelist[i] = s.getAttribute('displayName')
#displaylist[i] = s.getAttribute('display')
displaynamelist.append(s.getAttribute('displayName'))
#displaylist.append(s.getAttribute('display'))
infixlist.append(s.getAttribute('infixExpression'))
desclist.append(s.getAttribute('description'))
parameterlist = s.getElementsByTagName('listOfParameters')[0]
#for p in parameterlist
parameters = parameterlist.getElementsByTagName('parameter')
parameterstring = ""
for param in parameters:
parametername = param.attributes['name'].value
parameterdesc = param.attributes['description'].value
parameterstring = parameterstring + '\t' + parametername + ":" + '\t' + " " + parameterdesc + "\n"
#print('\t' + parametername + ":" + '\t' + parameterdesc)
parameterstringlist.append(parameterstring)
i = i + 1
QWidget.__init__(self, parent)
self.setWindowTitle("Rate Law Library")
self.output = None
self.error_output = None
self._last_wdir = None
self._last_args = None
self._last_pythonpath = None
self.textlabel = QLabel(RATE_LAW_MESSAGE)
self.lawlist = QListWidget()
self.lawpage = QStackedWidget()
#Adding displayName items to lawlist
for j in range(i):
item = QListWidgetItem(displaynamelist[j])
self.lawlist.addItem(item)
self.lawdetailpage = QWidget()
# Page layout will become its own function
setup_group = QGroupBox(displaynamelist[j])
infixmod = infixlist[j].replace("___"," ")
setup_label = QLabel(infixmod)
setup_label.setWordWrap(True)
desc_group = QGroupBox("Description")
desc_label = QLabel(desclist[j])
desc_label.setWordWrap(True)
param_label = QLabel(parameterstringlist[j])
param_label.setWordWrap(True)
# Warning: do not try to regroup the following QLabel contents with
# widgets above -- this string was isolated here in a single QLabel
# on purpose: to fix Issue 863
setup_layout = QVBoxLayout()
setup_layout.addWidget(setup_label)
setup_group.setLayout(setup_layout)
desc_layout = QVBoxLayout()
desc_layout.addWidget(desc_label)
desc_layout.addWidget(param_label)
desc_group.setLayout(desc_layout)
vlayout = QVBoxLayout()
#.........这里部分代码省略.........
开发者ID:jayitb,项目名称:Spyderplugin_ratelaws,代码行数:101,代码来源:ratelawgui.py
示例13: __init__
def __init__(self, parent, max_entries=100):
"Initialize Various list objects before assignment"
displaylist = []
displaynamelist = []
infixmod = []
infixlist = []
desclist = []
parameternamelist = []
parameterdesclist = []
parameterstringlist = []
paramcountlist = []
buttonlist = []
xmldoc = minidom.parse('C:\\Users\\Jayit\\.spyder2\\ratelaw2_0_3.xml')
#xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
lawlistxml = xmldoc.getElementsByTagName('law')
o = 0
for s in lawlistxml:
o = o + 1
parameternamelistlist = [0 for x in range(o)]
parameterdesclistlist = [0 for x in range(o)]
"""i is the number of laws currently in the xml file"""
i = 0
"""
Parsing xml: Acquiring rate law name, description, and list of parameter information
"""
for s in lawlistxml:
#RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
"""Gets Latec Expression"""
displaylist.append(s.getAttribute('display'))
"""Gets Rate-Law Name"""
displaynamelist.append(s.getAttribute('displayName'))
""""Gets Raw Rate-Law expression"""
infixlist.append(s.getAttribute('infixExpression'))
"""Gets description statement"""
desclist.append(s.getAttribute('description'))
"""Gets listOfParameters Object"""
parameterlist = s.getElementsByTagName('listOfParameters')[0]
"""Gets a list of parameters within ListOfParameters object"""
parameters = parameterlist.getElementsByTagName('parameter')
for param in parameters:
parameternamelist.append(param.attributes['name'].value)
#print(param.attributes['name'].value)
parameterdesclist.append(param.attributes['description'].value)
parameternamelistlist[i] = parameternamelist
#print("break")
parameterdesclistlist[i] = parameterdesclist
parameternamelist = []
parameterdesclist = []
i = i + 1
SLElistlist = [ 0 for x in range(i)]
PLElistlist = [ 0 for x in range(i)]
ILElistlist = [ 0 for x in range(i)]
paramLElistlist = [ 0 for x in range(i)]
numlistlist = [ 0 for x in range(i)]
QWidget.__init__(self, parent)
self.setWindowTitle("Rate Law Library")
self.output = None
self.error_output = None
self._last_wdir = None
self._last_args = None
self._last_pythonpath = None
#self.textlabel = QLabel(RATE_LAW_MESSAGE)
self.lawlist = QListWidget()
self.lawpage = QStackedWidget()
index = 0
for j in range(i):
item = QListWidgetItem(displaynamelist[j])
self.lawlist.addItem(item)
self.lawdetailpage = QWidget()
setup_group = QGroupBox(displaynamelist[j])
infixmod.append(infixlist[j].replace("___"," "))
setup_label = QLabel(infixmod[j])
setup_label.setWordWrap(True)
desc_group = QGroupBox("Description")
desc_label = QLabel(desclist[j])
#.........这里部分代码省略.........
开发者ID:jayitb,项目名称:Spyderplugin_ratelaws,代码行数:101,代码来源:ratelawgui.py
注:本文中的spyderlib.qt.QtGui.QListWidget类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论