当前位置: 首页>>代码示例>>Python>>正文


Python Qt.QTextEdit类代码示例

本文整理汇总了Python中PyQt4.Qt.QTextEdit的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit类的具体用法?Python QTextEdit怎么用?Python QTextEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTextEdit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insertHtmlMessage

    def insertHtmlMessage(self, text, setAsDefault=True,
                          minLines=4, maxLines=10,
                          replace=True):
        """Insert <text> (HTML) into the message groupbox.
        <minLines> - The minimum number of lines (of text) to display in the TextEdit.
        if <minLines>=0 the TextEdit will fit its own height to fit <text>. The
        default height is 4 (lines of text).
        <maxLines> - The maximum number of lines to display in the TextEdit widget.
        <replace> should be set to False if you do not wish
        to replace the current text. It will append <text> instead.

        Shows the message groupbox if it is hidden.
        """
        if setAsDefault:
            self.defaultText = text
            self.setAsDefault = True

        if replace:
            self.MessageTextEdit.clear()

        if text:
            self._setHeight(minLines, maxLines)
            QTextEdit.insertHtml(self.MessageTextEdit, text)
            self.show()
        else:
            # Hide the message groupbox if it contains no text.
            self.hide()
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:27,代码来源:PropertyManagerMixin.py

示例2: mousePressEvent

 def mousePressEvent(self, event):
     if event.button() == Qt.RightButton:
         # Rewrite the mouse event to a left button event so the cursor is
         # moved to the location of the pointer.
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
     QTextEdit.mousePressEvent(self, event)
开发者ID:RealDoll,项目名称:emesene,代码行数:7,代码来源:SpellTextEdit.py

示例3: __init__

    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)
开发者ID:089git,项目名称:calibre,代码行数:57,代码来源:console.py

示例4: main

def main(args=sys.argv):
    app = QApplication(args)
 
    editor = QTextEdit()
    nb=NumberBar(edit=editor)
    nb.show()
    editor.show()
 
    return app.exec_()
开发者ID:koo5,项目名称:yorave,代码行数:9,代码来源:numberbar.py

示例5: __init__

    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)
开发者ID:RealDoll,项目名称:emesene,代码行数:9,代码来源:SpellTextEdit.py

示例6: LineTextWidget

class LineTextWidget(QFrame):
    def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)

        self.edit = QTextEdit()
        self.edit.setFrameStyle(QFrame.NoFrame)
        self.edit.setAcceptRichText(False)

        self.number_bar = NumberBar()
        self.number_bar.setTextEdit(self.edit)

        hbox = QHBoxLayout(self)
        hbox.setSpacing(0)
        hbox.setMargin(0)
        hbox.addWidget(self.number_bar)
        hbox.addWidget(self.edit)

        self.edit.installEventFilter(self)
        self.edit.viewport().installEventFilter(self)

    def eventFilter(self, object, event):
        # Update the line numbers for all events on the text edit and the viewport.
        # This is easier than connecting all necessary singals.
        if object in (self.edit, self.edit.viewport()):
            self.number_bar.update()
            return False
        return QFrame.eventFilter(object, event)

    def getTextEdit(self):
        return self.edit
开发者ID:CodingRobots,项目名称:CodingRobots,代码行数:32,代码来源:numberedtextedit.py

示例7: show

 def show(self):
     if self.controller:
         self.controller.setSponsor()
     if self.typ == "QDialog":
         QDialog.show(self)
     elif self.typ == "QTextEdit":
         QTextEdit.show(self)
     elif self.typ == "QFrame":
         QFrame.show(self)
     else:
         print "don't know about self.typ == %r" % (self.typ,)
开发者ID:elfion,项目名称:nanoengineer,代码行数:11,代码来源:ParameterDialog.py

示例8: createLogDisplay

 def createLogDisplay(self):
    logTextDisplay = QTextEdit()
    logTextDisplay.setFont(GETFONT('Fixed', 8))
    w,h = relaxedSizeNChar(logTextDisplay, 68)[0], int(12 * 8.2)
    logTextDisplay.setMinimumWidth(w)
    logTextDisplay.setMinimumHeight(h)
    logTextDisplay.setReadOnly(True)
    return logTextDisplay
开发者ID:Bitcoinsulting,项目名称:BitcoinArmorydev,代码行数:8,代码来源:LoggingPlugin.py

示例9: keyPressEvent

 def keyPressEvent(self, ev):
     text = unicode(ev.text())
     key = ev.key()
     action = self.key_dispatcher.get(key, None)
     if callable(action):
         action()
     elif key in (Qt.Key_Escape,):
         QTextEdit.keyPressEvent(self, ev)
     elif text:
         self.text_typed(text)
     else:
         QTextEdit.keyPressEvent(self, ev)
开发者ID:089git,项目名称:calibre,代码行数:12,代码来源:console.py

示例10: keyPressEvent

 def keyPressEvent(self, event):
     """
     Overrides the superclass method. 
     """
     #If user hits 'Enter' key (return key), don't do anything. 
     if event.key() == Qt.Key_Return:
         #there is no obvious way to allow only a single line in a 
         #QTextEdit (we can use some methods that restrict the columnt width
         #, line wrapping etc but this is untested when the line contains 
         # huge umber of characters. Anyway, the following always works 
         #and fixes bug 2713
         if not self._permit_enter_keystroke:
             return  
         
     QTextEdit.keyPressEvent(self, event)
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:15,代码来源:PM_TextEdit.py

示例11: _init_controls

    def _init_controls(self):
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        ml = QHBoxLayout()
        layout.addLayout(ml, 1)

        self.keys_list = QListWidget(self)
        self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection)
        self.keys_list.setFixedWidth(150)
        self.keys_list.setAlternatingRowColors(True)
        ml.addWidget(self.keys_list)
        self.value_text = QTextEdit(self)
        self.value_text.setTabStopWidth(24)
        self.value_text.setReadOnly(False)
        ml.addWidget(self.value_text, 1)

        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self._apply_changes)
        button_box.rejected.connect(self.reject)
        self.clear_button = button_box.addButton('Clear', QDialogButtonBox.ResetRole)
        self.clear_button.setIcon(get_icon('trash.png'))
        self.clear_button.setToolTip('Clear all settings for this plugin')
        self.clear_button.clicked.connect(self._clear_settings)
        layout.addWidget(button_box)
开发者ID:beeftornado,项目名称:calibre-shelfari-metadata,代码行数:25,代码来源:common_utils.py

示例12: __init__

    def __init__(self, gui, icon, do_user_config):
        QDialog.__init__(self, gui)
        self.gui = gui
        self.do_user_config = do_user_config

        # The current database shown in the GUI
        self.db = gui.current_db

        self.prefs = PrefsFacade(self.db)

        self.version = Downloader.version

        # The GUI, created and layouted by hand...
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.setWindowTitle('Beam EBooks Downloader')
        self.setWindowIcon(icon)

        self.log_area = QTextEdit('Log output', self)
        self.log_area.setReadOnly(True)
        self.log_area.setLineWrapMode(QTextEdit.NoWrap);
        self.log_area.setText("")
        self.layout.addWidget(self.log_area)

        self.download_button = QPushButton('Download books', self)
        self.download_button.clicked.connect(self.download)
        self.layout.addWidget(self.download_button)

        self.conf_button = QPushButton('Configure this plugin', self)
        self.conf_button.clicked.connect(self.config)
        self.layout.addWidget(self.conf_button)

        self.resize(self.sizeHint())
开发者ID:hakan42,项目名称:calibre-beam-ebooks-downloader-plugin,代码行数:34,代码来源:gui.py

示例13: __init__

    def __init__(self, parent = None, name = None, modal = 1, fl = 0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self,parent)
        self.setModal(modal)
        qt4todo("handle flags in TextMessageBox.__init__")

        if name is None: name = "TextMessageBox"
        self.setObjectName(name)
        self.setWindowTitle(name)

        TextMessageLayout = QVBoxLayout(self)
        TextMessageLayout.setMargin(5)
        TextMessageLayout.setSpacing(1)

        self.text_edit = QTextEdit(self)

        TextMessageLayout.addWidget(self.text_edit)

        self.close_button = QPushButton(self)
        self.close_button.setText("Close")
        TextMessageLayout.addWidget(self.close_button)

        self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint()))
            # Width changed from 300 to 350. Now hscrollbar doesn't appear in
            # Help > Graphics Info textbox. mark 060322
        qt4todo('self.clearWState(Qt.WState_Polished)') # what is this?

        self.connect(self.close_button, SIGNAL("clicked()"),self.close)
开发者ID:foulowl,项目名称:nanoengineer,代码行数:28,代码来源:widget_helpers.py

示例14: PrefsViewerDialog

class PrefsViewerDialog(SizePersistedDialog):
    
    def __init__(self, gui, namespace):
        SizePersistedDialog.__init__(self, gui, 'Prefs Viewer dialog')
        self.setWindowTitle('Preferences for: '+namespace)

        self.db = gui.current_db
        self.namespace = namespace
        self._init_controls()
        self.resize_dialog()
        
        self._populate_settings()
        
        if self.keys_list.count():
            self.keys_list.setCurrentRow(0)
        
    def _init_controls(self):
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        
        ml = QHBoxLayout()
        layout.addLayout(ml, 1)
        
        self.keys_list = QListWidget(self)
        self.keys_list.setSelectionMode(QAbstractItemView.SingleSelection)
        self.keys_list.setFixedWidth(150)
        self.keys_list.setAlternatingRowColors(True)
        ml.addWidget(self.keys_list)
        self.value_text = QTextEdit(self)
        self.value_text.setTabStopWidth(24)
        self.value_text.setReadOnly(True)
        ml.addWidget(self.value_text, 1)
 
        button_box = QDialogButtonBox(QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.setCenterButtons(True)
        layout.addWidget(button_box)
        
    def _populate_settings(self):
        self.keys_list.clear()
        ns_prefix = 'namespaced:%s:'% self.namespace 
        keys = sorted([k[len(ns_prefix):] for k in self.db.prefs.iterkeys() 
                       if k.startswith(ns_prefix)])
        for key in keys:
            self.keys_list.addItem(key)
        self.keys_list.setMinimumWidth(self.keys_list.sizeHintForColumn(0)) 
        self.keys_list.currentRowChanged[int].connect(self._current_row_changed)

    def _current_row_changed(self, new_row):
        if new_row < 0:
            self.value_text.clear()
            return
        key = unicode(self.keys_list.currentItem().text())
        val = self.db.prefs.get_namespaced(self.namespace, key, '')
        self.value_text.setPlainText(self.db.prefs.to_raw(val))
        
开发者ID:john-peterson,项目名称:goodreads,代码行数:55,代码来源:common_utils.py

示例15: TextMessageBox

class TextMessageBox(QDialog):
    """
    The TextMessageBox class provides a modal dialog with a textedit widget
    and a close button.  It is used as an option to QMessageBox when displaying
    a large amount of text.  It also has the benefit of allowing the user to copy and
    paste the text from the textedit widget.

    Call the setText() method to insert text into the textedit widget.
    """
    def __init__(self, parent = None, name = None, modal = 1, fl = 0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self,parent)
        self.setModal(modal)
        qt4todo("handle flags in TextMessageBox.__init__")

        if name is None: name = "TextMessageBox"
        self.setObjectName(name)
        self.setWindowTitle(name)

        TextMessageLayout = QVBoxLayout(self)
        TextMessageLayout.setMargin(5)
        TextMessageLayout.setSpacing(1)

        self.text_edit = QTextEdit(self)

        TextMessageLayout.addWidget(self.text_edit)

        self.close_button = QPushButton(self)
        self.close_button.setText("Close")
        TextMessageLayout.addWidget(self.close_button)

        self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint()))
            # Width changed from 300 to 350. Now hscrollbar doesn't appear in
            # Help > Graphics Info textbox. mark 060322
        qt4todo('self.clearWState(Qt.WState_Polished)') # what is this?

        self.connect(self.close_button, SIGNAL("clicked()"),self.close)

    def setText(self, txt):
        """
        Sets the textedit's text to txt
        """
        self.text_edit.setPlainText(txt)

    pass
开发者ID:foulowl,项目名称:nanoengineer,代码行数:45,代码来源:widget_helpers.py


注:本文中的PyQt4.Qt.QTextEdit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。