本文整理汇总了Python中spyderlib.config.gui.get_font函数的典型用法代码示例。如果您正苦于以下问题:Python get_font函数的具体用法?Python get_font怎么用?Python get_font使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_font函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_font
def change_font(self):
"""Change console font"""
font, valid = QFontDialog.getFont(get_font(self.CONF_SECTION), self,
_("Select a new font"))
if valid:
self.set_plain_text_font(font)
set_font(font, self.CONF_SECTION)
示例2: data
def data(self, index, role=Qt.DisplayRole):
"""Cell content"""
if not index.isValid():
return to_qvariant()
value = self.get_value(index)
if is_binary_string(value):
try:
value = to_text_string(value, 'utf8')
except:
pass
if role == Qt.DisplayRole:
if value is np.ma.masked:
return ''
else:
return to_qvariant(self._format % value)
elif role == Qt.TextAlignmentRole:
return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
elif role == Qt.BackgroundColorRole and self.bgcolor_enabled \
and value is not np.ma.masked:
hue = self.hue0+\
self.dhue*(self.vmax-self.color_func(value)) \
/(self.vmax-self.vmin)
hue = float(np.abs(hue))
color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
return to_qvariant(color)
elif role == Qt.FontRole:
return to_qvariant(get_font('arrayeditor'))
return to_qvariant()
示例3: __init__
def __init__(self, parent, statusbar):
QWidget.__init__(self, parent)
self.label_font = font = get_font('editor')
font.setPointSize(self.font().pointSize())
font.setBold(True)
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
statusbar.addPermanentWidget(self)
示例4: __init__
def __init__(self, text, title='', font=None, parent=None,
readonly=False, size=(400, 300)):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.text = None
# Display text as unicode if it comes as bytes, so users see
# its right representation
if is_binary_string(text):
self.is_binary = True
text = to_text_string(text, 'utf8')
else:
self.is_binary = False
self.layout = QVBoxLayout()
self.setLayout(self.layout)
# Text edit
self.edit = QTextEdit(parent)
self.edit.textChanged.connect(self.text_changed)
self.edit.setReadOnly(readonly)
self.edit.setPlainText(text)
if font is None:
font = get_font()
self.edit.setFont(font)
self.layout.addWidget(self.edit)
# Buttons configuration
buttons = QDialogButtonBox.Ok
if not readonly:
buttons = buttons | QDialogButtonBox.Cancel
bbox = QDialogButtonBox(buttons)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
self.layout.addWidget(bbox)
# Make the dialog act as a window
self.setWindowFlags(Qt.Window)
self.setWindowIcon(ima.icon('edit'))
self.setWindowTitle(_("Text editor") + \
"%s" % (" - "+str(title) if str(title) else ""))
self.resize(size[0], size[1])
示例5: createEditor
def createEditor(self, parent, option, index):
"""Create editor widget"""
model = index.model()
value = model.get_value(index)
if model._data.dtype.name == "bool":
value = not value
model.setData(index, to_qvariant(value))
return
elif value is not np.ma.masked:
editor = QLineEdit(parent)
editor.setFont(get_font('arrayeditor'))
editor.setAlignment(Qt.AlignCenter)
if is_number(self.dtype):
editor.setValidator(QDoubleValidator(editor))
editor.returnPressed.connect(self.commitAndCloseEditor)
return editor
示例6: get_plugin_font
def get_plugin_font(self, rich_text=False):
"""
Return plugin font option.
All plugins in Spyder use a global font. This is a convenience method
in case some plugins will have a delta size based on the default size.
"""
if rich_text:
option = 'rich_font'
font_size_delta = self.RICH_FONT_SIZE_DELTA
else:
option = 'font'
font_size_delta = self.FONT_SIZE_DELTA
return get_font(option=option, font_size_delta=font_size_delta)
示例7: __init__
def __init__(self, parent, history_filename, profile=False):
"""
parent : specifies the parent widget
"""
ConsoleBaseWidget.__init__(self, parent)
SaveHistoryMixin.__init__(self)
# Prompt position: tuple (line, index)
self.current_prompt_pos = None
self.new_input_line = True
# History
self.histidx = None
self.hist_wholeline = False
assert is_text_string(history_filename)
self.history_filename = history_filename
self.history = self.load_history()
# Session
self.historylog_filename = CONF.get('main', 'historylog_filename',
get_conf_path('history.log'))
# Context menu
self.menu = None
self.setup_context_menu()
# Simple profiling test
self.profile = profile
# Buffer to increase performance of write/flush operations
self.__buffer = []
self.__timestamp = 0.0
self.__flushtimer = QTimer(self)
self.__flushtimer.setSingleShot(True)
self.__flushtimer.timeout.connect(self.flush)
# Give focus to widget
self.setFocus()
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('console')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
示例8: data
def data(self, index, role=Qt.DisplayRole):
"""Cell content"""
if not index.isValid():
return to_qvariant()
if role == Qt.DisplayRole or role == Qt.EditRole:
column = index.column()
row = index.row()
if column == 0:
return to_qvariant(to_text_string(self.df_index[row]))
else:
value = self.get_value(row, column-1)
if isinstance(value, float):
return to_qvariant(self._format % value)
else:
try:
return to_qvariant(to_text_string(value))
except UnicodeDecodeError:
return to_qvariant(encoding.to_unicode(value))
elif role == Qt.BackgroundColorRole:
return to_qvariant(self.get_bgcolor(index))
elif role == Qt.FontRole:
return to_qvariant(get_font('arrayeditor'))
return to_qvariant()
示例9: test
def test():
from spyderlib.utils.qthelpers import qapplication
app = qapplication()
from spyderlib.plugins.variableexplorer import VariableExplorer
settings = VariableExplorer.get_settings()
shell = ExternalPythonShell(pythonexecutable=sys.executable,
interact=True,
stand_alone=settings,
wdir=osp.dirname(__file__),
mpl_backend=0,
light_background=False)
from spyderlib.config.gui import get_font
font = get_font()
shell.shell.set_font(font)
shell.shell.toggle_wrap_mode(True)
shell.start_shell(False)
shell.show()
sys.exit(app.exec_())
示例10: set_infowidget_font
def set_infowidget_font(self):
"""Set font for infowidget"""
font = get_font('inspector', 'rich_text')
self.infowidget.set_font(font)
示例11: set_infowidget_font
def set_infowidget_font(self):
"""Set font for infowidget"""
font = get_font(option='rich_font')
self.infowidget.set_font(font)
示例12: get_plugin_font
def get_plugin_font(self, option=None):
"""Return plugin font option"""
return get_font(self.CONF_SECTION, option)