本文整理汇总了Python中spyderlib.qt.QtGui.QRadioButton类的典型用法代码示例。如果您正苦于以下问题:Python QRadioButton类的具体用法?Python QRadioButton怎么用?Python QRadioButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QRadioButton类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
vert_layout = QVBoxLayout()
# Type frame
type_layout = QHBoxLayout()
type_label = QLabel(_("Import as"))
type_layout.addWidget(type_label)
self.array_btn = array_btn = QRadioButton(_("array"))
array_btn.setEnabled(ndarray is not FakeObject)
array_btn.setChecked(ndarray is not FakeObject)
type_layout.addWidget(array_btn)
list_btn = QRadioButton(_("list"))
list_btn.setChecked(not array_btn.isChecked())
type_layout.addWidget(list_btn)
if pd:
self.df_btn = df_btn = QRadioButton(_("DataFrame"))
df_btn.setChecked(False)
type_layout.addWidget(df_btn)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
type_layout.addItem(h_spacer)
type_frame = QFrame()
type_frame.setLayout(type_layout)
self._table_view = PreviewTable(self)
vert_layout.addWidget(type_frame)
vert_layout.addWidget(self._table_view)
self.setLayout(vert_layout)
示例2: __init__
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)
示例3: create_radiobutton
def create_radiobutton(self, text, option, default=NoDefault,
tip=None, msg_warning=None, msg_info=None,
msg_if_enabled=False, button_group=None):
radiobutton = QRadioButton(text)
if button_group is None:
if self.default_button_group is None:
self.default_button_group = QButtonGroup(self)
button_group = self.default_button_group
button_group.addButton(radiobutton)
if tip is not None:
radiobutton.setToolTip(tip)
self.radiobuttons[radiobutton] = (option, default)
if msg_warning is not None or msg_info is not None:
def show_message(is_checked):
if is_checked or not msg_if_enabled:
if msg_warning is not None:
QMessageBox.warning(self, self.get_name(),
msg_warning, QMessageBox.Ok)
if msg_info is not None:
QMessageBox.information(self, self.get_name(),
msg_info, QMessageBox.Ok)
radiobutton.toggled.connect(show_message)
return radiobutton
示例4: __init__
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.current_radio = None
self.dedicated_radio = None
self.systerm_radio = None
self.runconf = RunConfiguration()
firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)
# --- General settings ----
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)
# --- Interpreter ---
interpreter_group = QGroupBox(_("Console"))
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
self.current_radio = QRadioButton(CURRENT_INTERPRETER)
interpreter_layout.addWidget(self.current_radio)
self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
interpreter_layout.addWidget(self.dedicated_radio)
self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
interpreter_layout.addWidget(self.systerm_radio)
# --- Dedicated interpreter ---
new_group = QGroupBox(_("Dedicated Python console"))
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 "
"console after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.show_kill_warning_cb = QCheckBox(_("Show warning when killing"
" running process"))
new_layout.addWidget(self.show_kill_warning_cb, 2, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 3, 0)
self.pclo_edit = QLineEdit()
self.connect(self.pclo_cb, SIGNAL("toggled(bool)"),
self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
self.pclo_edit.setToolTip(_("<b>-u</b> is added to the "
"other options you set here"))
new_layout.addWidget(self.pclo_edit, 3, 1)
#TODO: Add option for "Post-mortem debugging"
# Checkbox to preserve the old behavior, i.e. always open the dialog
# on first run
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
self.connect(self.firstrun_cb, SIGNAL("clicked(bool)"),
self.set_firstrun_o)
self.firstrun_cb.setChecked(firstrun_o)
layout = QVBoxLayout()
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(new_group)
layout.addWidget(hline)
layout.addWidget(self.firstrun_cb)
self.setLayout(layout)
示例5: RunConfigOptions
class RunConfigOptions(QWidget):
"""Run configuration options"""
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.current_radio = None
self.dedicated_radio = None
self.systerm_radio = None
self.runconf = RunConfiguration()
firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)
# --- General settings ----
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)
# --- Interpreter ---
interpreter_group = QGroupBox(_("Console"))
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
self.current_radio = QRadioButton(CURRENT_INTERPRETER)
interpreter_layout.addWidget(self.current_radio)
self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
interpreter_layout.addWidget(self.dedicated_radio)
self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
interpreter_layout.addWidget(self.systerm_radio)
# --- Dedicated interpreter ---
new_group = QGroupBox(_("Dedicated Python console"))
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 "
"console after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.show_kill_warning_cb = QCheckBox(_("Show warning when killing"
" running process"))
new_layout.addWidget(self.show_kill_warning_cb, 2, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 3, 0)
self.pclo_edit = QLineEdit()
self.connect(self.pclo_cb, SIGNAL("toggled(bool)"),
self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
self.pclo_edit.setToolTip(_("<b>-u</b> is added to the "
"other options you set here"))
new_layout.addWidget(self.pclo_edit, 3, 1)
#TODO: Add option for "Post-mortem debugging"
# Checkbox to preserve the old behavior, i.e. always open the dialog
# on first run
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
self.connect(self.firstrun_cb, SIGNAL("clicked(bool)"),
self.set_firstrun_o)
self.firstrun_cb.setChecked(firstrun_o)
layout = QVBoxLayout()
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(new_group)
layout.addWidget(hline)
layout.addWidget(self.firstrun_cb)
self.setLayout(layout)
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
#.........这里部分代码省略.........
示例6: __init__
def __init__(self, parent, search_text, search_text_regexp, search_path,
include, include_idx, include_regexp,
exclude, exclude_idx, exclude_regexp,
supported_encodings, in_python_path, more_options):
QWidget.__init__(self, parent)
if search_path is None:
search_path = getcwd()
if not isinstance(search_text, (list, tuple)):
search_text = [search_text]
if not isinstance(search_path, (list, tuple)):
search_path = [search_path]
if not isinstance(include, (list, tuple)):
include = [include]
if not isinstance(exclude, (list, tuple)):
exclude = [exclude]
self.supported_encodings = supported_encodings
# Layout 1
hlayout1 = QHBoxLayout()
self.search_text = PatternComboBox(self, search_text,
_("Search pattern"))
self.edit_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.edit_regexp.setCheckable(True)
self.edit_regexp.setChecked(search_text_regexp)
self.more_widgets = ()
self.more_options = create_toolbutton(self,
toggled=self.toggle_more_options)
self.more_options.setCheckable(True)
self.more_options.setChecked(more_options)
self.ok_button = create_toolbutton(self, text=_("Search"),
icon=ima.icon('DialogApplyButton'),
triggered=lambda: self.find.emit(),
tip=_("Start search"),
text_beside_icon=True)
self.ok_button.clicked.connect(self.update_combos)
self.stop_button = create_toolbutton(self, text=_("Stop"),
icon=ima.icon('stop'),
triggered=lambda: self.stop.emit(),
tip=_("Stop search"),
text_beside_icon=True)
self.stop_button.setEnabled(False)
for widget in [self.search_text, self.edit_regexp,
self.ok_button, self.stop_button, self.more_options]:
hlayout1.addWidget(widget)
# Layout 2
hlayout2 = QHBoxLayout()
self.include_pattern = PatternComboBox(self, include,
_("Included filenames pattern"))
if include_idx is not None and include_idx >= 0 \
and include_idx < self.include_pattern.count():
self.include_pattern.setCurrentIndex(include_idx)
self.include_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.include_regexp.setCheckable(True)
self.include_regexp.setChecked(include_regexp)
include_label = QLabel(_("Include:"))
include_label.setBuddy(self.include_pattern)
self.exclude_pattern = PatternComboBox(self, exclude,
_("Excluded filenames pattern"))
if exclude_idx is not None and exclude_idx >= 0 \
and exclude_idx < self.exclude_pattern.count():
self.exclude_pattern.setCurrentIndex(exclude_idx)
self.exclude_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.exclude_regexp.setCheckable(True)
self.exclude_regexp.setChecked(exclude_regexp)
exclude_label = QLabel(_("Exclude:"))
exclude_label.setBuddy(self.exclude_pattern)
for widget in [include_label, self.include_pattern,
self.include_regexp,
exclude_label, self.exclude_pattern,
self.exclude_regexp]:
hlayout2.addWidget(widget)
# Layout 3
hlayout3 = QHBoxLayout()
self.python_path = QRadioButton(_("PYTHONPATH"), self)
self.python_path.setChecked(in_python_path)
self.python_path.setToolTip(_(
"Search in all directories listed in sys.path which"
" are outside the Python installation directory"))
self.hg_manifest = QRadioButton(_("Hg repository"), self)
self.detect_hg_repository()
self.hg_manifest.setToolTip(
_("Search in current directory hg repository"))
self.custom_dir = QRadioButton(_("Here:"), self)
self.custom_dir.setChecked(not in_python_path)
self.dir_combo = PathComboBox(self)
self.dir_combo.addItems(search_path)
self.dir_combo.setToolTip(_("Search recursively in this directory"))
self.dir_combo.open_dir.connect(self.set_directory)
#.........这里部分代码省略.........
示例7: FindOptions
class FindOptions(QWidget):
"""Find widget with options"""
find = Signal()
stop = Signal()
def __init__(self, parent, search_text, search_text_regexp, search_path,
include, include_idx, include_regexp,
exclude, exclude_idx, exclude_regexp,
supported_encodings, in_python_path, more_options):
QWidget.__init__(self, parent)
if search_path is None:
search_path = getcwd()
if not isinstance(search_text, (list, tuple)):
search_text = [search_text]
if not isinstance(search_path, (list, tuple)):
search_path = [search_path]
if not isinstance(include, (list, tuple)):
include = [include]
if not isinstance(exclude, (list, tuple)):
exclude = [exclude]
self.supported_encodings = supported_encodings
# Layout 1
hlayout1 = QHBoxLayout()
self.search_text = PatternComboBox(self, search_text,
_("Search pattern"))
self.edit_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.edit_regexp.setCheckable(True)
self.edit_regexp.setChecked(search_text_regexp)
self.more_widgets = ()
self.more_options = create_toolbutton(self,
toggled=self.toggle_more_options)
self.more_options.setCheckable(True)
self.more_options.setChecked(more_options)
self.ok_button = create_toolbutton(self, text=_("Search"),
icon=ima.icon('DialogApplyButton'),
triggered=lambda: self.find.emit(),
tip=_("Start search"),
text_beside_icon=True)
self.ok_button.clicked.connect(self.update_combos)
self.stop_button = create_toolbutton(self, text=_("Stop"),
icon=ima.icon('stop'),
triggered=lambda: self.stop.emit(),
tip=_("Stop search"),
text_beside_icon=True)
self.stop_button.setEnabled(False)
for widget in [self.search_text, self.edit_regexp,
self.ok_button, self.stop_button, self.more_options]:
hlayout1.addWidget(widget)
# Layout 2
hlayout2 = QHBoxLayout()
self.include_pattern = PatternComboBox(self, include,
_("Included filenames pattern"))
if include_idx is not None and include_idx >= 0 \
and include_idx < self.include_pattern.count():
self.include_pattern.setCurrentIndex(include_idx)
self.include_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.include_regexp.setCheckable(True)
self.include_regexp.setChecked(include_regexp)
include_label = QLabel(_("Include:"))
include_label.setBuddy(self.include_pattern)
self.exclude_pattern = PatternComboBox(self, exclude,
_("Excluded filenames pattern"))
if exclude_idx is not None and exclude_idx >= 0 \
and exclude_idx < self.exclude_pattern.count():
self.exclude_pattern.setCurrentIndex(exclude_idx)
self.exclude_regexp = create_toolbutton(self,
icon=ima.icon('advanced'),
tip=_('Regular expression'))
self.exclude_regexp.setCheckable(True)
self.exclude_regexp.setChecked(exclude_regexp)
exclude_label = QLabel(_("Exclude:"))
exclude_label.setBuddy(self.exclude_pattern)
for widget in [include_label, self.include_pattern,
self.include_regexp,
exclude_label, self.exclude_pattern,
self.exclude_regexp]:
hlayout2.addWidget(widget)
# Layout 3
hlayout3 = QHBoxLayout()
self.python_path = QRadioButton(_("PYTHONPATH"), self)
self.python_path.setChecked(in_python_path)
self.python_path.setToolTip(_(
"Search in all directories listed in sys.path which"
" are outside the Python installation directory"))
self.hg_manifest = QRadioButton(_("Hg repository"), self)
self.detect_hg_repository()
self.hg_manifest.setToolTip(
_("Search in current directory hg repository"))
self.custom_dir = QRadioButton(_("Here:"), self)
#.........这里部分代码省略.........
示例8: ContentsWidget
class ContentsWidget(QWidget):
"""Import wizard contents widget"""
asDataChanged = Signal(bool)
def __init__(self, parent, text):
QWidget.__init__(self, parent)
self.text_editor = QTextEdit(self)
self.text_editor.setText(text)
self.text_editor.setReadOnly(True)
# Type frame
type_layout = QHBoxLayout()
type_label = QLabel(_("Import as"))
type_layout.addWidget(type_label)
data_btn = QRadioButton(_("data"))
data_btn.setChecked(True)
self._as_data = True
type_layout.addWidget(data_btn)
code_btn = QRadioButton(_("code"))
self._as_code = False
type_layout.addWidget(code_btn)
txt_btn = QRadioButton(_("text"))
type_layout.addWidget(txt_btn)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
type_layout.addItem(h_spacer)
type_frame = QFrame()
type_frame.setLayout(type_layout)
# Opts frame
grid_layout = QGridLayout()
grid_layout.setSpacing(0)
col_label = QLabel(_("Column separator:"))
grid_layout.addWidget(col_label, 0, 0)
col_w = QWidget()
col_btn_layout = QHBoxLayout()
self.tab_btn = QRadioButton(_("Tab"))
self.tab_btn.setChecked(False)
col_btn_layout.addWidget(self.tab_btn)
other_btn_col = QRadioButton(_("other"))
other_btn_col.setChecked(True)
col_btn_layout.addWidget(other_btn_col)
col_w.setLayout(col_btn_layout)
grid_layout.addWidget(col_w, 0, 1)
self.line_edt = QLineEdit(",")
self.line_edt.setMaximumWidth(30)
self.line_edt.setEnabled(True)
other_btn_col.toggled.connect(self.line_edt.setEnabled)
grid_layout.addWidget(self.line_edt, 0, 2)
row_label = QLabel(_("Row separator:"))
grid_layout.addWidget(row_label, 1, 0)
row_w = QWidget()
row_btn_layout = QHBoxLayout()
self.eol_btn = QRadioButton(_("EOL"))
self.eol_btn.setChecked(True)
row_btn_layout.addWidget(self.eol_btn)
other_btn_row = QRadioButton(_("other"))
row_btn_layout.addWidget(other_btn_row)
row_w.setLayout(row_btn_layout)
grid_layout.addWidget(row_w, 1, 1)
self.line_edt_row = QLineEdit(";")
self.line_edt_row.setMaximumWidth(30)
self.line_edt_row.setEnabled(False)
other_btn_row.toggled.connect(self.line_edt_row.setEnabled)
grid_layout.addWidget(self.line_edt_row, 1, 2)
grid_layout.setRowMinimumHeight(2, 15)
other_group = QGroupBox(_("Additional options"))
other_layout = QGridLayout()
other_group.setLayout(other_layout)
skiprows_label = QLabel(_("Skip rows:"))
other_layout.addWidget(skiprows_label, 0, 0)
self.skiprows_edt = QLineEdit("0")
self.skiprows_edt.setMaximumWidth(30)
intvalid = QIntValidator(0, len(to_text_string(text).splitlines()), self.skiprows_edt)
self.skiprows_edt.setValidator(intvalid)
other_layout.addWidget(self.skiprows_edt, 0, 1)
other_layout.setColumnMinimumWidth(2, 5)
comments_label = QLabel(_("Comments:"))
other_layout.addWidget(comments_label, 0, 3)
self.comments_edt = QLineEdit("#")
self.comments_edt.setMaximumWidth(30)
other_layout.addWidget(self.comments_edt, 0, 4)
self.trnsp_box = QCheckBox(_("Transpose"))
# self.trnsp_box.setEnabled(False)
other_layout.addWidget(self.trnsp_box, 1, 0, 2, 0)
grid_layout.addWidget(other_group, 3, 0, 2, 0)
opts_frame = QFrame()
opts_frame.setLayout(grid_layout)
#.........这里部分代码省略.........
示例9: RunConfigOptions
class RunConfigOptions(QWidget):
"""Run configuration options"""
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)
def select_directory(self):
"""Select directory"""
basedir = unicode(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = os.getcwdu()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
self.wd_cb.setChecked(True)
def set(self, options):
self.runconf.set(options)
self.clo_cb.setChecked(self.runconf.args_enabled)
self.clo_edit.setText(self.runconf.args)
self.wd_cb.setChecked(self.runconf.wdir_enabled)
self.wd_edit.setText(self.runconf.wdir)
if self.runconf.current:
self.current_radio.setChecked(True)
elif self.runconf.systerm:
self.systerm_radio.setChecked(True)
else:
self.new_radio.setChecked(True)
self.interact_cb.setChecked(self.runconf.interact)
self.pclo_cb.setChecked(self.runconf.python_args_enabled)
self.pclo_edit.setText(self.runconf.python_args)
def get(self):
self.runconf.args_enabled = self.clo_cb.isChecked()
self.runconf.args = unicode(self.clo_edit.text())
self.runconf.wdir_enabled = self.wd_cb.isChecked()
self.runconf.wdir = unicode(self.wd_edit.text())
self.runconf.current = self.current_radio.isChecked()
self.runconf.systerm = self.systerm_radio.isChecked()
self.runconf.interact = self.interact_cb.isChecked()
self.runconf.python_args_enabled = self.pclo_cb.isChecked()
self.runconf.python_args = unicode(self.pclo_edit.text())
return self.runconf.get()
#.........这里部分代码省略.........