本文整理汇总了Python中spyderlib.qt.QtGui.QPushButton类的典型用法代码示例。如果您正苦于以下问题:Python QPushButton类的具体用法?Python QPushButton怎么用?Python QPushButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPushButton类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ExampleWidget
class ExampleWidget(QWidget):
"""
Example widget.
Methods defined here should not be aware of spyder, but of the function
required by the widget only.
"""
def __init__(self, parent):
QWidget.__init__(self, parent=parent)
self.setWindowTitle("Example")
# Widgets
self.button = QPushButton('Current editor')
self.table = QTableWidget(self)
# Widget setup
self.button.setIcon(ima.icon('spyder'))
# Layouts
layout = QVBoxLayout()
layout.addWidget(self.button)
layout.addWidget(self.table)
self.setLayout(layout)
def msgbox(self, msg=None):
"""Message box."""
QMessageBox.information(self, 'Title', msg)
开发者ID:Nodd,项目名称:spyder.example,代码行数:29,代码来源:example.py
示例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)
开发者ID:jromang,项目名称:retina-old,代码行数:59,代码来源:runconfig.py
示例3: create_browsedir
def create_browsedir(self, text, option, default=NoDefault, tip=None):
widget = self.create_lineedit(text, option, default,
alignment=Qt.Horizontal)
for edit in self.lineedits:
if widget.isAncestorOf(edit):
break
msg = _("Invalid directory path")
self.validate_data[edit] = (osp.isdir, msg)
browse_btn = QPushButton(ima.icon('DirOpenIcon'), '', self)
browse_btn.setToolTip(_("Select directory"))
browse_btn.clicked.connect(lambda: self.select_directory(edit))
layout = QHBoxLayout()
layout.addWidget(widget)
layout.addWidget(browse_btn)
layout.setContentsMargins(0, 0, 0, 0)
browsedir = QWidget(self)
browsedir.setLayout(layout)
return browsedir
开发者ID:gyenney,项目名称:Tools,代码行数:18,代码来源:configdialog.py
示例4: create_browsefile
def create_browsefile(self, text, option, default=NoDefault, tip=None,
filters=None):
widget = self.create_lineedit(text, option, default,
alignment=Qt.Horizontal)
for edit in self.lineedits:
if widget.isAncestorOf(edit):
break
msg = _("Invalid file path")
self.validate_data[edit] = (osp.isfile, msg)
browse_btn = QPushButton(get_std_icon('FileIcon'), "", self)
browse_btn.setToolTip(_("Select file"))
browse_btn.clicked.connect(lambda: self.select_file(edit, filters))
layout = QHBoxLayout()
layout.addWidget(widget)
layout.addWidget(browse_btn)
layout.setContentsMargins(0, 0, 0, 0)
browsedir = QWidget(self)
browsedir.setLayout(layout)
return browsedir
开发者ID:SaWein,项目名称:spyder,代码行数:19,代码来源:configdialog.py
示例5: __init__
def __init__(self, parent, data, readonly=False,
xlabels=None, ylabels=None):
QWidget.__init__(self, parent)
self.data = data
self.old_data_shape = None
if len(self.data.shape) == 1:
self.old_data_shape = self.data.shape
self.data.shape = (self.data.shape[0], 1)
elif len(self.data.shape) == 0:
self.old_data_shape = self.data.shape
self.data.shape = (1, 1)
format = SUPPORTED_FORMATS.get(data.dtype.name, '%s')
self.model = ArrayModel(self.data, format=format, xlabels=xlabels,
ylabels=ylabels, readonly=readonly, parent=self)
self.view = ArrayView(self, self.model, data.dtype, data.shape)
btn_layout = QHBoxLayout()
btn_layout.setAlignment(Qt.AlignLeft)
btn = QPushButton(_( "Format"))
# disable format button for int type
btn.setEnabled(is_float(data.dtype))
btn_layout.addWidget(btn)
btn.clicked.connect(self.change_format)
btn = QPushButton(_( "Resize"))
btn_layout.addWidget(btn)
btn.clicked.connect(self.view.resize_to_contents)
bgcolor = QCheckBox(_( 'Background color'))
bgcolor.setChecked(self.model.bgcolor_enabled)
bgcolor.setEnabled(self.model.bgcolor_enabled)
bgcolor.stateChanged.connect(self.model.bgcolor)
btn_layout.addWidget(bgcolor)
layout = QVBoxLayout()
layout.addWidget(self.view)
layout.addLayout(btn_layout)
self.setLayout(layout)
开发者ID:da-woods,项目名称:spyder,代码行数:37,代码来源:arrayeditor.py
示例6: __init__
def __init__(self, parent):
QWidget.__init__(self, parent=parent)
self.setWindowTitle("Example")
# Widgets
self.button = QPushButton('Current editor')
self.table = QTableWidget(self)
# Widget setup
self.button.setIcon(ima.icon('spyder'))
# Layouts
layout = QVBoxLayout()
layout.addWidget(self.button)
layout.addWidget(self.table)
self.setLayout(layout)
开发者ID:Nodd,项目名称:spyder.example,代码行数:17,代码来源:example.py
示例7: __init__
def __init__(self):
super(TestWindow, self).__init__()
self.setGeometry(300, 100, 400, 600)
self.setWindowTitle('Exploring QMainWindow')
self.exit = QAction('Exit', self)
self.exit.setStatusTip('Exit program')
# create the menu bar
menubar = self.menuBar()
file_ = menubar.addMenu('&File')
file_.addAction(self.exit)
# create the status bar
self.statusBar()
# QWidget or its instance needed for box layout
self.widget = QWidget(self)
self.button = QPushButton('test')
self.button1 = QPushButton('1')
self.button2 = QPushButton('2')
effect = QGraphicsOpacityEffect(self.button2)
self.button2.setGraphicsEffect(effect)
self.anim = QPropertyAnimation(effect, "opacity")
self.anim.setStartValue(0.01)
self.anim.setEndValue(1.0)
self.anim.setDuration(500)
lay = QVBoxLayout()
lay.addWidget(self.button)
lay.addStretch()
lay.addWidget(self.button1)
lay.addWidget(self.button2)
self.widget.setLayout(lay)
self.setCentralWidget(self.widget)
self.button.clicked.connect(self.action1)
self.button1.clicked.connect(self.action2)
self.tour = AnimatedTour(self)
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:43,代码来源:tour.py
示例8: LayoutSettingsDialog
class LayoutSettingsDialog(QDialog):
"""Layout settings dialog"""
def __init__(self, parent, names, order, active):
super(LayoutSettingsDialog, self).__init__(parent)
# variables
self._parent = parent
self._selection_model = None
self.names = names
self.order = order
self.active = active
# widgets
self.button_move_up = QPushButton(_('Move Up'))
self.button_move_down = QPushButton(_('Move Down'))
self.button_delete = QPushButton(_('Delete Layout'))
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.group_box = QGroupBox(_("Layout Dispay and Order"))
self.table = QTableView(self)
self.ok_button = self.button_box.button(QDialogButtonBox.Ok)
self.cancel_button = self.button_box.button(QDialogButtonBox.Cancel)
self.cancel_button.setDefault(True)
self.cancel_button.setAutoDefault(True)
# widget setup
self.dialog_size = QSize(300, 200)
self.setMinimumSize(self.dialog_size)
self.setFixedSize(self.dialog_size)
self.setWindowTitle('Layout Settings')
self.table.setModel(LayoutModel(self.table, order, active))
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
self.table.verticalHeader().hide()
self.table.horizontalHeader().hide()
self.table.setAlternatingRowColors(True)
self.table.setShowGrid(False)
self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.setColumnHidden(1, True)
# need to keep a reference for pyside not to segfault!
self._selection_model = self.table.selectionModel()
# layout
buttons_layout = QVBoxLayout()
buttons_layout.addWidget(self.button_move_up)
buttons_layout.addWidget(self.button_move_down)
buttons_layout.addStretch()
buttons_layout.addWidget(self.button_delete)
group_layout = QHBoxLayout()
group_layout.addWidget(self.table)
group_layout.addLayout(buttons_layout)
self.group_box.setLayout(group_layout)
layout = QVBoxLayout()
layout.addWidget(self.group_box)
layout.addWidget(self.button_box)
self.setLayout(layout)
# signals and slots
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.close)
self.button_delete.clicked.connect(self.delete_layout)
self.button_move_up.clicked.connect(lambda: self.move_layout(True))
self.button_move_down.clicked.connect(lambda: self.move_layout(False))
self.table.model().dataChanged.connect(
lambda: self.selection_changed(None, None))
self._selection_model.selectionChanged.connect(
lambda: self.selection_changed(None, None))
# focus table
index = self.table.model().index(0, 0)
self.table.setCurrentIndex(index)
self.table.setFocus()
def delete_layout(self):
""" """
names, order, active = self.names, self.order, self.order
name = from_qvariant(self.table.selectionModel().currentIndex().data(),
to_text_string)
if name in names:
index = names.index(name)
# In case nothing has focus in the table
if index != -1:
order.remove(name)
names[index] = None
if name in active:
active.remove(name)
self.names, self.order, self.active = names, order, active
self.table.model().set_data(order, active)
index = self.table.model().index(0, 0)
self.table.setCurrentIndex(index)
self.table.setFocus()
self.selection_changed(None, None)
#.........这里部分代码省略.........
开发者ID:ming-hai,项目名称:spyder,代码行数:101,代码来源:layoutdialog.py
示例9: FadingTipBox
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()
#.........这里部分代码省略.........
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:101,代码来源:tour.py
示例10: TestWindow
class TestWindow(QMainWindow):
""" """
sig_resized = Signal("QResizeEvent")
sig_moved = Signal("QMoveEvent")
def __init__(self):
super(TestWindow, self).__init__()
self.setGeometry(300, 100, 400, 600)
self.setWindowTitle('Exploring QMainWindow')
self.exit = QAction('Exit', self)
self.exit.setStatusTip('Exit program')
# create the menu bar
menubar = self.menuBar()
file_ = menubar.addMenu('&File')
file_.addAction(self.exit)
# create the status bar
self.statusBar()
# QWidget or its instance needed for box layout
self.widget = QWidget(self)
self.button = QPushButton('test')
self.button1 = QPushButton('1')
self.button2 = QPushButton('2')
effect = QGraphicsOpacityEffect(self.button2)
self.button2.setGraphicsEffect(effect)
self.anim = QPropertyAnimation(effect, "opacity")
self.anim.setStartValue(0.01)
self.anim.setEndValue(1.0)
self.anim.setDuration(500)
lay = QVBoxLayout()
lay.addWidget(self.button)
lay.addStretch()
lay.addWidget(self.button1)
lay.addWidget(self.button2)
self.widget.setLayout(lay)
self.setCentralWidget(self.widget)
self.button.clicked.connect(self.action1)
self.button1.clicked.connect(self.action2)
self.tour = AnimatedTour(self)
def action1(self):
""" """
frames = get_tour('test')
index = 0
dic = {'last': 0, 'tour': frames}
self.tour.set_tour(index, dic, self)
self.tour.start_tour()
def action2(self):
""" """
self.anim.start()
def resizeEvent(self, event):
"""Reimplement Qt method"""
QMainWindow.resizeEvent(self, event)
self.sig_resized.emit(event)
def moveEvent(self, event):
"""Reimplement Qt method"""
QMainWindow.moveEvent(self, event)
self.sig_moved.emit(event)
开发者ID:MarvinLiu0810,项目名称:spyder,代码行数:70,代码来源:tour.py
示例11: __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)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:89,代码来源:runconfig.py
示例12: ImportWizard
class ImportWizard(QDialog):
"""Text data import wizard"""
def __init__(self, parent, text,
title=None, icon=None, contents_title=None, varname=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
if title is None:
title = _("Import wizard")
self.setWindowTitle(title)
if icon is None:
self.setWindowIcon(get_icon("fileimport.png"))
if contents_title is None:
contents_title = _("Raw text")
if varname is None:
varname = _("variable_name")
self.var_name, self.clip_data = None, None
# Setting GUI
self.tab_widget = QTabWidget(self)
self.text_widget = ContentsWidget(self, text)
self.table_widget = PreviewWidget(self)
self.tab_widget.addTab(self.text_widget, _("text"))
self.tab_widget.setTabText(0, contents_title)
self.tab_widget.addTab(self.table_widget, _("table"))
self.tab_widget.setTabText(1, _("Preview"))
self.tab_widget.setTabEnabled(1, False)
name_layout = QHBoxLayout()
name_h_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding, QSizePolicy.Minimum)
name_layout.addItem(name_h_spacer)
name_label = QLabel(_("Name"))
name_layout.addWidget(name_label)
self.name_edt = QLineEdit()
self.name_edt.setMaximumWidth(100)
self.name_edt.setText(varname)
name_layout.addWidget(self.name_edt)
btns_layout = QHBoxLayout()
cancel_btn = QPushButton(_("Cancel"))
btns_layout.addWidget(cancel_btn)
self.connect(cancel_btn, SIGNAL("clicked()"), self, SLOT("reject()"))
h_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding, QSizePolicy.Minimum)
btns_layout.addItem(h_spacer)
self.back_btn = QPushButton(_("Previous"))
self.back_btn.setEnabled(False)
btns_layout.addWidget(self.back_btn)
self.connect(self.back_btn, SIGNAL("clicked()"),
ft_partial(self._set_step, step=-1))
self.fwd_btn = QPushButton(_("Next"))
btns_layout.addWidget(self.fwd_btn)
self.connect(self.fwd_btn, SIGNAL("clicked()"),
ft_partial(self._set_step, step=1))
self.done_btn = QPushButton(_("Done"))
self.done_btn.setEnabled(False)
btns_layout.addWidget(self.done_btn)
self.connect(self.done_btn, SIGNAL("clicked()"),
self, SLOT("process()"))
self.connect(self.text_widget, SIGNAL("asDataChanged(bool)"),
self.fwd_btn, SLOT("setEnabled(bool)"))
self.connect(self.text_widget, SIGNAL("asDataChanged(bool)"),
self.done_btn, SLOT("setDisabled(bool)"))
layout = QVBoxLayout()
layout.addLayout(name_layout)
layout.addWidget(self.tab_widget)
layout.addLayout(btns_layout)
self.setLayout(layout)
def _focus_tab(self, tab_idx):
"""Change tab focus"""
for i in range(self.tab_widget.count()):
self.tab_widget.setTabEnabled(i, False)
self.tab_widget.setTabEnabled(tab_idx, True)
self.tab_widget.setCurrentIndex(tab_idx)
def _set_step(self,step):
"""Proceed to a given step"""
new_tab = self.tab_widget.currentIndex() + step
assert new_tab < self.tab_widget.count() and new_tab >= 0
if new_tab == self.tab_widget.count()-1:
try:
self.table_widget.open_data(self._get_plain_text(),
self.text_widget.get_col_sep(),
self.text_widget.get_row_sep(),
self.text_widget.trnsp_box.isChecked(),
self.text_widget.get_skiprows(),
self.text_widget.get_comments())
self.done_btn.setEnabled(True)
#.........这里部分代码省略.........
开发者ID:jromang,项目名称:retina-old,代码行数:101,代码来源:importwizard.py
示例13: __init__
def __init__(self, parent, names, order, active):
super(LayoutSettingsDialog, self).__init__(parent)
# variables
self._parent = parent
self._selection_model = None
self.names = names
self.order = order
self.active = active
# widgets
self.button_move_up = QPushButton(_('Move Up'))
self.button_move_down = QPushButton(_('Move Down'))
self.button_delete = QPushButton(_('Delete Layout'))
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.group_box = QGroupBox(_("Layout Dispay and Order"))
self.table = QTableView(self)
self.ok_button = self.button_box.button(QDialogButtonBox.Ok)
self.cancel_button = self.button_box.button(QDialogButtonBox.Cancel)
self.cancel_button.setDefault(True)
self.cancel_button.setAutoDefault(True)
# widget setup
self.dialog_size = QSize(300, 200)
self.setMinimumSize(self.dialog_size)
self.setFixedSize(self.dialog_size)
self.setWindowTitle('Layout Settings')
self.table.setModel(LayoutModel(self.table, order, active))
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
self.table.verticalHeader().hide()
self.table.horizontalHeader().hide()
self.table.setAlternatingRowColors(True)
self.table.setShowGrid(False)
self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.setColumnHidden(1, True)
# need to keep a reference for pyside not to segfault!
self._selection_model = self.table.selectionModel()
# layout
buttons_layout = QVBoxLayout()
buttons_layout.addWidget(self.button_move_up)
buttons_layout.addWidget(self.button_move_down)
buttons_layout.addStretch()
buttons_layout.addWidget(self.button_delete)
group_layout = QHBoxLayout()
group_layout.addWidget(self.table)
group_layout.addLayout(buttons_layout)
self.group_box.setLayout(group_layout)
layout = QVBoxLayout()
layout.addWidget(self.group_box)
layout.addWidget(self.button_box)
self.setLayout(layout)
# signals and slots
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.close)
self.button_delete.clicked.connect(self.delete_layout)
self.button_move_up.clicked.connect(lambda: self.move_layout(True))
self.button_move_down.clicked.connect(lambda: self.move_layout(False))
self.table.model().dataChanged.connect(
lambda: self.selection_changed(None, None))
self._selection_model.selectionChanged.connect(
lambda: self.selection_changed(None, None))
# focus table
index = self.table.model().index(0, 0)
self.table.setCurrentIndex(index)
self.table.setFocus()
开发者ID:ming-hai,项目名称:spyder,代码行数:77,代码来源:layoutdialog.py
示例14: __init__
def __init__(self, parent, text, title=None, icon=None, contents_title=None, varname=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
if title is None:
title = _("Import wizard")
self.setWindowTitle(title)
if icon is None:
self.setWindowIcon(ima.icon("fileimport"))
if contents_title is None:
contents_title = _("Raw text")
if varname is None:
varname = _("variable_name")
self.var_name, self.clip_data = None, None
# Setting GUI
self.tab_widget = QTabWidget(self)
self.text_widget = ContentsWidget(self, text)
self.table_widget = PreviewWidget(self)
self.tab_widget.addTab(self.text_widget, _("text"))
self.tab_widget.setTabText(0, contents_title)
self.tab_widget.addTab(self.table_widget, _("table"))
self.tab_widget.setTabText(1, _("Preview"))
self.tab_widget.setTabEnabled(1, False)
name_layout = QHBoxLayout()
name_label = QLabel(_("Variable Name"))
name_layout.addWidget(name_label)
self.name_edt = QLineEdit()
self.name_edt.setText(varname)
name_layout.addWidget(self.name_edt)
btns_layout = QHBoxLayout()
cancel_btn = QPushButton(_("Cancel"))
btns_layout.addWidget(cancel_btn)
cancel_btn.clicked.connect(self.reject)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
btns_layout.addItem(h_spacer)
self.back_btn = QPushButton(_("Previous"))
self.back_btn.setEnabled(False)
btns_layout.addWidget(self.back_btn)
self.back_btn.clicked.connect(ft_partial(self._set_step, step=-1))
self.fwd_btn = QPushButton(_("Next"))
btns_layout.addWidget(self.fwd_btn)
self.fwd_btn.clicked.connect(ft_partial(self._set_step, step=1))
self.done_btn = QPushButton(_("Done"))
self.done_btn.setEnabled(False)
btns_layout.addWidget(self.done_btn)
self.done_btn.clicked.connect(self.process)
self.text_widget.asDataChanged.connect(self.fwd_btn.setEnabled)
self.text_widget.asDataChanged.connect(self.done_btn.setDisabled)
layout = QVBoxLayout()
layout.addLayout(name_layout)
layout.addWidget(self.tab_widget)
layout.addLayout(btns_layout)
self.setLayout(layout)
开发者ID:gyenney,项目名称:Tools,代码行数:66,代码来源:importwizard.py
示例15: ImportWizard
class ImportWizard(QDialog):
"""Text data import wizard"""
def __init__(self, parent, text, title=None, icon=None, contents_title=None, varname=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
if title is None:
title = _("Import wizard")
self.setWindowTitle(title)
if icon is None:
self.setWindowIcon(ima.icon("fileimport"))
if contents_title is None:
contents_title = _("Raw text")
if varname is None:
varname = _("variable_name")
self.var_name, self.clip_data = None, None
# Setting GUI
self.tab_widget = QTabWidget(self)
self.text_widget = ContentsWidget(self, text)
self.table_widget = PreviewWidget(self)
self.tab_widget.addTab(self.text_widget, _("text"))
self.tab_widget.setTabText(0, contents_title)
self.tab_widget.addTab(self.table_widget, _("table"))
self.tab_widget.setTabText(1, _("Preview"))
self.tab_widget.setTabEnabled(1, False)
name_layout = QHBoxLayout()
name_label = QLabel(_("Variable Name"))
name_layout.addWidget(name_label)
self.name_edt = QLineEdit()
self.name_edt.setText(varname)
name_layout.addWidget(self.name_edt)
btns_layout = QHBoxLayout()
cancel_btn = QPushButton(_("Cancel"))
btns_layout.addWidget(cancel_btn)
cancel_btn.clicked.connect(self.reject)
h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
btns_layout.addItem(h_spacer)
self.back_btn = QPushButton(_("Previous"))
self.back_btn.setEnabled(False)
btns_layout.addWidget(self.back_btn)
self.back_btn.clicked.connect(ft_partial(self._set_step, step=-1))
self.fwd_btn = QPushButton(_("Next"))
btns_layout.addWidget(self.fwd_btn)
self.fwd_btn.clicked.connect(ft_partial(self._set_step, step=1))
self.done_btn = QPushButton(_("Done"))
self.done_btn.setEnabled(False)
btns_layout.addWidget(self.done_btn)
self.done_btn.clicked.connect(self.process)
self.text_widget.asDataChanged.connect(self.fwd_btn.setEnabled)
self.text_widget.asDataChanged.connect(self.done_btn.setDisabled)
layout = QVBoxLayout()
layout.addLayout(name_layout)
layout.addWidget(self.tab_widget)
layout.addLayout(btns_layout)
self.setLayout(layout)
def _focus_tab(self, tab_idx):
"""Change tab focus"""
for i in range(self.tab_widget.count()):
self.tab_widget.setTabEnabled(i, False)
self.tab_widget.setTabEnabled(tab_idx, True)
self.tab_widget.setCurrentIndex(tab_idx)
def _set_step(self, step):
"""Proceed to a given step"""
new_tab = self.tab_widget.currentIndex() + step
assert new_tab < self.tab_widget.count() and new_tab >= 0
if new_tab == self.tab_widget.count() - 1:
try:
self.table_widget.open_data(
self._get_plain_text(),
self.text_widget.get_col_sep(),
self.text_widget.get_row_sep(),
self.text_widget.trnsp_box.isChecked(),
self.text_widget.get_skiprows(),
self.text_widget.get_comments(),
)
self.done_btn.setEnabled(True)
self.done_btn.setDefault(True)
self.fwd_btn.setEnabled(False)
self.back_btn.setEnabled(True)
except (SyntaxError, AssertionError) as error:
QMessageBox.critical(
self,
_("Import wizard"),
_(
#.........这里部分代码省略.........
开发者ID:gyenney,项目名称:Tools,代码行数:101,代码来源:importwizard.py
示例16: __init__
def __init__(self, parent=None):
QPushButton.__init__(self, parent)
self.setFixedSize(20, 20)
self.setIconSize(QSize(12, 12))
self.clicked.connect(self.choose_color)
self._color = QColor()
开发者ID:ming-hai,项目名称:spyder,代码行数:6,代码来源:formlayout.py
注:本文中的spyderlib.qt.QtGui.QPushButton类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论