本文整理汇总了Python中PyQt4.Qt.QTextEdit.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.__init__方法的具体用法?Python QTextEdit.__init__怎么用?Python QTextEdit.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTextEdit
的用法示例。
在下文中一共展示了QTextEdit.__init__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self,
prompt='>>> ',
continuation='... ',
parent=None):
QTextEdit.__init__(self, parent)
self.shutting_down = False
self.compiler = CommandCompiler()
self.buf = self.old_buf = []
self.history = History([''], dynamic.get('console_history', []))
self.prompt_frame = None
self.allow_output = False
self.prompt_frame_format = QTextFrameFormat()
self.prompt_frame_format.setBorder(1)
self.prompt_frame_format.setBorderStyle(QTextFrameFormat.BorderStyle_Solid)
self.prompt_len = len(prompt)
self.doc.setMaximumBlockCount(int(prefs['scrollback']))
self.lexer = PythonLexer(ensurenl=False)
self.tb_lexer = PythonTracebackLexer()
self.context_menu = cm = QMenu(self) # {{{
cm.theme = ThemeMenu(cm)
# }}}
self.formatter = Formatter(prompt, continuation, style=prefs['theme'])
p = QPalette()
p.setColor(p.Base, QColor(self.formatter.background_color))
p.setColor(p.Text, QColor(self.formatter.color))
self.setPalette(p)
self.key_dispatcher = { # {{{
Qt.Key_Enter : self.enter_pressed,
Qt.Key_Return : self.enter_pressed,
Qt.Key_Up : self.up_pressed,
Qt.Key_Down : self.down_pressed,
Qt.Key_Home : self.home_pressed,
Qt.Key_End : self.end_pressed,
Qt.Key_Left : self.left_pressed,
Qt.Key_Right : self.right_pressed,
Qt.Key_Backspace : self.backspace_pressed,
Qt.Key_Delete : self.delete_pressed,
} # }}}
motd = textwrap.dedent('''\
# Python {0}
# {1} {2}
'''.format(sys.version.splitlines()[0], __appname__,
__version__))
sys.excepthook = self.unhandled_exception
self.controllers = []
QTimer.singleShot(0, self.launch_controller)
with EditBlock(self.cursor):
self.render_block(motd)
示例2: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self, *args):
QTextEdit.__init__(self, *args)
self._active = False
# Default dictionary based on the current locale.
self.dict = enchant.Dict()
self.highlighter = Highlighter(self.document())
self.highlighter.setDict(self.dict)
self.highlighter.setActivateSpellCheck(self._active)
示例3: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self, parent = None, desc = None, name = None, modal = 0, fl = 0, env = None, type = "QDialog"):
if env is None:
import foundation.env as env # this is a little weird... probably it'll be ok, and logically it seems correct.
self.desc = desc
self.typ = type
if type == "QDialog":
QDialog.__init__(self,parent,name,modal,fl)
elif type == "QTextEdit":
QTextEdit.__init__(self, parent, name)
elif type == "QFrame":
QFrame.__init__(self,parent,name)
else:
print "don't know about type == %r" % (type,)
self.image1 = QPixmap()
self.image1.loadFromData(image1_data,"PNG") # should be: title_icon ####
self.image3 = QPixmap()
self.image3.loadFromData(image3_data,"PNG")
self.image4 = QPixmap()
self.image4.loadFromData(image4_data,"PNG")
self.image5 = QPixmap()
self.image5.loadFromData(image5_data,"PNG")
self.image6 = QPixmap()
self.image6.loadFromData(image6_data,"PNG")
self.image7 = QPixmap()
self.image7.loadFromData(image7_data,"PNG")
self.image0 = QPixmap(image0_data) # should be: border_icon ####
self.image2 = QPixmap(image2_data) # should be: sponsor_pixmap ####
try:
####@@@@
title_icon_name = self.desc.options.get('title_icon')
border_icon_name = self.desc.options.get('border_icon')
if title_icon_name:
self.image1 = imagename_to_pixmap(title_icon_name) ###@@@ pass icon_path
###@@@ import imagename_to_pixmap or use env function
# or let that func itself be an arg, or have an env arg for it
###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset)
###e use iconset instead?
if border_icon_name:
self.image0 = imagename_to_pixmap(border_icon_name)
except:
print_compact_traceback("bug in icon-setting code, using fallback icons: ")
pass
if not name:
self.setName("parameter_dialog_or_frame") ###
###k guess this will need: if type == 'QDialog'
self.setIcon(self.image0) # should be: border_icon ####
nanotube_dialogLayout = QVBoxLayout(self,0,0,"nanotube_dialogLayout")
self.heading_frame = QFrame(self,"heading_frame")
self.heading_frame.setPaletteBackgroundColor(QColor(122,122,122))
self.heading_frame.setFrameShape(QFrame.NoFrame)
self.heading_frame.setFrameShadow(QFrame.Plain)
heading_frameLayout = QHBoxLayout(self.heading_frame,0,3,"heading_frameLayout")
self.heading_pixmap = QLabel(self.heading_frame,"heading_pixmap")
self.heading_pixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.heading_pixmap.sizePolicy().hasHeightForWidth()))
self.heading_pixmap.setPixmap(self.image1) # should be: title_icon ####
self.heading_pixmap.setScaledContents(1)
heading_frameLayout.addWidget(self.heading_pixmap)
self.heading_label = QLabel(self.heading_frame,"heading_label")
self.heading_label.setPaletteForegroundColor(QColor(255,255,255))
heading_label_font = QFont(self.heading_label.font())
heading_label_font.setPointSize(12)
heading_label_font.setBold(1)
self.heading_label.setFont(heading_label_font)
heading_frameLayout.addWidget(self.heading_label)
nanotube_dialogLayout.addWidget(self.heading_frame)
self.body_frame = QFrame(self,"body_frame")
self.body_frame.setFrameShape(QFrame.StyledPanel)
self.body_frame.setFrameShadow(QFrame.Raised)
body_frameLayout = QVBoxLayout(self.body_frame,3,3,"body_frameLayout")
self.sponsor_frame = QFrame(self.body_frame,"sponsor_frame")
self.sponsor_frame.setPaletteBackgroundColor(QColor(255,255,255))
self.sponsor_frame.setFrameShape(QFrame.StyledPanel)
self.sponsor_frame.setFrameShadow(QFrame.Raised)
sponsor_frameLayout = QHBoxLayout(self.sponsor_frame,0,0,"sponsor_frameLayout")
self.sponsor_btn = QPushButton(self.sponsor_frame,"sponsor_btn")
self.sponsor_btn.setAutoDefault(0) #bruce 060703 bugfix
self.sponsor_btn.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred,0,0,self.sponsor_btn.sizePolicy().hasHeightForWidth()))
self.sponsor_btn.setPaletteBackgroundColor(QColor(255,255,255))
self.sponsor_btn.setPixmap(self.image2) # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor]
self.sponsor_btn.setFlat(1)
sponsor_frameLayout.addWidget(self.sponsor_btn)
body_frameLayout.addWidget(self.sponsor_frame)
layout59 = QHBoxLayout(None,0,6,"layout59")
left_spacer = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
layout59.addItem(left_spacer)
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self,
parentWidget,
label = '',
labelColumn = 0,
spanWidth = False,
addToParent = True,
permit_enter_keystroke = True
):
"""
Appends a QTextEdit (Qt) widget to the bottom of I{parentWidget},
a Property Manager group box.
The QTextEdit is empty (has no text) by default. Use insertHtml()
to insert HTML text into the TextEdit.
@param parentWidget: the parent group box containing this widget.
@type parentWidget: PM_GroupBox
@param label: The label that appears to the left of (or above) the
spin box. To suppress the label, set I{label} to an
empty string.
@type label: str
@param spanWidth: If True, the spin box and its label will span the width
of the group box. The label will appear directly above
the spin box and is left justified.
@type spanWidth: bool
@param addToParent: If True (the default), self will be added to
parentWidget by passing it to
parentWidget.addPmWidget. If False, self will not
be added to parentWidget. Typically, when this is
False, the caller will add self to parent in some
other way.
@type addToParent: bool
@param permit_enter_keystroke: If set to True, this PM_textEdit can have multiple
lines. Otherwise, it will block the 'Enter' keypress
within the text editor. Note that caller needs
to make sure that linewrapping option is a
propriately set, (in addition to this flag)
so as to permit/ not permit multiple lines
in the text edit.
@see: U{B{QTextEdit}<http://doc.trolltech.com/4/qtextedit.html>}
"""
if 0: # Debugging code
print "QTextEdit.__init__():"
print " label =", label
print " labelColumn =", labelColumn
print " spanWidth =", spanWidth
QTextEdit.__init__(self)
self.parentWidget = parentWidget
self.label = label
self.labelColumn = labelColumn
self.spanWidth = spanWidth
self._permit_enter_keystroke = permit_enter_keystroke
if label: # Create this widget's QLabel.
self.labelWidget = QLabel()
self.labelWidget.setText(label)
self._setHeight() # Default height is 4 lines high.
## from PM.PM_MessageGroupBox import PM_MessageGroupBox
## if isinstance(parentWidget, PM_MessageGroupBox):
## # Add to parentWidget's vBoxLayout if <parentWidget> is a MessageGroupBox.
## parentWidget.vBoxLayout.addWidget(self)
## # We should be calling the PM's getMessageTextEditPalette() method,
## # but that will take some extra work which I will do soon. Mark 2007-06-21
## self.setPalette(getPalette( None,
## QPalette.Base,
## pmMessageBoxColor))
## self.setReadOnly(True)
## #@self.labelWidget = None # Never has one. Mark 2007-05-31
## parentWidget._widgetList.append(self)
## parentWidget._rowCount += 1
## else:
## parentWidget.addPmWidget(self)
# bruce 071103 refactored the above into the new addToParent option and
# code added to PM_MessageGroupBox.__init__ after it calls this method.
if addToParent:
parentWidget.addPmWidget(self)
return
示例5: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self, *args):
QTextEdit.__init__(self, *args)
self.lastFolder = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DocumentsLocation)
self.docName = None
self.initDict()
示例6: __init__
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import __init__ [as 别名]
def __init__(self, *args):
QTextEdit.__init__(self, *args)