def setup_page(self): """ Create the Spyder Config page for this plugin. As of Dec 2014, there are no options available to set, so we only display the data path. """ results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Results are stored here:")) results_label1.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 results_label2 = QLabel(CoverageWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): settings_group = QGroupBox(_("Settings")) use_color_box = self.create_checkbox( _("Use deterministic colors to differentiate functions"), 'use_colors', default=True) results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Memory profiler plugin results " "(the output of memory_profiler)\n" "is stored here:")) results_label1.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 of Profiler plugon results_label2 = QLabel(MemoryProfilerWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) settings_layout = QVBoxLayout() settings_layout.addWidget(use_color_box) settings_group.setLayout(settings_layout) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): results_group = QGroupBox(_("Results")) results_label1 = QLabel( _("Profiler plugin results " "(the output of python's profile/cProfile)\n" "are stored here:")) results_label1.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 results_label2 = QLabel(ProfilerWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): settings_group = QGroupBox(_("Settings")) use_color_box = self.create_checkbox( _("Use deterministic colors to differentiate functions"), 'use_colors', default=True) results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Line profiler plugin results " "(the output of kernprof.py)\n" "are stored here:")) results_label1.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 of Profiler plugon results_label2 = QLabel(LineProfilerWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) settings_layout = QVBoxLayout() settings_layout.addWidget(use_color_box) settings_group.setLayout(settings_layout) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.runconf = RunConfiguration() common_group = QGroupBox(_("General settings")) common_layout = QGridLayout() common_group.setLayout(common_layout) self.clo_cb = QCheckBox(_("Command line options:")) common_layout.addWidget(self.clo_cb, 0, 0) self.clo_edit = QLineEdit() self.connect(self.clo_cb, SIGNAL("toggled(bool)"), self.clo_edit.setEnabled) self.clo_edit.setEnabled(False) common_layout.addWidget(self.clo_edit, 0, 1) self.wd_cb = QCheckBox(_("Working directory:")) common_layout.addWidget(self.wd_cb, 1, 0) wd_layout = QHBoxLayout() self.wd_edit = QLineEdit() self.connect(self.wd_cb, SIGNAL("toggled(bool)"), self.wd_edit.setEnabled) self.wd_edit.setEnabled(False) wd_layout.addWidget(self.wd_edit) browse_btn = QPushButton(get_std_icon("DirOpenIcon"), "", self) browse_btn.setToolTip(_("Select directory")) self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory) wd_layout.addWidget(browse_btn) common_layout.addLayout(wd_layout, 1, 1) radio_group = QGroupBox(_("Interpreter")) radio_layout = QVBoxLayout() radio_group.setLayout(radio_layout) self.current_radio = QRadioButton(_("Execute in current Python " "or IPython interpreter")) radio_layout.addWidget(self.current_radio) self.new_radio = QRadioButton(_("Execute in a new dedicated " "Python interpreter")) radio_layout.addWidget(self.new_radio) self.systerm_radio = QRadioButton(_("Execute in an external " "system terminal")) radio_layout.addWidget(self.systerm_radio) new_group = QGroupBox(_("Dedicated Python interpreter")) self.connect(self.current_radio, SIGNAL("toggled(bool)"), new_group.setDisabled) new_layout = QGridLayout() new_group.setLayout(new_layout) self.interact_cb = QCheckBox(_("Interact with the Python " "interpreter after execution")) new_layout.addWidget(self.interact_cb, 1, 0, 1, -1) self.pclo_cb = QCheckBox(_("Command line options:")) new_layout.addWidget(self.pclo_cb, 2, 0) self.pclo_edit = QLineEdit() self.connect(self.pclo_cb, SIGNAL("toggled(bool)"), self.pclo_edit.setEnabled) self.pclo_edit.setEnabled(False) new_layout.addWidget(self.pclo_edit, 2, 1) pclo_label = QLabel(_("The <b>-u</b> option is " "added to these commands")) pclo_label.setWordWrap(True) new_layout.addWidget(pclo_label, 3, 1) # TODO: Add option for "Post-mortem debugging" layout = QVBoxLayout() layout.addWidget(common_group) layout.addWidget(radio_group) layout.addWidget(new_group) self.setLayout(layout)
class DependenciesDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Optional Dependencies"))) self.setModal(True) self.view = DependenciesTableView(self, []) important_mods = ["rope", "pyflakes", "IPython", "matplotlib"] self.label = QLabel( _( "Spyder depends on several Python modules to " "provide additional functionality for its " "plugins. The table below shows the required " "and installed versions (if any) of all of " "them.<br><br>" "Although Spyder can work without any of these " "modules, it's strongly recommended that at " "least you try to install <b>%s</b> and " "<b>%s</b> to have a much better experience." ) % (", ".join(important_mods[:-1]), important_mods[-1]) ) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignJustify) self.label.setContentsMargins(5, 8, 12, 10) btn = QPushButton(_("Copy to clipboard")) self.connect(btn, SIGNAL("clicked()"), self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.label) vlayout.addWidget(self.view) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(560, 350) def set_data(self, dependencies): self.view.model.set_data(dependencies) self.view.adjust_columns() self.view.sortByColumn(0, Qt.DescendingOrder) def copy_to_clipboard(self): from spyderlib.dependencies import status QApplication.clipboard().setText(status())
class DependenciesDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Optional Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.view = DependenciesTableView(self, []) important_mods = ['rope', 'pyflakes', 'IPython', 'matplotlib'] self.label = QLabel( _("Spyder depends on several Python modules to " "provide additional functionality for its " "plugins. The table below shows the required " "and installed versions (if any) of all of " "them.<br><br>" "Although Spyder can work without any of these " "modules, it's strongly recommended that at " "least you try to install <b>%s</b> and " "<b>%s</b> to have a much better experience.") % (', '.join(important_mods[:-1]), important_mods[-1])) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignJustify) self.label.setContentsMargins(5, 8, 12, 10) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.label) vlayout.addWidget(self.view) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(630, 420) def set_data(self, dependencies): self.view.model.set_data(dependencies) self.view.adjust_columns() self.view.sortByColumn(0, Qt.DescendingOrder) def copy_to_clipboard(self): from spyderlib.dependencies import status QApplication.clipboard().setText(status())
class DependenciesDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.view = DependenciesTableView(self, []) opt_mods = ['NumPy', 'Matplotlib', 'Pandas', 'SymPy'] self.label = QLabel( _("Spyder depends on several Python modules to " "provide the right functionality for all its " "panes. The table below shows the required " "and installed versions (if any) of all of " "them.<br><br>" "<b>Note</b>: You can safely use Spyder " "without the following modules installed: " "<b>%s</b> and <b>%s</b>") % (', '.join(opt_mods[:-1]), opt_mods[-1])) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignJustify) self.label.setContentsMargins(5, 8, 12, 10) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.label) vlayout.addWidget(self.view) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(630, 420) def set_data(self, dependencies): self.view.model.set_data(dependencies) self.view.adjust_columns() self.view.sortByColumn(0, Qt.DescendingOrder) def copy_to_clipboard(self): from spyderlib.dependencies import status QApplication.clipboard().setText(status())
class DependenciesDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.setWindowTitle("Spyder %s: %s" % (__version__, _("Dependencies"))) self.setWindowIcon(ima.icon('tooloptions')) self.setModal(True) self.view = DependenciesTableView(self, []) opt_mods = ['NumPy', 'Matplotlib', 'Pandas', 'SymPy'] self.label = QLabel(_("Spyder depends on several Python modules to " "provide the right functionality for all its " "panes. The table below shows the required " "and installed versions (if any) of all of " "them.<br><br>" "<b>Note</b>: You can safely use Spyder " "without the following modules installed: " "<b>%s</b> and <b>%s</b>") % (', '.join(opt_mods[:-1]), opt_mods[-1])) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignJustify) self.label.setContentsMargins(5, 8, 12, 10) btn = QPushButton(_("Copy to clipboard"), ) btn.clicked.connect(self.copy_to_clipboard) bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) hlayout = QHBoxLayout() hlayout.addWidget(btn) hlayout.addStretch() hlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(self.label) vlayout.addWidget(self.view) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.resize(630, 420) def set_data(self, dependencies): self.view.model.set_data(dependencies) self.view.adjust_columns() self.view.sortByColumn(0, Qt.DescendingOrder) def copy_to_clipboard(self): from spyderlib.dependencies import status QApplication.clipboard().setText(status())
def create_lineedit(self, text, option, default=NoDefault, tip=None, alignment=Qt.Vertical): label = QLabel(text) label.setWordWrap(True) edit = QLineEdit() layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout() layout.addWidget(label) layout.addWidget(edit) layout.setContentsMargins(0, 0, 0, 0) if tip: edit.setToolTip(tip) self.lineedits[edit] = (option, default) widget = QWidget(self) widget.setLayout(layout) return widget
def setup_page(self): """ Setup of the configuration page. All widgets need to be added here""" setup_group = QGroupBox(_("RateLaw Plugin Configuration")) setup_label = QLabel(_("RateLaw plugin configuration needs to be "\ "implemented here.\n")) setup_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) vlayout = QVBoxLayout() vlayout.addWidget(setup_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Profiler plugin results "\ "(the output of python's profile/cProfile)\n" "are stored here:")) results_label1.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 results_label2 = QLabel(ProfilerWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): settings_group = QGroupBox(_("Settings")) save_box = self.create_checkbox(_("Save file before analyzing it"), 'save_before', default=True) hist_group = QGroupBox(_("History")) hist_label1 = QLabel( _("The following option will be applied at next " "startup.")) hist_label1.setWordWrap(True) hist_spin = self.create_spinbox(_("History: "), _(" results"), 'max_entries', default=50, min_=10, max_=1000000, step=10) results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Results are stored here:")) results_label1.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 results_label2 = QLabel(PylintWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) settings_layout = QVBoxLayout() settings_layout.addWidget(save_box) settings_group.setLayout(settings_layout) hist_layout = QVBoxLayout() hist_layout.addWidget(hist_label1) hist_layout.addWidget(hist_spin) hist_group.setLayout(hist_layout) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(hist_group) vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): settings_group = QGroupBox(_("Settings")) save_box = self.create_checkbox(_("Save file before analyzing it"), 'save_before', default=True) hist_group = QGroupBox(_("History")) hist_label1 = QLabel(_("The following option will be applied at next " "startup.")) hist_label1.setWordWrap(True) hist_spin = self.create_spinbox(_("History: "), _(" results"), 'max_entries', default=50, min_=10, max_=1000000, step=10) results_group = QGroupBox(_("Results")) results_label1 = QLabel(_("Results are stored here:")) results_label1.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 results_label2 = QLabel(PylintWidget.DATAPATH) results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse) results_label2.setWordWrap(True) settings_layout = QVBoxLayout() settings_layout.addWidget(save_box) settings_group.setLayout(settings_layout) hist_layout = QVBoxLayout() hist_layout.addWidget(hist_label1) hist_layout.addWidget(hist_spin) hist_group.setLayout(hist_layout) results_layout = QVBoxLayout() results_layout.addWidget(results_label1) results_layout.addWidget(results_label2) results_group.setLayout(results_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(hist_group) vlayout.addWidget(results_group) vlayout.addStretch(1) self.setLayout(vlayout)
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]) desc_label.setWordWrap(True) param_label = QGridLayout() nm = QLabel("Name:") des = QLabel("Description:") repl = QLabel("Replace with:") param_label.addWidget(nm,0,0) param_label.addWidget(des,0,1) param_label.addWidget(repl,0,2) """g is the total number of alterable values""" g = 0 """t is the total number of alterable non-parameters""" t = 1 snum = 0 pnum = 0 inum = 0 """range of N is the max number of possible substrates OR products""" N = 5 for n in range(N): nl = n+1 if (infixmod[j].find('S%s' % nl) > -1): z = QLabel('S%s is present' % nl) param_label.addWidget(z,t,0) snum = snum + 1 t = t + 1 for n in range(N): nl = n+1 if (infixmod[j].find('P%s' % nl) > -1): z = QLabel('P%s is present' % nl) param_label.addWidget(z,t,0) pnum = pnum + 1 t = t + 1 for n in range(N): nl = n+1 if (infixmod[j].find('I%s' % nl) > -1): z = QLabel('I%s is present' % nl) param_label.addWidget(z,t,0) inum = inum + 1 t = t + 1 """Initialize lists of list of parameter lineedit""" length = len(parameternamelistlist[j]) for b in range(length): p = QLabel("%s :" % parameternamelistlist[j][b]) param_label.addWidget(p,b+t,0) d = QLabel("'%s'" % parameterdesclistlist[j][b]) param_label.addWidget(d,b+t,1) g = t + length Slineeditlist = [0 for x in range(snum)] Plineeditlist = [0 for x in range(pnum)] Ilineeditlist = [0 for x in range(inum)] paramlineeditlist = [0 for x in range(length)] editcount = 1 """Place lineedit widgets for parameters""" for s in range(snum): Slineeditlist[s] = QLineEdit() param_label.addWidget(Slineeditlist[s],editcount,2) editcount = editcount + 1 SLElistlist[j] = Slineeditlist for s in range(pnum): Plineeditlist[s] = QLineEdit() param_label.addWidget(Plineeditlist[s],editcount,2) editcount = editcount + 1 PLElistlist[j] = Plineeditlist for s in range(inum): Ilineeditlist[s] = QLineEdit() param_label.addWidget(Ilineeditlist[s],editcount,2) editcount = editcount + 1 ILElistlist[j] = Ilineeditlist for s in range(length): paramlineeditlist[s] = QLineEdit() param_label.addWidget(paramlineeditlist[s],editcount,2) editcount = editcount + 1 paramLElistlist[j] = paramlineeditlist """Necessary lists for editable parameters. Housekeeping essentially.""" stuff = paramlineeditlist[0].text() numlistlist[j] = [snum, pnum, inum, length] charlist = ["S","P","I"] buttonlist.append(QPushButton(self)) buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j]) # 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 """Page formatting""" setup_layout = QVBoxLayout() setup_layout.addWidget(setup_label) setup_group.setLayout(setup_layout) desc_group.setLayout(param_label) vlayout = QVBoxLayout() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addWidget(buttonlist[j]) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) """Set up button functionality""" for k in range(47): buttonlist[k].clicked.connect(pressbutton(self, infixmod[k], SLElistlist[k], PLElistlist[k],ILElistlist[k], paramLElistlist[k], parameternamelistlist[k], numlistlist[k], charlist,k)) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) self.lawlist.setCurrentRow(0) """Set up high-level widget formatting.""" hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
class FadingTipBox(FadingDialog): """ """ def __init__(self, parent, opacity, duration, easing_curve): super(FadingTipBox, self).__init__(parent, opacity, duration, easing_curve) self.holder = self.anim # needed for qt to work self.parent = parent self.frames = None self.color_top = QColor.fromRgb(230, 230, 230) self.color_back = QColor.fromRgb(255, 255, 255) self.offset_shadow = 0 self.fixed_width = 300 self.key_pressed = None self.setAttribute(Qt.WA_TranslucentBackground) self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setModal(False) # Widgets self.button_home = QPushButton("<<") self.button_close = QPushButton("X") self.button_previous = QPushButton(" < ") self.button_end = QPushButton(">>") self.button_next = QPushButton(" > ") self.button_run = QPushButton(_('Run code')) self.button_disable = None self.button_current = QToolButton() self.label_image = QLabel() self.label_title = QLabel() self.combo_title = QComboBox() self.label_current = QLabel() self.label_content = QLabel() self.label_content.setMinimumWidth(self.fixed_width) self.label_content.setMaximumWidth(self.fixed_width) self.label_current.setAlignment(Qt.AlignCenter) self.label_content.setWordWrap(True) self.widgets = [ self.label_content, self.label_title, self.label_current, self.combo_title, self.button_close, self.button_run, self.button_next, self.button_previous, self.button_end, self.button_home, self.button_current ] arrow = get_image_path('hide.png') self.stylesheet = '''QPushButton { background-color: rgbs(200,200,200,100%); color: rgbs(0,0,0,100%); border-style: outset; border-width: 1px; border-radius: 3px; border-color: rgbs(100,100,100,100%); padding: 2px; } QPushButton:hover { background-color: rgbs(150, 150, 150, 100%); } QPushButton:disabled { background-color: rgbs(230,230,230,100%); color: rgbs(200,200,200,100%); border-color: rgbs(200,200,200,100%); } QComboBox { padding-left: 5px; background-color: rgbs(230,230,230,100%); border-width: 0px; border-radius: 0px; min-height:20px; max-height:20px; } QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top left; border-width: 0px; } QComboBox::down-arrow { image: url(''' + arrow + '''); } ''' # Windows fix, slashes should be always in unix-style self.stylesheet = self.stylesheet.replace('\\', '/') for widget in self.widgets: widget.setFocusPolicy(Qt.NoFocus) widget.setStyleSheet(self.stylesheet) layout_top = QHBoxLayout() layout_top.addWidget(self.combo_title) layout_top.addStretch() layout_top.addWidget(self.button_close) layout_top.addSpacerItem( QSpacerItem(self.offset_shadow, self.offset_shadow)) layout_content = QHBoxLayout() layout_content.addWidget(self.label_content) layout_content.addWidget(self.label_image) layout_content.addSpacerItem(QSpacerItem(5, 5)) layout_run = QHBoxLayout() layout_run.addStretch() layout_run.addWidget(self.button_run) layout_run.addStretch() layout_run.addSpacerItem( QSpacerItem(self.offset_shadow, self.offset_shadow)) layout_navigation = QHBoxLayout() layout_navigation.addWidget(self.button_home) layout_navigation.addWidget(self.button_previous) layout_navigation.addStretch() layout_navigation.addWidget(self.label_current) layout_navigation.addStretch() layout_navigation.addWidget(self.button_next) layout_navigation.addWidget(self.button_end) layout_navigation.addSpacerItem( QSpacerItem(self.offset_shadow, self.offset_shadow)) layout = QVBoxLayout() layout.addLayout(layout_top) layout.addStretch() layout.addSpacerItem(QSpacerItem(15, 15)) layout.addLayout(layout_content) layout.addLayout(layout_run) layout.addStretch() layout.addSpacerItem(QSpacerItem(15, 15)) layout.addLayout(layout_navigation) layout.addSpacerItem( QSpacerItem(self.offset_shadow, self.offset_shadow)) layout.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(layout) self.set_funcs_before_fade_in([self._disable_widgets]) self.set_funcs_after_fade_in([self._enable_widgets]) self.set_funcs_before_fade_out([self._disable_widgets]) self.setContextMenuPolicy(Qt.CustomContextMenu) # signals and slots # These are defined every time by the AnimatedTour Class def _disable_widgets(self): """ """ for widget in self.widgets: widget.setDisabled(True) def _enable_widgets(self): """ """ self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) for widget in self.widgets: widget.setDisabled(False) if self.button_disable == 'previous': self.button_previous.setDisabled(True) self.button_home.setDisabled(True) elif self.button_disable == 'next': self.button_next.setDisabled(True) self.button_end.setDisabled(True) def set_data(self, title, content, current, image, run, frames=None, step=None): """ """ self.label_title.setText(title) self.combo_title.clear() self.combo_title.addItems(frames) self.combo_title.setCurrentIndex(step) # min_content_len = max([len(f) for f in frames]) # self.combo_title.setMinimumContentsLength(min_content_len) # Fix and try to see how it looks with a combo box self.label_current.setText(current) self.button_current.setText(current) self.label_content.setText(content) self.image = image if image is None: self.label_image.setFixedHeight(1) self.label_image.setFixedWidth(1) else: extension = image.split('.')[-1] self.image = QPixmap(get_image_path(image), extension) self.label_image.setPixmap(self.image) self.label_image.setFixedSize(self.image.size()) if run is None: self.button_run.setVisible(False) else: self.button_run.setDisabled(False) self.button_run.setVisible(True) # Refresh layout self.layout().activate() def set_pos(self, x, y): """ """ self.x = x self.y = y self.move(QPoint(x, y)) def build_paths(self): """ """ geo = self.geometry() radius = 30 shadow = self.offset_shadow x0, y0 = geo.x(), geo.y() width, height = geo.width() - shadow, geo.height() - shadow left, top = 0, 0 right, bottom = width, height self.round_rect_path = QPainterPath() self.round_rect_path.moveTo(right, top + radius) self.round_rect_path.arcTo(right - radius, top, radius, radius, 0.0, 90.0) self.round_rect_path.lineTo(left + radius, top) self.round_rect_path.arcTo(left, top, radius, radius, 90.0, 90.0) self.round_rect_path.lineTo(left, bottom - radius) self.round_rect_path.arcTo(left, bottom - radius, radius, radius, 180.0, 90.0) self.round_rect_path.lineTo(right - radius, bottom) self.round_rect_path.arcTo(right - radius, bottom - radius, radius, radius, 270.0, 90.0) self.round_rect_path.closeSubpath() # Top path header = 36 offset = 2 left, top = offset, offset right = width - (offset) self.top_rect_path = QPainterPath() self.top_rect_path.lineTo(right, top + radius) self.top_rect_path.moveTo(right, top + radius) self.top_rect_path.arcTo(right - radius, top, radius, radius, 0.0, 90.0) self.top_rect_path.lineTo(left + radius, top) self.top_rect_path.arcTo(left, top, radius, radius, 90.0, 90.0) self.top_rect_path.lineTo(left, top + header) self.top_rect_path.lineTo(right, top + header) def paintEvent(self, event): """ """ self.build_paths() painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.fillPath(self.round_rect_path, self.color_back) painter.fillPath(self.top_rect_path, self.color_top) painter.strokePath(self.round_rect_path, QPen(Qt.gray, 1)) # TODO: Build the pointing arrow? def keyReleaseEvent(self, event): """ """ key = event.key() self.key_pressed = key # print(key) keys = [ Qt.Key_Right, Qt.Key_Left, Qt.Key_Down, Qt.Key_Up, Qt.Key_Escape, Qt.Key_PageUp, Qt.Key_PageDown, Qt.Key_Home, Qt.Key_End, Qt.Key_Menu ] if key in keys: if not self.is_fade_running(): self.sig_key_pressed.emit() def mousePressEvent(self, event): """override Qt method""" # Raise the main application window on click self.parent.raise_() self.raise_() if event.button() == Qt.RightButton: pass # clicked_widget = self.childAt(event.x(), event.y()) # if clicked_widget == self.label_current: # self.context_menu_requested(event) def context_menu_requested(self, event): """ """ pos = QPoint(event.x(), event.y()) menu = QMenu(self) actions = [] action_title = create_action(self, _('Go to step: '), icon=QIcon()) action_title.setDisabled(True) actions.append(action_title) # actions.append(create_action(self, _(': '), icon=QIcon())) add_actions(menu, actions) menu.popup(self.mapToGlobal(pos)) def reject(self): """Qt method to handle escape key event""" if not self.is_fade_running(): key = Qt.Key_Escape self.key_pressed = key self.sig_key_pressed.emit()
def setup_page(self): about_label = QLabel( _("The <b>global working directory</b> is " "the working directory for newly opened <i>consoles</i> " "(Python/IPython consoles and terminals), for the " "<i>file explorer</i>, for the <i>find in files</i> " "plugin and for new files created in the <i>editor</i>.")) about_label.setWordWrap(True) startup_group = QGroupBox(_("Startup")) startup_bg = QButtonGroup(startup_group) startup_label = QLabel( _("At startup, the global working " "directory is:")) startup_label.setWordWrap(True) lastdir_radio = self.create_radiobutton( _("the same as in last session"), 'startup/use_last_directory', True, _("At startup, Spyder will restore the " "global directory from last session"), button_group=startup_bg) thisdir_radio = self.create_radiobutton( _("the following directory:"), 'startup/use_fixed_directory', False, _("At startup, the global working " "directory will be the specified path"), button_group=startup_bg) thisdir_bd = self.create_browsedir("", 'startup/fixed_directory', getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) lastdir_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) editor_o_group = QGroupBox(_("Open file")) editor_o_label = QLabel(_("Files are opened from:")) editor_o_label.setWordWrap(True) editor_o_bg = QButtonGroup(editor_o_group) editor_o_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/open/browse_scriptdir', button_group=editor_o_bg) editor_o_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/open/browse_workdir', button_group=editor_o_bg) editor_n_group = QGroupBox(_("New file")) editor_n_label = QLabel(_("Files are created in:")) editor_n_label.setWordWrap(True) editor_n_bg = QButtonGroup(editor_n_group) editor_n_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/new/browse_scriptdir', button_group=editor_n_bg) editor_n_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/new/browse_workdir', button_group=editor_n_bg) # Note: default values for the options above are set in plugin's # constructor (see below) other_group = QGroupBox(_("Change to file base directory")) newcb = self.create_checkbox open_box = newcb(_("When opening a file"), 'editor/open/auto_set_to_basedir') save_box = newcb(_("When saving a file"), 'editor/save/auto_set_to_basedir') startup_layout = QVBoxLayout() startup_layout.addWidget(startup_label) startup_layout.addWidget(lastdir_radio) startup_layout.addLayout(thisdir_layout) startup_group.setLayout(startup_layout) editor_o_layout = QVBoxLayout() editor_o_layout.addWidget(editor_o_label) editor_o_layout.addWidget(editor_o_radio1) editor_o_layout.addWidget(editor_o_radio2) editor_o_group.setLayout(editor_o_layout) editor_n_layout = QVBoxLayout() editor_n_layout.addWidget(editor_n_label) editor_n_layout.addWidget(editor_n_radio1) editor_n_layout.addWidget(editor_n_radio2) editor_n_group.setLayout(editor_n_layout) other_layout = QVBoxLayout() other_layout.addWidget(open_box) other_layout.addWidget(save_box) other_group.setLayout(other_layout) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(startup_group) vlayout.addWidget(editor_o_group) vlayout.addWidget(editor_n_group) vlayout.addWidget(other_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): # Fonts group plain_text_font_group = self.create_fontgroup( option=None, text=_("Plain text font style"), fontfilters=QFontComboBox.MonospacedFonts ) rich_text_font_group = self.create_fontgroup(option="rich_text", text=_("Rich text font style")) # Connections group connections_group = QGroupBox(_("Automatic connections")) connections_label = QLabel( _( "The Object Inspector can automatically " "show an object's help information after " "a left parenthesis is written next to it. " "Below you can decide to which plugin " "you want to connect it to turn on this " "feature." ) ) connections_label.setWordWrap(True) editor_box = self.create_checkbox(_("Editor"), "connect/editor") rope_installed = programs.is_module_installed("rope") jedi_installed = programs.is_module_installed("jedi", ">=0.8.0") editor_box.setEnabled(rope_installed or jedi_installed) # TODO: Don't forget to add Jedi here if not rope_installed: rope_tip = _("This feature requires the Rope library.\n" "It seems you don't have it installed.") editor_box.setToolTip(rope_tip) python_box = self.create_checkbox(_("Python Console"), "connect/python_console") ipython_box = self.create_checkbox(_("IPython Console"), "connect/ipython_console") ipython_installed = programs.is_module_installed("IPython", ">=0.13") ipython_box.setEnabled(ipython_installed) connections_layout = QVBoxLayout() connections_layout.addWidget(connections_label) connections_layout.addWidget(editor_box) connections_layout.addWidget(python_box) connections_layout.addWidget(ipython_box) connections_group.setLayout(connections_layout) # Features group features_group = QGroupBox(_("Additional features")) math_box = self.create_checkbox(_("Render mathematical equations"), "math") req_sphinx = sphinx_version is not None and programs.is_module_installed("sphinx", ">=1.1") math_box.setEnabled(req_sphinx) if not req_sphinx: sphinx_tip = _("This feature requires Sphinx 1.1 or superior.") if sphinx_version is not None: sphinx_tip += "\n" + _("Sphinx %s is currently installed.") % sphinx_version math_box.setToolTip(sphinx_tip) features_layout = QVBoxLayout() features_layout.addWidget(math_box) features_group.setLayout(features_layout) # Source code group sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), "wrap") names = CONF.get("color_schemes", "names") choices = list(zip(names, names)) cs_combo = self.create_combobox(_("Syntax color scheme: "), choices, "color_scheme_name") sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_layout.addWidget(cs_combo) sourcecode_group.setLayout(sourcecode_layout) # Final layout vlayout = QVBoxLayout() vlayout.addWidget(rich_text_font_group) vlayout.addWidget(plain_text_font_group) vlayout.addWidget(connections_group) vlayout.addWidget(features_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton(CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton(DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton(SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) general_group = QGroupBox("General settings") wdir_bg = QButtonGroup(general_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) dirname_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) post_mortem = self.create_checkbox( _("Enter debugging mode when errors appear during execution"), 'post_mortem', False) general_layout = QVBoxLayout() general_layout.addWidget(wdir_label) general_layout.addWidget(dirname_radio) general_layout.addLayout(thisdir_layout) general_layout.addWidget(post_mortem) general_group.setLayout(general_layout) dedicated_group = QGroupBox(_("Dedicated Python console")) interact_after = self.create_checkbox( _("Interact with the Python console after execution"), 'interact', False) show_warning = self.create_checkbox( _("Show warning when killing running processes"), 'show_kill_warning', True) dedicated_layout = QVBoxLayout() dedicated_layout.addWidget(interact_after) dedicated_layout.addWidget(show_warning) dedicated_group.setLayout(dedicated_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(general_group) vlayout.addWidget(dedicated_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton(CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton(DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton(SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) wdir_group = QGroupBox(_("Working directory")) wdir_bg = QButtonGroup(wdir_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) dirname_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) wdir_layout = QVBoxLayout() wdir_layout.addWidget(wdir_label) wdir_layout.addWidget(dirname_radio) wdir_layout.addLayout(thisdir_layout) wdir_group.setLayout(wdir_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(wdir_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self, parent=None): super(KernelConnectionDialog, self).__init__(parent) self.setWindowTitle(_('Connect to an existing kernel')) main_label = QLabel(_("Please enter the connection info of the kernel " "you want to connect to. For that you can " "either select its JSON connection file using " "the <tt>Browse</tt> button, or write directly " "its id, in case it's a local kernel (for " "example <tt>kernel-3764.json</tt> or just " "<tt>3764</tt>).")) main_label.setWordWrap(True) main_label.setAlignment(Qt.AlignJustify) # connection file cf_label = QLabel(_('Connection info:')) self.cf = QLineEdit() self.cf.setPlaceholderText(_('Path to connection file or kernel id')) self.cf.setMinimumWidth(250) cf_open_btn = QPushButton(_('Browse')) self.connect(cf_open_btn, SIGNAL('clicked()'), self.select_connection_file) cf_layout = QHBoxLayout() cf_layout.addWidget(cf_label) cf_layout.addWidget(self.cf) cf_layout.addWidget(cf_open_btn) # remote kernel checkbox self.rm_cb = QCheckBox(_('This is a remote kernel')) # ssh connection self.hn = QLineEdit() self.hn.setPlaceholderText(_('username@hostname:port')) self.kf = QLineEdit() self.kf.setPlaceholderText(_('Path to ssh key file')) kf_open_btn = QPushButton(_('Browse')) self.connect(kf_open_btn, SIGNAL('clicked()'), self.select_ssh_key) kf_layout = QHBoxLayout() kf_layout.addWidget(self.kf) kf_layout.addWidget(kf_open_btn) self.pw = QLineEdit() self.pw.setPlaceholderText(_('Password or ssh key passphrase')) self.pw.setEchoMode(QLineEdit.Password) ssh_form = QFormLayout() ssh_form.addRow(_('Host name'), self.hn) ssh_form.addRow(_('Ssh key'), kf_layout) ssh_form.addRow(_('Password'), self.pw) # Ok and Cancel buttons accept_btns = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.connect(accept_btns, SIGNAL('accepted()'), self.accept) self.connect(accept_btns, SIGNAL('rejected()'), self.reject) # Dialog layout layout = QVBoxLayout(self) layout.addWidget(main_label) layout.addLayout(cf_layout) layout.addWidget(self.rm_cb) layout.addLayout(ssh_form) layout.addWidget(accept_btns) # remote kernel checkbox enables the ssh_connection_form def ssh_set_enabled(state): for wid in [self.hn, self.kf, kf_open_btn, self.pw]: wid.setEnabled(state) for i in range(ssh_form.rowCount()): ssh_form.itemAt(2 * i).widget().setEnabled(state) ssh_set_enabled(self.rm_cb.checkState()) self.connect(self.rm_cb, SIGNAL('stateChanged(int)'), ssh_set_enabled)
def setup_page(self): if ERR_MSG: label = QLabel(_("Could not load plugin:\n{0}".format(ERR_MSG))) layout = QVBoxLayout() layout.addWidget(label) self.setLayout(layout) return # Layout parameter indent = QCheckBox().sizeHint().width() # General options options_group = QGroupBox(_("Options")) # Hack : the spinbox widget will be added to self.spinboxes spinboxes_before = set(self.spinboxes) passes_spin = self.create_spinbox(_("Number of pep8 passes: "), "", 'passes', default=0, min_=0, max_=1000000, step=1) spinbox = set(self.spinboxes) - spinboxes_before spinbox = spinbox.pop() spinbox.setSpecialValueText(_("Infinite")) aggressive1_checkbox = self.create_checkbox("Aggressivity level 1", "aggressive1", default=False) aggressive1_label = QLabel( _("Allow possibly unsafe fixes (E711 and W6), shorten lines" " and remove trailing whitespace more aggressively (in" " docstrings and multiline strings).")) aggressive1_label.setWordWrap(True) aggressive1_label.setIndent(indent) font_description = aggressive1_label.font() font_description.setPointSizeF(font_description.pointSize() * 0.9) aggressive1_label.setFont(font_description) aggressive2_checkbox = self.create_checkbox("Aggressivity level 2", "aggressive2", default=False) aggressive2_label = QLabel( _("Allow more possibly unsafe fixes (E712) and shorten lines.")) aggressive2_label.setWordWrap(True) aggressive2_label.setIndent(indent) aggressive2_label.setFont(font_description) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), aggressive2_checkbox.setEnabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), aggressive2_label.setEnabled) aggressive2_checkbox.setEnabled(aggressive1_checkbox.isChecked()) aggressive2_label.setEnabled(aggressive1_checkbox.isChecked()) # Enable/disable error codes fix_layout = QVBoxLayout() last_group = "" FIX_LIST.sort(key=lambda item: item[0][1]) for code, description in FIX_LIST: # Create a new group if necessary if code[1] != last_group: last_group = code[1] group = QGroupBox(_(self.GROUPS.get(code[1], ""))) fix_layout.addWidget(group) group_layout = QVBoxLayout(group) # Checkbox for the option text = code default = True if code in DEFAULT_IGNORE: text += _(" (UNSAFE)") default = False option = self.create_checkbox(text, code, default=default) # Label for description if code in self.CODES: label = QLabel("{autopep8} ({pep8}).".format( autopep8=_(description).rstrip("."), pep8=self.CODES[code])) else: label = QLabel(_(description)) label.setWordWrap(True) label.setIndent(indent) label.setFont(font_description) # Add widgets to layout option_layout = QVBoxLayout() option_layout.setSpacing(0) option_layout.addWidget(option) option_layout.addWidget(label) group_layout.addLayout(option_layout) # Special cases if code in ("E711", "W6"): self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), option.setEnabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), label.setEnabled) option.setEnabled(aggressive1_checkbox.isChecked()) label.setEnabled(aggressive1_checkbox.isChecked()) if code == "E712": def e712_enabled(): enabled = (aggressive1_checkbox.isChecked() and aggressive2_checkbox.isChecked()) option.setEnabled(enabled) label.setEnabled(enabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), e712_enabled) self.connect(aggressive2_checkbox, SIGNAL("toggled(bool)"), e712_enabled) e712_enabled() # General layout aggressive2_layout = QVBoxLayout() margins = aggressive2_layout.contentsMargins() margins.setLeft(indent) aggressive2_layout.setContentsMargins(margins) aggressive2_layout.addWidget(aggressive2_checkbox) aggressive2_layout.addWidget(aggressive2_label) options_layout = QVBoxLayout() options_layout.addWidget(passes_spin) options_layout.addWidget(aggressive1_checkbox) options_layout.addWidget(aggressive1_label) options_layout.addLayout(aggressive2_layout) options_group.setLayout(options_layout) widget_scroll = QWidget() widget_scroll.setLayout(fix_layout) fix_scroll = QScrollArea() fix_scroll.setWidget(widget_scroll) fix_scroll.setWidgetResizable(True) fig_out_layout = QVBoxLayout() fig_out_layout.addWidget(fix_scroll, 1) fix_group = QGroupBox(_("Errors/warnings to fix")) fix_group.setLayout(fig_out_layout) vlayout = QVBoxLayout() vlayout.addWidget(options_group) vlayout.addWidget(fix_group, 1) self.setLayout(vlayout)
def setup_page(self): if ERR_MSG: label = QLabel(_("Could not load plugin:\n{0}".format(ERR_MSG))) layout = QVBoxLayout() layout.addWidget(label) self.setLayout(layout) return # Layout parameter indent = QCheckBox().sizeHint().width() # General options options_group = QGroupBox(_("Options")) # Hack : the spinbox widget will be added to self.spinboxes spinboxes_before = set(self.spinboxes) passes_spin = self.create_spinbox( _("Number of pep8 passes: "), "", 'passes', default=0, min_=0, max_=1000000, step=1) spinbox = set(self.spinboxes) - spinboxes_before spinbox = spinbox.pop() spinbox.setSpecialValueText(_("Infinite")) aggressive1_checkbox = self.create_checkbox( "Aggressivity level 1", "aggressive1", default=False) aggressive1_label = QLabel(_( "Allow possibly unsafe fixes (E711 and W6), shorten lines" " and remove trailing whitespace more aggressively (in" " docstrings and multiline strings).")) aggressive1_label.setWordWrap(True) aggressive1_label.setIndent(indent) font_description = aggressive1_label.font() font_description.setPointSizeF(font_description.pointSize() * 0.9) aggressive1_label.setFont(font_description) aggressive2_checkbox = self.create_checkbox( "Aggressivity level 2", "aggressive2", default=False) aggressive2_label = QLabel(_( "Allow more possibly unsafe fixes (E712) and shorten lines.")) aggressive2_label.setWordWrap(True) aggressive2_label.setIndent(indent) aggressive2_label.setFont(font_description) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), aggressive2_checkbox.setEnabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), aggressive2_label.setEnabled) aggressive2_checkbox.setEnabled(aggressive1_checkbox.isChecked()) aggressive2_label.setEnabled(aggressive1_checkbox.isChecked()) # Enable/disable error codes fix_layout = QVBoxLayout() last_group = "" FIX_LIST.sort(key=lambda item: item[0][1]) for code, description in FIX_LIST: # Create a new group if necessary if code[1] != last_group: last_group = code[1] group = QGroupBox(_(self.GROUPS.get(code[1], ""))) fix_layout.addWidget(group) group_layout = QVBoxLayout(group) # Checkbox for the option text = code default = True if code in DEFAULT_IGNORE: text += _(" (UNSAFE)") default = False option = self.create_checkbox(text, code, default=default) # Label for description if code in self.CODES: label = QLabel("{autopep8} ({pep8}).".format( autopep8=_(description).rstrip("."), pep8=self.CODES[code])) else: label = QLabel(_(description)) label.setWordWrap(True) label.setIndent(indent) label.setFont(font_description) # Add widgets to layout option_layout = QVBoxLayout() option_layout.setSpacing(0) option_layout.addWidget(option) option_layout.addWidget(label) group_layout.addLayout(option_layout) # Special cases if code in ("E711", "W6"): self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), option.setEnabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), label.setEnabled) option.setEnabled(aggressive1_checkbox.isChecked()) label.setEnabled(aggressive1_checkbox.isChecked()) if code == "E712": def e712_enabled(): enabled = (aggressive1_checkbox.isChecked() and aggressive2_checkbox.isChecked()) option.setEnabled(enabled) label.setEnabled(enabled) self.connect(aggressive1_checkbox, SIGNAL("toggled(bool)"), e712_enabled) self.connect(aggressive2_checkbox, SIGNAL("toggled(bool)"), e712_enabled) e712_enabled() # General layout aggressive2_layout = QVBoxLayout() margins = aggressive2_layout.contentsMargins() margins.setLeft(indent) aggressive2_layout.setContentsMargins(margins) aggressive2_layout.addWidget(aggressive2_checkbox) aggressive2_layout.addWidget(aggressive2_label) options_layout = QVBoxLayout() options_layout.addWidget(passes_spin) options_layout.addWidget(aggressive1_checkbox) options_layout.addWidget(aggressive1_label) options_layout.addLayout(aggressive2_layout) options_group.setLayout(options_layout) widget_scroll = QWidget() widget_scroll.setLayout(fix_layout) fix_scroll = QScrollArea() fix_scroll.setWidget(widget_scroll) fix_scroll.setWidgetResizable(True) fig_out_layout = QVBoxLayout() fig_out_layout.addWidget(fix_scroll, 1) fix_group = QGroupBox(_("Errors/warnings to fix")) fix_group.setLayout(fig_out_layout) vlayout = QVBoxLayout() vlayout.addWidget(options_group) vlayout.addWidget(fix_group, 1) self.setLayout(vlayout)
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]) desc_label.setWordWrap(True) param_label = QGridLayout() nm = QLabel("Name:") des = QLabel("Description:") repl = QLabel("Replace with:") param_label.addWidget(nm, 0, 0) param_label.addWidget(des, 0, 1) param_label.addWidget(repl, 0, 2) """g is the total number of alterable values""" g = 0 """t is the total number of alterable non-parameters""" t = 1 snum = 0 pnum = 0 inum = 0 """range of N is the max number of possible substrates OR products""" N = 5 for n in range(N): nl = n + 1 if (infixmod[j].find('S%s' % nl) > -1): z = QLabel('S%s is present' % nl) param_label.addWidget(z, t, 0) snum = snum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('P%s' % nl) > -1): z = QLabel('P%s is present' % nl) param_label.addWidget(z, t, 0) pnum = pnum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('I%s' % nl) > -1): z = QLabel('I%s is present' % nl) param_label.addWidget(z, t, 0) inum = inum + 1 t = t + 1 """Initialize lists of list of parameter lineedit""" length = len(parameternamelistlist[j]) for b in range(length): p = QLabel("%s :" % parameternamelistlist[j][b]) param_label.addWidget(p, b + t, 0) d = QLabel("'%s'" % parameterdesclistlist[j][b]) param_label.addWidget(d, b + t, 1) g = t + length Slineeditlist = [0 for x in range(snum)] Plineeditlist = [0 for x in range(pnum)] Ilineeditlist = [0 for x in range(inum)] paramlineeditlist = [0 for x in range(length)] editcount = 1 """Place lineedit widgets for parameters""" for s in range(snum): Slineeditlist[s] = QLineEdit() param_label.addWidget(Slineeditlist[s], editcount, 2) editcount = editcount + 1 SLElistlist[j] = Slineeditlist for s in range(pnum): Plineeditlist[s] = QLineEdit() param_label.addWidget(Plineeditlist[s], editcount, 2) editcount = editcount + 1 PLElistlist[j] = Plineeditlist for s in range(inum): Ilineeditlist[s] = QLineEdit() param_label.addWidget(Ilineeditlist[s], editcount, 2) editcount = editcount + 1 ILElistlist[j] = Ilineeditlist for s in range(length): paramlineeditlist[s] = QLineEdit() param_label.addWidget(paramlineeditlist[s], editcount, 2) editcount = editcount + 1 paramLElistlist[j] = paramlineeditlist """Necessary lists for editable parameters. Housekeeping essentially.""" stuff = paramlineeditlist[0].text() numlistlist[j] = [snum, pnum, inum, length] charlist = ["S", "P", "I"] buttonlist.append(QPushButton(self)) buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j]) # 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 """Page formatting""" setup_layout = QVBoxLayout() setup_layout.addWidget(setup_label) setup_group.setLayout(setup_layout) desc_group.setLayout(param_label) vlayout = QVBoxLayout() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addWidget(buttonlist[j]) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) """Set up button functionality""" for k in range(47): buttonlist[k].clicked.connect( pressbutton(self, infixmod[k], SLElistlist[k], PLElistlist[k], ILElistlist[k], paramLElistlist[k], parameternamelistlist[k], numlistlist[k], charlist, k)) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) self.lawlist.setCurrentRow(0) """Set up high-level widget formatting.""" hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
def __init__(self, parent=None): super(KernelConnectionDialog, self).__init__(parent) self.setWindowTitle(_('Connect to an existing kernel')) main_label = QLabel( _("Please enter the connection info of the kernel " "you want to connect to. For that you can " "either select its JSON connection file using " "the <tt>Browse</tt> button, or write directly " "its id, in case it's a local kernel (for " "example <tt>kernel-3764.json</tt> or just " "<tt>3764</tt>).")) main_label.setWordWrap(True) main_label.setAlignment(Qt.AlignJustify) # connection file cf_label = QLabel(_('Connection info:')) self.cf = QLineEdit() self.cf.setPlaceholderText(_('Path to connection file or kernel id')) self.cf.setMinimumWidth(250) cf_open_btn = QPushButton(_('Browse')) self.connect(cf_open_btn, SIGNAL('clicked()'), self.select_connection_file) cf_layout = QHBoxLayout() cf_layout.addWidget(cf_label) cf_layout.addWidget(self.cf) cf_layout.addWidget(cf_open_btn) # remote kernel checkbox self.rm_cb = QCheckBox(_('This is a remote kernel')) # ssh connection self.hn = QLineEdit() self.hn.setPlaceholderText(_('username@hostname:port')) self.kf = QLineEdit() self.kf.setPlaceholderText(_('Path to ssh key file')) kf_open_btn = QPushButton(_('Browse')) self.connect(kf_open_btn, SIGNAL('clicked()'), self.select_ssh_key) kf_layout = QHBoxLayout() kf_layout.addWidget(self.kf) kf_layout.addWidget(kf_open_btn) self.pw = QLineEdit() self.pw.setPlaceholderText(_('Password or ssh key passphrase')) self.pw.setEchoMode(QLineEdit.Password) ssh_form = QFormLayout() ssh_form.addRow(_('Host name'), self.hn) ssh_form.addRow(_('Ssh key'), kf_layout) ssh_form.addRow(_('Password'), self.pw) # Ok and Cancel buttons accept_btns = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.connect(accept_btns, SIGNAL('accepted()'), self.accept) self.connect(accept_btns, SIGNAL('rejected()'), self.reject) # Dialog layout layout = QVBoxLayout(self) layout.addWidget(main_label) layout.addLayout(cf_layout) layout.addWidget(self.rm_cb) layout.addLayout(ssh_form) layout.addWidget(accept_btns) # remote kernel checkbox enables the ssh_connection_form def ssh_set_enabled(state): for wid in [self.hn, self.kf, kf_open_btn, self.pw]: wid.setEnabled(state) for i in range(ssh_form.rowCount()): ssh_form.itemAt(2 * i).widget().setEnabled(state) ssh_set_enabled(self.rm_cb.checkState()) self.connect(self.rm_cb, SIGNAL('stateChanged(int)'), ssh_set_enabled)
def setup_page(self): # Connections group connections_group = QGroupBox(_("Automatic connections")) connections_label = QLabel(_("This pane can automatically " "show an object's help information after " "a left parenthesis is written next to it. " "Below you can decide to which plugin " "you want to connect it to turn on this " "feature.")) connections_label.setWordWrap(True) editor_box = self.create_checkbox(_("Editor"), 'connect/editor') rope_installed = programs.is_module_installed('rope') jedi_installed = programs.is_module_installed('jedi', '>=0.8.1') editor_box.setEnabled(rope_installed or jedi_installed) if not rope_installed and not jedi_installed: editor_tip = _("This feature requires the Rope or Jedi libraries.\n" "It seems you don't have either installed.") editor_box.setToolTip(editor_tip) python_box = self.create_checkbox(_("Python Console"), 'connect/python_console') ipython_box = self.create_checkbox(_("IPython Console"), 'connect/ipython_console') ipython_box.setEnabled(QTCONSOLE_INSTALLED) connections_layout = QVBoxLayout() connections_layout.addWidget(connections_label) connections_layout.addWidget(editor_box) connections_layout.addWidget(python_box) connections_layout.addWidget(ipython_box) connections_group.setLayout(connections_layout) # Features group features_group = QGroupBox(_("Additional features")) math_box = self.create_checkbox(_("Render mathematical equations"), 'math') req_sphinx = programs.is_module_installed('sphinx', '>=1.1') math_box.setEnabled(req_sphinx) if not req_sphinx: sphinx_ver = programs.get_module_version('sphinx') sphinx_tip = _("This feature requires Sphinx 1.1 or superior.") sphinx_tip += "\n" + _("Sphinx %s is currently installed.") % sphinx_ver math_box.setToolTip(sphinx_tip) features_layout = QVBoxLayout() features_layout.addWidget(math_box) features_group.setLayout(features_layout) # Source code group sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_group.setLayout(sourcecode_layout) # Final layout vlayout = QVBoxLayout() vlayout.addWidget(connections_group) vlayout.addWidget(features_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): about_label = QLabel(_("The <b>global working directory</b> is " "the working directory for newly opened <i>consoles</i> " "(Python/IPython consoles and terminals), for the " "<i>file explorer</i>, for the <i>find in files</i> " "plugin and for new files created in the <i>editor</i>.")) about_label.setWordWrap(True) startup_group = QGroupBox(_("Startup")) startup_bg = QButtonGroup(startup_group) startup_label = QLabel(_("At startup, the global working " "directory is:")) startup_label.setWordWrap(True) lastdir_radio = self.create_radiobutton( _("the same as in last session"), 'startup/use_last_directory', True, _("At startup, Spyder will restore the " "global directory from last session"), button_group=startup_bg) thisdir_radio = self.create_radiobutton( _("the following directory:"), 'startup/use_fixed_directory', False, _("At startup, the global working " "directory will be the specified path"), button_group=startup_bg) thisdir_bd = self.create_browsedir("", 'startup/fixed_directory', getcwd()) self.connect(thisdir_radio, SIGNAL("toggled(bool)"), thisdir_bd.setEnabled) self.connect(lastdir_radio, SIGNAL("toggled(bool)"), thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) editor_o_group = QGroupBox(_("Open file")) editor_o_label = QLabel(_("Files are opened from:")) editor_o_label.setWordWrap(True) editor_o_bg = QButtonGroup(editor_o_group) editor_o_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/open/browse_scriptdir', button_group=editor_o_bg) editor_o_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/open/browse_workdir', button_group=editor_o_bg) editor_n_group = QGroupBox(_("New file")) editor_n_label = QLabel(_("Files are created in:")) editor_n_label.setWordWrap(True) editor_n_bg = QButtonGroup(editor_n_group) editor_n_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/new/browse_scriptdir', button_group=editor_n_bg) editor_n_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/new/browse_workdir', button_group=editor_n_bg) # Note: default values for the options above are set in plugin's # constructor (see below) other_group = QGroupBox(_("Change to file base directory")) newcb = self.create_checkbox open_box = newcb(_("When opening a file"), 'editor/open/auto_set_to_basedir') save_box = newcb(_("When saving a file"), 'editor/save/auto_set_to_basedir') startup_layout = QVBoxLayout() startup_layout.addWidget(startup_label) startup_layout.addWidget(lastdir_radio) startup_layout.addLayout(thisdir_layout) startup_group.setLayout(startup_layout) editor_o_layout = QVBoxLayout() editor_o_layout.addWidget(editor_o_label) editor_o_layout.addWidget(editor_o_radio1) editor_o_layout.addWidget(editor_o_radio2) editor_o_group.setLayout(editor_o_layout) editor_n_layout = QVBoxLayout() editor_n_layout.addWidget(editor_n_label) editor_n_layout.addWidget(editor_n_radio1) editor_n_layout.addWidget(editor_n_radio2) editor_n_group.setLayout(editor_n_layout) other_layout = QVBoxLayout() other_layout.addWidget(open_box) other_layout.addWidget(save_box) other_group.setLayout(other_layout) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(startup_group) vlayout.addWidget(editor_o_group) vlayout.addWidget(editor_n_group) vlayout.addWidget(other_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): newcb = self.create_checkbox mpl_present = programs.is_module_installed("matplotlib") # --- Display --- font_group = self.create_fontgroup(option=None, text=None, fontfilters=QFontComboBox.MonospacedFonts) # Interface Group interface_group = QGroupBox(_("Interface")) banner_box = newcb(_("Display initial banner"), 'show_banner', tip=_("This option lets you hide the message shown at\n" "the top of the console when it's opened.")) gui_comp_box = newcb(_("Use a completion widget"), 'use_gui_completion', tip=_("Use a widget instead of plain text " "output for tab completion")) pager_box = newcb(_("Use a pager to display additional text inside " "the console"), 'use_pager', tip=_("Useful if you don't want to fill the " "console with long help or completion texts.\n" "Note: Use the Q key to get out of the " "pager.")) calltips_box = newcb(_("Display balloon tips"), 'show_calltips') ask_box = newcb(_("Ask for confirmation before closing"), 'ask_before_closing') interface_layout = QVBoxLayout() interface_layout.addWidget(banner_box) interface_layout.addWidget(gui_comp_box) interface_layout.addWidget(pager_box) interface_layout.addWidget(calltips_box) interface_layout.addWidget(ask_box) interface_group.setLayout(interface_layout) # Background Color Group bg_group = QGroupBox(_("Background color")) light_radio = self.create_radiobutton(_("Light background"), 'light_color') dark_radio = self.create_radiobutton(_("Dark background"), 'dark_color') bg_layout = QVBoxLayout() bg_layout.addWidget(light_radio) bg_layout.addWidget(dark_radio) bg_group.setLayout(bg_layout) # Source Code Group source_code_group = QGroupBox(_("Source code")) buffer_spin = self.create_spinbox( _("Buffer: "), _(" lines"), 'buffer_size', min_=-1, max_=1000000, step=100, tip=_("Set the maximum number of lines of text shown in the\n" "console before truncation. Specifying -1 disables it\n" "(not recommended!)")) source_code_layout = QVBoxLayout() source_code_layout.addWidget(buffer_spin) source_code_group.setLayout(source_code_layout) # --- Graphics --- # Pylab Group pylab_group = QGroupBox(_("Support for graphics (Matplotlib)")) pylab_box = newcb(_("Activate support"), 'pylab') autoload_pylab_box = newcb(_("Automatically load Pylab and NumPy " "modules"), 'pylab/autoload', tip=_("This lets you load graphics support " "without importing \nthe commands to do " "plots. Useful to work with other\n" "plotting libraries different to " "Matplotlib or to develop \nGUIs with " "Spyder.")) autoload_pylab_box.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), autoload_pylab_box.setEnabled) pylab_layout = QVBoxLayout() pylab_layout.addWidget(pylab_box) pylab_layout.addWidget(autoload_pylab_box) pylab_group.setLayout(pylab_layout) if not mpl_present: self.set_option('pylab', False) self.set_option('pylab/autoload', False) pylab_group.setEnabled(False) pylab_tip = _("This feature requires the Matplotlib library.\n" "It seems you don't have it installed.") pylab_box.setToolTip(pylab_tip) # Pylab backend Group inline = _("Inline") automatic = _("Automatic") backend_group = QGroupBox(_("Graphics backend")) bend_label = QLabel(_("Decide how graphics are going to be displayed " "in the console. If unsure, please select " "<b>%s</b> to put graphics inside the " "console or <b>%s</b> to interact with " "them (through zooming and panning) in a " "separate window.") % (inline, automatic)) bend_label.setWordWrap(True) backends = [(inline, 0), (automatic, 1), ("Qt", 2)] # TODO: Add gtk3 when 0.13 is released if sys.platform == 'darwin': backends.append( ("Mac OSX", 3) ) if programs.is_module_installed('pygtk'): backends.append( ("Gtk", 4) ) if programs.is_module_installed('wxPython'): backends.append( ("Wx", 5) ) if programs.is_module_installed('_tkinter'): backends.append( ("Tkinter", 6) ) backends = tuple(backends) backend_box = self.create_combobox( _("Backend:")+" ", backends, 'pylab/backend', default=0, tip=_("This option will be applied the " "next time a console is opened.")) backend_layout = QVBoxLayout() backend_layout.addWidget(bend_label) backend_layout.addWidget(backend_box) backend_group.setLayout(backend_layout) backend_group.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), backend_group.setEnabled) # Inline backend Group inline_group = QGroupBox(_("Inline backend")) inline_label = QLabel(_("Decide how to render the figures created by " "this backend")) inline_label.setWordWrap(True) formats = (("PNG", 0), ("SVG", 1)) format_box = self.create_combobox(_("Format:")+" ", formats, 'pylab/inline/figure_format', default=0) resolution_spin = self.create_spinbox( _("Resolution:")+" ", " "+_("dpi"), 'pylab/inline/resolution', min_=56, max_=112, step=1, tip=_("Only used when the format is PNG. Default is " "72")) width_spin = self.create_spinbox( _("Width:")+" ", " "+_("inches"), 'pylab/inline/width', min_=2, max_=20, step=1, tip=_("Default is 6")) height_spin = self.create_spinbox( _("Height:")+" ", " "+_("inches"), 'pylab/inline/height', min_=1, max_=20, step=1, tip=_("Default is 4")) inline_layout = QVBoxLayout() inline_layout.addWidget(inline_label) inline_layout.addWidget(format_box) inline_layout.addWidget(resolution_spin) inline_layout.addWidget(width_spin) inline_layout.addWidget(height_spin) inline_group.setLayout(inline_layout) inline_group.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), inline_group.setEnabled) # --- Startup --- # Run lines Group run_lines_group = QGroupBox(_("Run code")) run_lines_label = QLabel(_("You can run several lines of code when " "a console is started. Please introduce " "each one separated by commas, for " "example:<br>" "<i>import os, import sys</i>")) run_lines_label.setWordWrap(True) run_lines_edit = self.create_lineedit(_("Lines:"), 'startup/run_lines', '', alignment=Qt.Horizontal) run_lines_layout = QVBoxLayout() run_lines_layout.addWidget(run_lines_label) run_lines_layout.addWidget(run_lines_edit) run_lines_group.setLayout(run_lines_layout) # Run file Group run_file_group = QGroupBox(_("Run a file")) run_file_label = QLabel(_("You can also run a whole file at startup " "instead of just some lines (This is " "similar to have a PYTHONSTARTUP file).")) run_file_label.setWordWrap(True) file_radio = newcb(_("Use the following file:"), 'startup/use_run_file', False) run_file_browser = self.create_browsefile('', 'startup/run_file', '') run_file_browser.setEnabled(False) self.connect(file_radio, SIGNAL("toggled(bool)"), run_file_browser.setEnabled) run_file_layout = QVBoxLayout() run_file_layout.addWidget(run_file_label) run_file_layout.addWidget(file_radio) run_file_layout.addWidget(run_file_browser) run_file_group.setLayout(run_file_layout) # ---- Advanced settings ---- # Greedy completer group greedy_group = QGroupBox(_("Greedy completion")) greedy_label = QLabel(_("Enable <tt>Tab</tt> completion on elements " "of lists, results of function calls, etc, " "<i>without</i> assigning them to a " "variable.<br>" "For example, you can get completions on " "things like <tt>li[0].<Tab></tt> or " "<tt>ins.meth().<Tab></tt>")) greedy_label.setWordWrap(True) greedy_box = newcb(_("Use the greedy completer"), "greedy_completer", tip="<b>Warning</b>: It can be unsafe because the " "code is actually evaluated when you press " "<tt>Tab</tt>.") greedy_layout = QVBoxLayout() greedy_layout.addWidget(greedy_label) greedy_layout.addWidget(greedy_box) greedy_group.setLayout(greedy_layout) # Autocall group autocall_group = QGroupBox(_("Autocall")) autocall_label = QLabel(_("Autocall makes IPython automatically call " "any callable object even if you didn't type " "explicit parentheses.<br>" "For example, if you type <i>str 43</i> it " "becomes <i>str(43)</i> automatically.")) autocall_label.setWordWrap(True) smart = _('Smart') full = _('Full') autocall_opts = ((_('Off'), 0), (smart, 1), (full, 2)) autocall_box = self.create_combobox( _("Autocall: "), autocall_opts, 'autocall', default=0, tip=_("On <b>%s</b> mode, Autocall is not applied if " "there are no arguments after the callable. On " "<b>%s</b> mode, all callable objects are " "automatically called (even if no arguments are " "present).") % (smart, full)) autocall_layout = QVBoxLayout() autocall_layout.addWidget(autocall_label) autocall_layout.addWidget(autocall_box) autocall_group.setLayout(autocall_layout) # Sympy group sympy_group = QGroupBox(_("Symbolic Mathematics")) sympy_label = QLabel(_("Perfom symbolic operations in the console " "(e.g. integrals, derivatives, vector calculus, " "etc) and get the outputs in a beautifully " "printed style.")) sympy_label.setWordWrap(True) sympy_box = newcb(_("Use symbolic math"), "symbolic_math", tip=_("This option loads the Sympy library to work " "with.<br>Please refer to its documentation to " "learn how to use it.")) sympy_layout = QVBoxLayout() sympy_layout.addWidget(sympy_label) sympy_layout.addWidget(sympy_box) sympy_group.setLayout(sympy_layout) sympy_present = programs.is_module_installed("sympy") if not sympy_present: self.set_option("symbolic_math", False) sympy_box.setEnabled(False) sympy_tip = _("This feature requires the Sympy library.\n" "It seems you don't have it installed.") sympy_box.setToolTip(sympy_tip) # Prompts group prompts_group = QGroupBox(_("Prompts")) prompts_label = QLabel(_("Modify how Input and Output prompts are " "shown in the console.")) prompts_label.setWordWrap(True) in_prompt_edit = self.create_lineedit(_("Input prompt:"), 'in_prompt', '', _('Default is<br>' 'In [<span class="in-prompt-number">' '%i</span>]:'), alignment=Qt.Horizontal) out_prompt_edit = self.create_lineedit(_("Output prompt:"), 'out_prompt', '', _('Default is<br>' 'Out[<span class="out-prompt-number">' '%i</span>]:'), alignment=Qt.Horizontal) prompts_layout = QVBoxLayout() prompts_layout.addWidget(prompts_label) prompts_layout.addWidget(in_prompt_edit) prompts_layout.addWidget(out_prompt_edit) prompts_group.setLayout(prompts_layout) # --- Tabs organization --- tabs = QTabWidget() tabs.addTab(self.create_tab(font_group, interface_group, bg_group, source_code_group), _("Display")) tabs.addTab(self.create_tab(pylab_group, backend_group, inline_group), _("Graphics")) tabs.addTab(self.create_tab(run_lines_group, run_file_group), _("Startup")) tabs.addTab(self.create_tab(greedy_group, autocall_group, sympy_group, prompts_group), _("Advanced Settings")) vlayout = QVBoxLayout() vlayout.addWidget(tabs) self.setLayout(vlayout)
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() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) #self.connect(self.lawlist, SIGNAL(self.lawlist.currentRowChanged(int)),self.lawpage,SLOT(self.lawpage.setCurrentIndex(int))) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) ''' self.lawpage = QWidget() ''' self.lawlist.setCurrentRow(0) hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hlayout1 = QHBoxLayout() hlayout1.addWidget(self.textlabel) hlayout1.addStretch() self.lawpage.setLayout(hlayout1) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton(CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton(DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton(SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) wdir_group = QGroupBox(_("Working directory")) wdir_bg = QButtonGroup(wdir_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) self.connect(thisdir_radio, SIGNAL("toggled(bool)"), thisdir_bd.setEnabled) self.connect(dirname_radio, SIGNAL("toggled(bool)"), thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) wdir_layout = QVBoxLayout() wdir_layout.addWidget(wdir_label) wdir_layout.addWidget(dirname_radio) wdir_layout.addLayout(thisdir_layout) wdir_group.setLayout(wdir_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(wdir_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): # Fonts group plain_text_font_group = self.create_fontgroup( option=None, text=_("Plain text font style"), fontfilters=QFontComboBox.MonospacedFonts) rich_text_font_group = self.create_fontgroup( option='rich_text', text=_("Rich text font style")) # Connections group connections_group = QGroupBox(_("Automatic connections")) connections_label = QLabel( _("The Object Inspector can automatically " "show an object's help information after " "a left parenthesis is written next to it. " "Below you can decide to which plugin " "you want to connect it to turn on this " "feature.")) connections_label.setWordWrap(True) editor_box = self.create_checkbox(_("Editor"), 'connect/editor') rope_installed = programs.is_module_installed('rope') jedi_installed = programs.is_module_installed('jedi', '>=0.8.0') editor_box.setEnabled(rope_installed or jedi_installed) # TODO: Don't forget to add Jedi here if not rope_installed: rope_tip = _("This feature requires the Rope library.\n" "It seems you don't have it installed.") editor_box.setToolTip(rope_tip) python_box = self.create_checkbox(_("Python Console"), 'connect/python_console') ipython_box = self.create_checkbox(_("IPython Console"), 'connect/ipython_console') ipython_installed = programs.is_module_installed('IPython', '>=0.13') ipython_box.setEnabled(ipython_installed) connections_layout = QVBoxLayout() connections_layout.addWidget(connections_label) connections_layout.addWidget(editor_box) connections_layout.addWidget(python_box) connections_layout.addWidget(ipython_box) connections_group.setLayout(connections_layout) # Features group features_group = QGroupBox(_("Additional features")) math_box = self.create_checkbox(_("Render mathematical equations"), 'math') req_sphinx = sphinx_version is not None and \ programs.is_module_installed('sphinx', '>=1.1') math_box.setEnabled(req_sphinx) if not req_sphinx: sphinx_tip = _("This feature requires Sphinx 1.1 or superior.") if sphinx_version is not None: sphinx_tip += "\n" + _( "Sphinx %s is currently installed.") % sphinx_version math_box.setToolTip(sphinx_tip) features_layout = QVBoxLayout() features_layout.addWidget(math_box) features_group.setLayout(features_layout) # Source code group sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') names = CONF.get('color_schemes', 'names') choices = list(zip(names, names)) cs_combo = self.create_combobox(_("Syntax color scheme: "), choices, 'color_scheme_name') sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_layout.addWidget(cs_combo) sourcecode_group.setLayout(sourcecode_layout) # Final layout vlayout = QVBoxLayout() vlayout.addWidget(rich_text_font_group) vlayout.addWidget(plain_text_font_group) vlayout.addWidget(connections_group) vlayout.addWidget(features_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): # Fonts group plain_text_font_group = self.create_fontgroup(option=None, text=_("Plain text font style"), fontfilters=QFontComboBox.MonospacedFonts) rich_text_font_group = self.create_fontgroup(option='rich_text', text=_("Rich text font style")) # Connections group connections_group = QGroupBox(_("Automatic connections")) connections_label = QLabel(_("This pane can automatically " "show an object's help information after " "a left parenthesis is written next to it. " "Below you can decide to which plugin " "you want to connect it to turn on this " "feature.")) connections_label.setWordWrap(True) editor_box = self.create_checkbox(_("Editor"), 'connect/editor') rope_installed = programs.is_module_installed('rope') jedi_installed = programs.is_module_installed('jedi', '>=0.8.1') editor_box.setEnabled(rope_installed or jedi_installed) if not rope_installed and not jedi_installed: editor_tip = _("This feature requires the Rope or Jedi libraries.\n" "It seems you don't have either installed.") editor_box.setToolTip(editor_tip) python_box = self.create_checkbox(_("Python Console"), 'connect/python_console') ipython_box = self.create_checkbox(_("IPython Console"), 'connect/ipython_console') ipython_box.setEnabled(QTCONSOLE_INSTALLED) connections_layout = QVBoxLayout() connections_layout.addWidget(connections_label) connections_layout.addWidget(editor_box) connections_layout.addWidget(python_box) connections_layout.addWidget(ipython_box) connections_group.setLayout(connections_layout) # Features group features_group = QGroupBox(_("Additional features")) math_box = self.create_checkbox(_("Render mathematical equations"), 'math') req_sphinx = sphinx_version is not None and \ programs.is_module_installed('sphinx', '>=1.1') math_box.setEnabled(req_sphinx) if not req_sphinx: sphinx_tip = _("This feature requires Sphinx 1.1 or superior.") if sphinx_version is not None: sphinx_tip += "\n" + _("Sphinx %s is currently installed." ) % sphinx_version math_box.setToolTip(sphinx_tip) features_layout = QVBoxLayout() features_layout.addWidget(math_box) features_group.setLayout(features_layout) # Source code group sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') names = CONF.get('color_schemes', 'names') choices = list(zip(names, names)) cs_combo = self.create_combobox(_("Syntax color scheme: "), choices, 'color_scheme_name') sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_layout.addWidget(cs_combo) sourcecode_group.setLayout(sourcecode_layout) # Final layout vlayout = QVBoxLayout() vlayout.addWidget(rich_text_font_group) vlayout.addWidget(plain_text_font_group) vlayout.addWidget(connections_group) vlayout.addWidget(features_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
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 """ Parsing xml: Acquiring rate law name, description, and list of parameter information """ 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" """Creates "description" string""" #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]) """Creates list entry for each rate law""" self.lawlist.addItem(item) """Adds rate law to list""" self.lawdetailpage = QWidget() """Creates page for each rate law""" # Page layout will become its own function setup_group = QGroupBox(displaynamelist[j]) """Creates box with rate law name as title""" infixmod = infixlist[j].replace("___"," ") setup_label = QLabel(infixmod) setup_label.setWordWrap(True) """types rate law expression, removing underscores""" desc_group = QGroupBox("Description") """creates box for 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() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) """Formats the page shown when a rate law is selected""" #self.connect(self.lawlist, SIGNAL(self.lawlist.currentRowChanged(int)),self.lawpage,SLOT(self.lawpage.setCurrentIndex(int))) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) """When a rate law in the list is clicked, its corresponding page is shown""" ''' self.lawpage = QWidget() ''' self.lawlist.setCurrentRow(0) hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) "Adds list to left side of window" hlayout1 = QHBoxLayout() hlayout1.addWidget(self.textlabel) hlayout1.addStretch() self.lawpage.setLayout(hlayout1) hsplitter.addWidget(self.lawpage) """Adds law page to left side of window""" layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
class FadingTipBox(FadingDialog): """ """ def __init__(self, parent, opacity, duration, easing_curve): super(FadingTipBox, self).__init__(parent, opacity, duration, easing_curve) self.holder = self.anim # needed for qt to work self.parent = parent self.frames = None self.color_top = QColor.fromRgb(230, 230, 230) self.color_back = QColor.fromRgb(255, 255, 255) self.offset_shadow = 0 self.fixed_width = 300 self.key_pressed = None self.setAttribute(Qt.WA_TranslucentBackground) self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setModal(False) # Widgets self.button_home = QPushButton("<<") self.button_close = QPushButton("X") self.button_previous = QPushButton(" < ") self.button_end = QPushButton(">>") self.button_next = QPushButton(" > ") self.button_run = QPushButton(_('Run code')) self.button_disable = None self.button_current = QToolButton() self.label_image = QLabel() self.label_title = QLabel() self.combo_title = QComboBox() self.label_current = QLabel() self.label_content = QLabel() self.label_content.setMinimumWidth(self.fixed_width) self.label_content.setMaximumWidth(self.fixed_width) self.label_current.setAlignment(Qt.AlignCenter) self.label_content.setWordWrap(True) self.widgets = [self.label_content, self.label_title, self.label_current, self.combo_title, self.button_close, self.button_run, self.button_next, self.button_previous, self.button_end, self.button_home, self.button_current] arrow = get_image_path('hide.png') self.stylesheet = '''QPushButton { background-color: rgbs(200,200,200,100%); color: rgbs(0,0,0,100%); border-style: outset; border-width: 1px; border-radius: 3px; border-color: rgbs(100,100,100,100%); padding: 2px; } QPushButton:hover { background-color: rgbs(150, 150, 150, 100%); } QPushButton:disabled { background-color: rgbs(230,230,230,100%); color: rgbs(200,200,200,100%); border-color: rgbs(200,200,200,100%); } QComboBox { padding-left: 5px; background-color: rgbs(230,230,230,100%); border-width: 0px; border-radius: 0px; min-height:20px; max-height:20px; } QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top left; border-width: 0px; } QComboBox::down-arrow { image: url(''' + arrow + '''); } ''' # Windows fix, slashes should be always in unix-style self.stylesheet = self.stylesheet.replace('\\', '/') for widget in self.widgets: widget.setFocusPolicy(Qt.NoFocus) widget.setStyleSheet(self.stylesheet) layout_top = QHBoxLayout() layout_top.addWidget(self.combo_title) layout_top.addStretch() layout_top.addWidget(self.button_close) layout_top.addSpacerItem(QSpacerItem(self.offset_shadow, self.offset_shadow)) layout_content = QHBoxLayout() layout_content.addWidget(self.label_content) layout_content.addWidget(self.label_image) layout_content.addSpacerItem(QSpacerItem(5, 5)) layout_run = QHBoxLayout() layout_run.addStretch() layout_run.addWidget(self.button_run) layout_run.addStretch() layout_run.addSpacerItem(QSpacerItem(self.offset_shadow, self.offset_shadow)) layout_navigation = QHBoxLayout() layout_navigation.addWidget(self.button_home) layout_navigation.addWidget(self.button_previous) layout_navigation.addStretch() layout_navigation.addWidget(self.label_current) layout_navigation.addStretch() layout_navigation.addWidget(self.button_next) layout_navigation.addWidget(self.button_end) layout_navigation.addSpacerItem(QSpacerItem(self.offset_shadow, self.offset_shadow)) layout = QVBoxLayout() layout.addLayout(layout_top) layout.addStretch() layout.addSpacerItem(QSpacerItem(15, 15)) layout.addLayout(layout_content) layout.addLayout(layout_run) layout.addStretch() layout.addSpacerItem(QSpacerItem(15, 15)) layout.addLayout(layout_navigation) layout.addSpacerItem(QSpacerItem(self.offset_shadow, self.offset_shadow)) layout.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(layout) self.set_funcs_before_fade_in([self._disable_widgets]) self.set_funcs_after_fade_in([self._enable_widgets]) self.set_funcs_before_fade_out([self._disable_widgets]) self.setContextMenuPolicy(Qt.CustomContextMenu) # signals and slots # These are defined every time by the AnimatedTour Class def _disable_widgets(self): """ """ for widget in self.widgets: widget.setDisabled(True) def _enable_widgets(self): """ """ self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) for widget in self.widgets: widget.setDisabled(False) if self.button_disable == 'previous': self.button_previous.setDisabled(True) self.button_home.setDisabled(True) elif self.button_disable == 'next': self.button_next.setDisabled(True) self.button_end.setDisabled(True) def set_data(self, title, content, current, image, run, frames=None, step=None): """ """ self.label_title.setText(title) self.combo_title.clear() self.combo_title.addItems(frames) self.combo_title.setCurrentIndex(step) # min_content_len = max([len(f) for f in frames]) # self.combo_title.setMinimumContentsLength(min_content_len) # Fix and try to see how it looks with a combo box self.label_current.setText(current) self.button_current.setText(current) self.label_content.setText(content) self.image = image if image is None: self.label_image.setFixedHeight(1) self.label_image.setFixedWidth(1) else: extension = image.split('.')[-1] self.image = QPixmap(get_image_path(image), extension) self.label_image.setPixmap(self.image) self.label_image.setFixedSize(self.image.size()) if run is None: self.button_run.setVisible(False) else: self.button_run.setDisabled(False) self.button_run.setVisible(True) # Refresh layout self.layout().activate() def set_pos(self, x, y): """ """ self.x = x self.y = y self.move(QPoint(x, y)) def build_paths(self): """ """ geo = self.geometry() radius = 30 shadow = self.offset_shadow x0, y0 = geo.x(), geo.y() width, height = geo.width() - shadow, geo.height() - shadow left, top = 0, 0 right, bottom = width, height self.round_rect_path = QPainterPath() self.round_rect_path.moveTo(right, top + radius) self.round_rect_path.arcTo(right-radius, top, radius, radius, 0.0, 90.0) self.round_rect_path.lineTo(left+radius, top) self.round_rect_path.arcTo(left, top, radius, radius, 90.0, 90.0) self.round_rect_path.lineTo(left, bottom-radius) self.round_rect_path.arcTo(left, bottom-radius, radius, radius, 180.0, 90.0) self.round_rect_path.lineTo(right-radius, bottom) self.round_rect_path.arcTo(right-radius, bottom-radius, radius, radius, 270.0, 90.0) self.round_rect_path.closeSubpath() # Top path header = 36 offset = 2 left, top = offset, offset right = width - (offset) self.top_rect_path = QPainterPath() self.top_rect_path.lineTo(right, top + radius) self.top_rect_path.moveTo(right, top + radius) self.top_rect_path.arcTo(right-radius, top, radius, radius, 0.0, 90.0) self.top_rect_path.lineTo(left+radius, top) self.top_rect_path.arcTo(left, top, radius, radius, 90.0, 90.0) self.top_rect_path.lineTo(left, top + header) self.top_rect_path.lineTo(right, top + header) def paintEvent(self, event): """ """ self.build_paths() painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.fillPath(self.round_rect_path, self.color_back) painter.fillPath(self.top_rect_path, self.color_top) painter.strokePath(self.round_rect_path, QPen(Qt.gray, 1)) # TODO: Build the pointing arrow? def keyReleaseEvent(self, event): """ """ key = event.key() self.key_pressed = key # print(key) keys = [Qt.Key_Right, Qt.Key_Left, Qt.Key_Down, Qt.Key_Up, Qt.Key_Escape, Qt.Key_PageUp, Qt.Key_PageDown, Qt.Key_Home, Qt.Key_End, Qt.Key_Menu] if key in keys: if not self.is_fade_running(): self.sig_key_pressed.emit() def mousePressEvent(self, event): """override Qt method""" # Raise the main application window on click self.parent.raise_() self.raise_() if event.button() == Qt.RightButton: pass # clicked_widget = self.childAt(event.x(), event.y()) # if clicked_widget == self.label_current: # self.context_menu_requested(event) def context_menu_requested(self, event): """ """ pos = QPoint(event.x(), event.y()) menu = QMenu(self) actions = [] action_title = create_action(self, _('Go to step: '), icon=QIcon()) action_title.setDisabled(True) actions.append(action_title) # actions.append(create_action(self, _(': '), icon=QIcon())) add_actions(menu, actions) menu.popup(self.mapToGlobal(pos)) def reject(self): """Qt method to handle escape key event""" if not self.is_fade_running(): key = Qt.Key_Escape self.key_pressed = key self.sig_key_pressed.emit()
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton( CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton( DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton( SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) general_group = QGroupBox("General settings") wdir_bg = QButtonGroup(general_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) dirname_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) post_mortem = self.create_checkbox( _("Enter debugging mode when errors appear during execution"), 'post_mortem', False) general_layout = QVBoxLayout() general_layout.addWidget(wdir_label) general_layout.addWidget(dirname_radio) general_layout.addLayout(thisdir_layout) general_layout.addWidget(post_mortem) general_group.setLayout(general_layout) dedicated_group = QGroupBox(_("Dedicated Python console")) interact_after = self.create_checkbox( _("Interact with the Python console after execution"), 'interact', False) show_warning = self.create_checkbox( _("Show warning when killing running processes"), 'show_kill_warning', True) dedicated_layout = QVBoxLayout() dedicated_layout.addWidget(interact_after) dedicated_layout.addWidget(show_warning) dedicated_group.setLayout(dedicated_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(general_group) vlayout.addWidget(dedicated_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): newcb = self.create_checkbox mpl_present = programs.is_module_installed("matplotlib") # --- Display --- font_group = self.create_fontgroup( option=None, text=None, fontfilters=QFontComboBox.MonospacedFonts) # Interface Group interface_group = QGroupBox(_("Interface")) banner_box = newcb( _("Display initial banner"), 'show_banner', tip=_("This option lets you hide the message shown at\n" "the top of the console when it's opened.")) gui_comp_box = newcb(_("Use a completion widget"), 'use_gui_completion', tip=_("Use a widget instead of plain text " "output for tab completion")) pager_box = newcb(_("Use a pager to display additional text inside " "the console"), 'use_pager', tip=_("Useful if you don't want to fill the " "console with long help or completion texts.\n" "Note: Use the Q key to get out of the " "pager.")) calltips_box = newcb(_("Display balloon tips"), 'show_calltips') ask_box = newcb(_("Ask for confirmation before closing"), 'ask_before_closing') interface_layout = QVBoxLayout() interface_layout.addWidget(banner_box) interface_layout.addWidget(gui_comp_box) interface_layout.addWidget(pager_box) interface_layout.addWidget(calltips_box) interface_layout.addWidget(ask_box) interface_group.setLayout(interface_layout) # Background Color Group bg_group = QGroupBox(_("Background color")) light_radio = self.create_radiobutton(_("Light background"), 'light_color') dark_radio = self.create_radiobutton(_("Dark background"), 'dark_color') bg_layout = QVBoxLayout() bg_layout.addWidget(light_radio) bg_layout.addWidget(dark_radio) bg_group.setLayout(bg_layout) # Source Code Group source_code_group = QGroupBox(_("Source code")) buffer_spin = self.create_spinbox( _("Buffer: "), _(" lines"), 'buffer_size', min_=-1, max_=1000000, step=100, tip=_("Set the maximum number of lines of text shown in the\n" "console before truncation. Specifying -1 disables it\n" "(not recommended!)")) source_code_layout = QVBoxLayout() source_code_layout.addWidget(buffer_spin) source_code_group.setLayout(source_code_layout) # --- Graphics --- # Pylab Group pylab_group = QGroupBox(_("Support for graphics (Matplotlib)")) pylab_box = newcb(_("Activate support"), 'pylab') autoload_pylab_box = newcb( _("Automatically load Pylab and NumPy " "modules"), 'pylab/autoload', tip=_("This lets you load graphics support " "without importing \nthe commands to do " "plots. Useful to work with other\n" "plotting libraries different to " "Matplotlib or to develop \nGUIs with " "Spyder.")) autoload_pylab_box.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), autoload_pylab_box.setEnabled) pylab_layout = QVBoxLayout() pylab_layout.addWidget(pylab_box) pylab_layout.addWidget(autoload_pylab_box) pylab_group.setLayout(pylab_layout) if not mpl_present: self.set_option('pylab', False) self.set_option('pylab/autoload', False) pylab_group.setEnabled(False) pylab_tip = _("This feature requires the Matplotlib library.\n" "It seems you don't have it installed.") pylab_box.setToolTip(pylab_tip) # Pylab backend Group inline = _("Inline") automatic = _("Automatic") backend_group = QGroupBox(_("Graphics backend")) bend_label = QLabel( _("Decide how graphics are going to be displayed " "in the console. If unsure, please select " "<b>%s</b> to put graphics inside the " "console or <b>%s</b> to interact with " "them (through zooming and panning) in a " "separate window.") % (inline, automatic)) bend_label.setWordWrap(True) backends = [(inline, 0), (automatic, 1), ("Qt", 2)] # TODO: Add gtk3 when 0.13 is released if sys.platform == 'darwin': backends.append(("Mac OSX", 3)) if programs.is_module_installed('pygtk'): backends.append(("Gtk", 4)) if programs.is_module_installed('wxPython'): backends.append(("Wx", 5)) if programs.is_module_installed('_tkinter'): backends.append(("Tkinter", 6)) backends = tuple(backends) backend_box = self.create_combobox( _("Backend:") + " ", backends, 'pylab/backend', default=0, tip=_("This option will be applied the " "next time a console is opened.")) backend_layout = QVBoxLayout() backend_layout.addWidget(bend_label) backend_layout.addWidget(backend_box) backend_group.setLayout(backend_layout) backend_group.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), backend_group.setEnabled) # Inline backend Group inline_group = QGroupBox(_("Inline backend")) inline_label = QLabel( _("Decide how to render the figures created by " "this backend")) inline_label.setWordWrap(True) formats = (("PNG", 0), ("SVG", 1)) format_box = self.create_combobox(_("Format:") + " ", formats, 'pylab/inline/figure_format', default=0) resolution_spin = self.create_spinbox( _("Resolution:") + " ", " " + _("dpi"), 'pylab/inline/resolution', min_=56, max_=112, step=1, tip=_("Only used when the format is PNG. Default is " "72")) width_spin = self.create_spinbox(_("Width:") + " ", " " + _("inches"), 'pylab/inline/width', min_=2, max_=20, step=1, tip=_("Default is 6")) height_spin = self.create_spinbox(_("Height:") + " ", " " + _("inches"), 'pylab/inline/height', min_=1, max_=20, step=1, tip=_("Default is 4")) inline_layout = QVBoxLayout() inline_layout.addWidget(inline_label) inline_layout.addWidget(format_box) inline_layout.addWidget(resolution_spin) inline_layout.addWidget(width_spin) inline_layout.addWidget(height_spin) inline_group.setLayout(inline_layout) inline_group.setEnabled(self.get_option('pylab') and mpl_present) self.connect(pylab_box, SIGNAL("toggled(bool)"), inline_group.setEnabled) # --- Startup --- # Run lines Group run_lines_group = QGroupBox(_("Run code")) run_lines_label = QLabel( _("You can run several lines of code when " "a console is started. Please introduce " "each one separated by commas, for " "example:<br>" "<i>import os, import sys</i>")) run_lines_label.setWordWrap(True) run_lines_edit = self.create_lineedit(_("Lines:"), 'startup/run_lines', '', alignment=Qt.Horizontal) run_lines_layout = QVBoxLayout() run_lines_layout.addWidget(run_lines_label) run_lines_layout.addWidget(run_lines_edit) run_lines_group.setLayout(run_lines_layout) # Run file Group run_file_group = QGroupBox(_("Run a file")) run_file_label = QLabel( _("You can also run a whole file at startup " "instead of just some lines (This is " "similar to have a PYTHONSTARTUP file).")) run_file_label.setWordWrap(True) file_radio = newcb(_("Use the following file:"), 'startup/use_run_file', False) run_file_browser = self.create_browsefile('', 'startup/run_file', '') run_file_browser.setEnabled(False) self.connect(file_radio, SIGNAL("toggled(bool)"), run_file_browser.setEnabled) run_file_layout = QVBoxLayout() run_file_layout.addWidget(run_file_label) run_file_layout.addWidget(file_radio) run_file_layout.addWidget(run_file_browser) run_file_group.setLayout(run_file_layout) # ---- Advanced settings ---- # Greedy completer group greedy_group = QGroupBox(_("Greedy completion")) greedy_label = QLabel( _("Enable <tt>Tab</tt> completion on elements " "of lists, results of function calls, etc, " "<i>without</i> assigning them to a " "variable.<br>" "For example, you can get completions on " "things like <tt>li[0].<Tab></tt> or " "<tt>ins.meth().<Tab></tt>")) greedy_label.setWordWrap(True) greedy_box = newcb(_("Use the greedy completer"), "greedy_completer", tip="<b>Warning</b>: It can be unsafe because the " "code is actually evaluated when you press " "<tt>Tab</tt>.") greedy_layout = QVBoxLayout() greedy_layout.addWidget(greedy_label) greedy_layout.addWidget(greedy_box) greedy_group.setLayout(greedy_layout) # Autocall group autocall_group = QGroupBox(_("Autocall")) autocall_label = QLabel( _("Autocall makes IPython automatically call " "any callable object even if you didn't type " "explicit parentheses.<br>" "For example, if you type <i>str 43</i> it " "becomes <i>str(43)</i> automatically.")) autocall_label.setWordWrap(True) smart = _('Smart') full = _('Full') autocall_opts = ((_('Off'), 0), (smart, 1), (full, 2)) autocall_box = self.create_combobox( _("Autocall: "), autocall_opts, 'autocall', default=0, tip=_("On <b>%s</b> mode, Autocall is not applied if " "there are no arguments after the callable. On " "<b>%s</b> mode, all callable objects are " "automatically called (even if no arguments are " "present).") % (smart, full)) autocall_layout = QVBoxLayout() autocall_layout.addWidget(autocall_label) autocall_layout.addWidget(autocall_box) autocall_group.setLayout(autocall_layout) # Sympy group sympy_group = QGroupBox(_("Symbolic Mathematics")) sympy_label = QLabel( _("Perfom symbolic operations in the console " "(e.g. integrals, derivatives, vector calculus, " "etc) and get the outputs in a beautifully " "printed style.")) sympy_label.setWordWrap(True) sympy_box = newcb(_("Use symbolic math"), "symbolic_math", tip=_( "This option loads the Sympy library to work " "with.<br>Please refer to its documentation to " "learn how to use it.")) sympy_layout = QVBoxLayout() sympy_layout.addWidget(sympy_label) sympy_layout.addWidget(sympy_box) sympy_group.setLayout(sympy_layout) sympy_present = programs.is_module_installed("sympy") if not sympy_present: self.set_option("symbolic_math", False) sympy_box.setEnabled(False) sympy_tip = _("This feature requires the Sympy library.\n" "It seems you don't have it installed.") sympy_box.setToolTip(sympy_tip) # Prompts group prompts_group = QGroupBox(_("Prompts")) prompts_label = QLabel( _("Modify how Input and Output prompts are " "shown in the console.")) prompts_label.setWordWrap(True) in_prompt_edit = self.create_lineedit( _("Input prompt:"), 'in_prompt', '', _('Default is<br>' 'In [<span class="in-prompt-number">' '%i</span>]:'), alignment=Qt.Horizontal) out_prompt_edit = self.create_lineedit( _("Output prompt:"), 'out_prompt', '', _('Default is<br>' 'Out[<span class="out-prompt-number">' '%i</span>]:'), alignment=Qt.Horizontal) prompts_layout = QVBoxLayout() prompts_layout.addWidget(prompts_label) prompts_layout.addWidget(in_prompt_edit) prompts_layout.addWidget(out_prompt_edit) prompts_group.setLayout(prompts_layout) # --- Tabs organization --- tabs = QTabWidget() tabs.addTab( self.create_tab(font_group, interface_group, bg_group, source_code_group), _("Display")) tabs.addTab(self.create_tab(pylab_group, backend_group, inline_group), _("Graphics")) tabs.addTab(self.create_tab(run_lines_group, run_file_group), _("Startup")) tabs.addTab( self.create_tab(greedy_group, autocall_group, sympy_group, prompts_group), _("Advanced Settings")) vlayout = QVBoxLayout() vlayout.addWidget(tabs) self.setLayout(vlayout)
def setup_page(self): # Connections group connections_group = QGroupBox(_("Automatic connections")) connections_label = QLabel( _("This pane can automatically " "show an object's help information after " "a left parenthesis is written next to it. " "Below you can decide to which plugin " "you want to connect it to turn on this " "feature.")) connections_label.setWordWrap(True) editor_box = self.create_checkbox(_("Editor"), 'connect/editor') rope_installed = programs.is_module_installed('rope') jedi_installed = programs.is_module_installed('jedi', '>=0.8.1') editor_box.setEnabled(rope_installed or jedi_installed) if not rope_installed and not jedi_installed: editor_tip = _( "This feature requires the Rope or Jedi libraries.\n" "It seems you don't have either installed.") editor_box.setToolTip(editor_tip) python_box = self.create_checkbox(_("Python Console"), 'connect/python_console') ipython_box = self.create_checkbox(_("IPython Console"), 'connect/ipython_console') ipython_box.setEnabled(QTCONSOLE_INSTALLED) connections_layout = QVBoxLayout() connections_layout.addWidget(connections_label) connections_layout.addWidget(editor_box) connections_layout.addWidget(python_box) connections_layout.addWidget(ipython_box) connections_group.setLayout(connections_layout) # Features group features_group = QGroupBox(_("Additional features")) math_box = self.create_checkbox(_("Render mathematical equations"), 'math') req_sphinx = programs.is_module_installed('sphinx', '>=1.1') math_box.setEnabled(req_sphinx) if not req_sphinx: sphinx_ver = programs.get_module_version('sphinx') sphinx_tip = _("This feature requires Sphinx 1.1 or superior.") sphinx_tip += "\n" + _( "Sphinx %s is currently installed.") % sphinx_ver math_box.setToolTip(sphinx_tip) features_layout = QVBoxLayout() features_layout.addWidget(math_box) features_group.setLayout(features_layout) # Source code group sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_group.setLayout(sourcecode_layout) # Final layout vlayout = QVBoxLayout() vlayout.addWidget(connections_group) vlayout.addWidget(features_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)