本文整理汇总了Python中customeditor.CustomEditor.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python CustomEditor.__init__方法的具体用法?Python CustomEditor.__init__怎么用?Python CustomEditor.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类customeditor.CustomEditor
的用法示例。
在下文中一共展示了CustomEditor.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent, maximum=5, editable=True, **kwargs):
CustomEditor.__init__(self, parent)
self.setFocusPolicy(Qt.StrongFocus)
layout = QtGui.QHBoxLayout(self)
layout.setMargin(0)
layout.setSpacing(0)
self.starCount = 5
self.buttons = []
for i in range(self.starCount):
button = QtGui.QToolButton(self)
button.setIcon(self.no_star_icon.getQIcon())
button.setFocusPolicy(Qt.ClickFocus)
if editable:
button.setAutoRaise(True)
else:
button.setAutoRaise(True)
button.setDisabled(True)
button.setFixedHeight(self.get_height())
self.buttons.append(button)
def createStarClick(i):
return lambda:self.starClick(i+1)
for i in range(self.starCount):
self.buttons[i].clicked.connect(createStarClick(i))
for i in range(self.starCount):
layout.addWidget(self.buttons[i])
layout.addStretch()
self.setLayout(layout)
示例2: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self,
parent,
editable = True,
icons = default_icons,
field_name = 'icons',
**kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName( field_name )
self.box = QtGui.QComboBox()
self.box.setFrame(True)
self.box.setEditable(False)
self.name_by_position = {0:None}
self.position_by_name = {None:0}
self.box.addItem('')
for i,(icon_name, icon) in enumerate(icons):
self.name_by_position[i+1] = icon_name
self.position_by_name[icon_name] = i+1
self.box.addItem(icon.getQIcon(), '')
self.box.setFixedHeight(self.get_height())
self.setFocusPolicy(Qt.StrongFocus)
layout = QtGui.QHBoxLayout(self)
layout.setContentsMargins( 0, 0, 0, 0)
layout.setSpacing(0)
self.setAutoFillBackground(True)
if not editable:
self.box.setEnabled(False)
else:
self.box.setEnabled(True)
self.box.activated.connect( self.smiley_changed )
layout.addWidget(self.box)
layout.addStretch()
self.setLayout(layout)
示例3: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self,
parent = None,
field_name = 'richtext',
**kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName( field_name )
self.layout = QtGui.QVBoxLayout(self)
self.layout.setSpacing(0)
self.layout.setContentsMargins( 0, 0, 0, 0)
self.setSizePolicy( QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding )
self.textedit = CustomTextEdit(self)
self.initToolbar() # Has to be invoked before the connect's below.
self.toolbar.hide() # Should only be visible when textedit is focused.
self.textedit.editingFinished.connect(self.emit_editing_finished)
self.textedit.receivedFocus.connect(self.toolbar.show)
self.textedit.setAcceptRichText(True)
# Layout
self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.textedit)
self.setLayout(self.layout)
# Format
self.textedit.setFontWeight(QtGui.QFont.Normal)
self.textedit.setFontItalic(False)
self.textedit.setFontUnderline(False)
#self.textedit.setFocus(Qt.OtherFocusReason)
self.update_alignment()
self.textedit.currentCharFormatChanged.connect(self.update_format)
self.textedit.cursorPositionChanged.connect(self.update_text)
示例4: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent=None, storage=None, remove_original=False,
**kwargs):
CustomEditor.__init__(self, parent)
self.storage = storage
# i'm a < 80 characters fanatic, i know :)
self.new_icon = Icon(
'tango/16x16/actions/list-add.png'
).getQIcon()
self.open_icon = Icon(
'tango/16x16/actions/document-open.png'
).getQIcon()
self.clear_icon = Icon(
'tango/16x16/actions/edit-delete.png'
).getQIcon()
self.save_as_icon = Icon(
'tango/16x16/actions/document-save-as.png'
).getQIcon()
self.document_pixmap = Icon(
'tango/16x16/mimetypes/x-office-document.png'
).getQPixmap()
self.value = None
self.remove_original = remove_original
self.setup_widget()
示例5: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent=None, editable=True, address_type=None, **kwargs):
CustomEditor.__init__(self, parent)
self._address_type = address_type
self.layout = QtGui.QHBoxLayout()
self.layout.setMargin(0)
self.combo = QtGui.QComboBox()
self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
self.combo.setEnabled(editable)
if address_type:
self.combo.setVisible(False)
self.layout.addWidget(self.combo)
self.editor = QtGui.QLineEdit()
self.editor.setEnabled(editable)
self.layout.addWidget(self.editor)
self.setFocusProxy(self.editor)
self.editable = editable
nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
self.label = QtGui.QToolButton()
self.label.setIcon(nullIcon)
self.label.setAutoFillBackground(False)
self.label.setAutoRaise(True)
self.label.setEnabled(False)
self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.layout.addWidget(self.label)
self.editor.editingFinished.connect(self.emit_editing_finished)
self.editor.textEdited.connect(self.editorValueChanged)
self.combo.currentIndexChanged.connect(self.comboIndexChanged)
self.setLayout(self.layout)
self.setAutoFillBackground(True)
self.checkValue(self.editor.text())
示例6: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self,
parent,
editable=True,
nullable=True,
**kwargs):
CustomEditor.__init__(self, parent)
import itertools
self.nullable = nullable
layout = QtGui.QHBoxLayout()
self.dateedit = DateEditor(self, editable=editable, nullable=nullable, **kwargs)
self.dateedit.editingFinished.connect( self.editing_finished )
layout.addWidget(self.dateedit, 1)
self.timeedit = QtGui.QComboBox(self)
self.timeedit.setEditable(True)
if not editable:
self.timeedit.setEnabled(False)
time_entries = [entry
for entry in itertools.chain(*(('%02i:00'%i, '%02i:30'%i)
for i in range(0,24)))]
self.timeedit.addItems(time_entries)
self.timeedit.setValidator(TimeValidator(self, nullable))
self.timeedit.currentIndexChanged.connect( self.editing_finished )
self.timeedit.editTextChanged.connect( self.editing_finished )
self.timeedit.setFocusPolicy( Qt.StrongFocus )
layout.addWidget(self.timeedit, 1)
# focus proxy is needed to activate the editor with a single click
self.setFocusProxy(self.dateedit)
self.setLayout(layout)
示例7: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent=None, **kwargs):
CustomEditor.__init__(self, parent)
self.layout = QtGui.QVBoxLayout(self)
self.layout.setSpacing(0)
self.layout.setMargin(0)
self.setSizePolicy( QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding )
class CustomTextEdit(QtGui.QTextEdit):
"""A TextEdit editor that sends editingFinished events when the text was changed
and focus is lost
"""
editingFinished = QtCore.pyqtSignal()
def __init__(self, parent):
super(CustomTextEdit, self).__init__(parent)
self._changed = False
self.setTabChangesFocus( True )
self.textChanged.connect( self._handle_text_changed )
def focusOutEvent(self, event):
if self._changed:
self.editingFinished.emit()
super(CustomTextEdit, self).focusOutEvent( event )
def _handle_text_changed(self):
self._changed = True
def setTextChanged(self, state=True):
self._changed = state
def setHtml(self, html):
QtGui.QTextEdit.setHtml(self, html)
self._changed = False
self.textedit = CustomTextEdit(self)
self.textedit.editingFinished.connect( self.emit_editing_finished )
self.textedit.setAcceptRichText(True)
self.initButtons()
# #
# # Layout
# #
# self.layout.addWidget(self.toolbar)
self.layout.addWidget(self.textedit)
self.setLayout(self.layout)
#
# Format
#
self.textedit.setFontWeight(QtGui.QFont.Normal)
self.textedit.setFontItalic(False)
self.textedit.setFontUnderline(False)
#self.textedit.setFocus(Qt.OtherFocusReason)
self.update_alignment()
self.textedit.currentCharFormatChanged.connect(self.update_format)
self.textedit.cursorPositionChanged.connect(self.update_text)
示例8: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent=None, storage=None, field_name="file", remove_original=False, **kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName(field_name)
self.storage = storage
self.filename = None # the widget containing the filename
self.value = None
self.remove_original = remove_original
self.setup_widget()
示例9: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent = None,
editable = True,
nullable = True,
field_name = 'date',
**kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName( field_name )
self.date_format = local_date_format()
self.line_edit = DecoratedLineEdit()
self.line_edit.set_minimum_width( len( self.date_format ) )
self.line_edit.set_background_text( QtCore.QDate(2000,1,1).toString(self.date_format) )
# The order of creation of this widgets and their parenting
# seems very sensitive under windows and creates system crashes
# so don't change this without extensive testing on windows
special_date_menu = QtGui.QMenu(self)
calendar_widget_action = QtGui.QWidgetAction(special_date_menu)
self.calendar_widget = QtGui.QCalendarWidget(special_date_menu)
self.calendar_widget.activated.connect(self.calendar_widget_activated)
self.calendar_widget.clicked.connect(self.calendar_widget_activated)
calendar_widget_action.setDefaultWidget(self.calendar_widget)
self.calendar_action_trigger.connect( special_date_menu.hide )
special_date_menu.addAction(calendar_widget_action)
special_date_menu.addAction(_('Today'))
special_date_menu.addAction(_('Far future'))
self.special_date = QtGui.QToolButton(self)
self.special_date.setIcon( self.special_date_icon.getQIcon() )
self.special_date.setAutoRaise(True)
self.special_date.setToolTip(_('Calendar and special dates'))
self.special_date.setMenu(special_date_menu)
self.special_date.setPopupMode(QtGui.QToolButton.InstantPopup)
self.special_date.setFixedHeight(self.get_height())
self.special_date.setFocusPolicy(Qt.ClickFocus)
# end of sensitive part
if nullable:
special_date_menu.addAction(_('Clear'))
self.hlayout = QtGui.QHBoxLayout()
self.hlayout.addWidget(self.line_edit)
self.hlayout.addWidget(self.special_date)
self.hlayout.setContentsMargins(0, 0, 0, 0)
self.hlayout.setSpacing(0)
self.hlayout.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
self.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.hlayout)
self.minimum = datetime.date.min
self.maximum = datetime.date.max
self.setFocusProxy(self.line_edit)
self.line_edit.editingFinished.connect( self.line_edit_finished )
self.line_edit.textEdited.connect(self.text_edited)
special_date_menu.triggered.connect(self.set_special_date)
示例10: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent=None, editable=True, **kwargs):
CustomEditor.__init__(self, parent)
layout = QtGui.QVBoxLayout(self)
layout.setSpacing(0)
layout.setMargin(0)
self.color_button = QtGui.QPushButton(parent)
self.color_button.setMaximumSize(QtCore.QSize(20, 20))
layout.addWidget(self.color_button)
if editable:
self.color_button.clicked.connect(self.buttonClicked)
self.setLayout(layout)
self._color = None
示例11: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self,
parent = None,
field_name = 'local_file',
directory = False,
save_as = False,
file_filter = 'All files (*)',
**kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName( field_name )
self._directory = directory
self._save_as = save_as
self._file_filter = file_filter
self.setup_widget()
示例12: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent, img='face-plain', editable=True, **kwargs):
CustomEditor.__init__(self, parent)
self.box = QtGui.QComboBox()
self.box.setFrame(True)
self.box.setEditable(False)
self.allSmileys = []
self.allSmileys.append('face-angel')
self.allSmileys.append('face-crying')
self.allSmileys.append('face-devilish')
self.allSmileys.append('face-glasses')
self.allSmileys.append('face-grin')
self.allSmileys.append('face-kiss')
self.allSmileys.append('face-monkey')
self.allSmileys.append('face-plain')
self.allSmileys.append('face-sad')
self.allSmileys.append('face-smile')
self.allSmileys.append('face-smile-big')
self.allSmileys.append('face-surprise')
self.allSmileys.append('face-wink')
for i, value in enumerate(self.allSmileys):
imgPath = 'tango/16x16/emotes/' + value + '.png'
icon = Icon(imgPath).getQIcon()
self.box.addItem(icon, '')
self.box.setFixedHeight(self.get_height())
if value == 'face-plain':
self.box.setCurrentIndex(i)
self.setFocusPolicy(Qt.StrongFocus)
layout = QtGui.QHBoxLayout(self)
layout.setMargin(0)
layout.setSpacing(0)
self.img = img
self.imgPath = 'tango/16x16/emotes/' + img + '.png'
self.Icon = Icon(self.imgPath).getQIcon()
self.setAutoFillBackground(True)
#self.starCount = maximum
if not editable:
self.box.setEnabled(False)
else:
self.box.setEnabled(True)
self.box.currentIndexChanged.connect(self.smiley_changed)
layout.addWidget(self.box)
layout.addStretch()
self.setLayout(layout)
示例13: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self,
parent = None,
editable = True,
address_type = None,
address_validator = default_address_validator,
field_name = 'virtual_address',
**kwargs):
"""
:param address_type: limit the allowed address to be entered to be
of a certain time, can be 'phone', 'fax', 'email', 'mobile', 'pager'.
If set to None, all types are allowed.
Upto now, the corrected address returned by the address validator is
not yet taken into account.
"""
CustomEditor.__init__(self, parent)
self.setObjectName( field_name )
self._address_type = address_type
self._address_validator = address_validator
self.layout = QtGui.QHBoxLayout()
self.layout.setContentsMargins( 0, 0, 0, 0)
self.combo = QtGui.QComboBox()
self.combo.addItems(camelot.types.VirtualAddress.virtual_address_types)
self.combo.setEnabled(editable)
if address_type:
self.combo.setVisible(False)
self.layout.addWidget(self.combo)
self.editor = DecoratedLineEdit( self )
self.editor.setEnabled(editable)
self.editor.set_minimum_width( 30 )
self.layout.addWidget(self.editor)
self.setFocusProxy(self.editor)
self.editable = editable
nullIcon = Icon('tango/16x16/apps/internet-mail.png').getQIcon()
self.label = QtGui.QToolButton()
self.label.setIcon(nullIcon)
self.label.setAutoRaise(True)
self.label.setEnabled(False)
self.label.setToolButtonStyle(Qt.ToolButtonIconOnly)
self.label.setFocusPolicy(Qt.ClickFocus)
self.label.clicked.connect( self.mail_click )
self.label.hide()
self.layout.addWidget(self.label)
self.editor.editingFinished.connect(self.emit_editing_finished)
self.editor.textEdited.connect(self.editorValueChanged)
self.combo.currentIndexChanged.connect(self.comboIndexChanged)
self.setLayout(self.layout)
self.checkValue(self.editor.text())
示例14: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__(self, parent, precision=2, reverse=False, neutral=False, option=None, field_name="float", **kwargs):
CustomEditor.__init__(self, parent)
self.setObjectName(field_name)
action = QtGui.QAction(self)
action.setShortcut(QtGui.QKeySequence(Qt.Key_F4))
self.setFocusPolicy(Qt.StrongFocus)
self.spinBox = CustomDoubleSpinBox(option, parent)
self.spinBox.setDecimals(precision)
self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.spinBox.addAction(action)
self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)
self.arrow = QtGui.QLabel()
self.arrow.setPixmap(self.go_up.getQPixmap())
self.arrow.setFixedHeight(self.get_height())
self.arrow.setAutoFillBackground(False)
self.arrow.setMaximumWidth(19)
self.calculatorButton = QtGui.QToolButton()
self.calculatorButton.setIcon(self.calculator_icon.getQIcon())
self.calculatorButton.setAutoRaise(True)
self.calculatorButton.setFixedHeight(self.get_height())
self.calculatorButton.clicked.connect(lambda: self.popupCalculator(self.spinBox.value()))
action.triggered.connect(lambda: self.popupCalculator(self.spinBox.value()))
self.spinBox.editingFinished.connect(self.spinbox_editing_finished)
self.releaseKeyboard()
layout = QtGui.QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.addSpacing(3.5)
layout.addWidget(self.arrow)
layout.addWidget(self.spinBox)
layout.addWidget(self.calculatorButton)
self.reverse = reverse
self.neutral = neutral
self.setFocusProxy(self.spinBox)
self.setLayout(layout)
if not self.reverse:
if not self.neutral:
self.icons = {-1: self.go_down_red, 1: self.go_up, 0: self.zero}
else:
self.icons = {-1: self.go_down_blue, 1: self.go_up_blue, 0: self.zero}
else:
self.icons = {1: self.go_down_red, -1: self.go_up, 0: self.zero}
示例15: __init__
# 需要导入模块: from customeditor import CustomEditor [as 别名]
# 或者: from customeditor.CustomEditor import __init__ [as 别名]
def __init__( self,
admin = None,
parent = None,
create_inline = False,
vertical_header_clickable = True,
**kw ):
"""
:param admin: the Admin interface for the objects on the one side of the
relation
:param create_inline: if False, then a new entity will be created within a
new window, if True, it will be created inline
:param vertical_header_clickable: True if the vertical header is clickable by the user, False if not.
after creating the editor, set_value needs to be called to set the
actual data to the editor
"""
CustomEditor.__init__( self, parent )
layout = QtGui.QHBoxLayout()
layout.setContentsMargins( 0, 0, 0, 0 )
#
# Setup table
#
from camelot.view.controls.tableview import AdminTableWidget
# parent set by layout manager
table = AdminTableWidget(admin, self)
table.setObjectName('table')
rowHeight = QtGui.QFontMetrics( self.font() ).height() + 5
layout.setSizeConstraint( QtGui.QLayout.SetNoConstraint )
self.setSizePolicy( QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding )
self.setMinimumHeight( rowHeight*5 )
if vertical_header_clickable:
table.verticalHeader().sectionClicked.connect(
self.createFormForIndex
)
self.admin = admin
self.create_inline = create_inline
self.add_button = None
self.copy_button = None
self.delete_button = None
layout.addWidget( table )
self.setupButtons( layout, table )
self.setLayout( layout )
self.model = None
self._new_message = None