web.safeunicode

Here are the examples of the python api web.safeunicode taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: Qt-Python-Binding-Examples Source File: get_input_dialog.py
Function: get_input
    def _get_input(self):
        title, msg = 'Get Input Dialog', 'Enter your name:'
        text, resp = QtGui.QInputDialog.getText(self, title, msg)
        
        if resp:
            self.label.setText(web.safeunicode(text))

Example 2

Project: Qt-Python-Binding-Examples Source File: label.py
Function: init
    def __init__(self):
        super(Demo, self).__init__()

        x, y, w, h = 500, 200, 300, 400
        self.setGeometry(x, y, w, h)

        # support basic rich text
        text1 = "Hello, <a href='http://www.pyside.org/'>PySide</a>"
        label1 = QtGui.QLabel(text1, self)
        x, y = 20, 20
        label1.move(x, y)
        label1.linkActivated.connect(self._label1_linkActivated)
        label1.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
    

        label2 = QtGui.QLabel(self)
        x, y = 20, 55
        label2.move(x, y)
        text2 = u'\u4e2d\u6587'
        label2.setText(text2)
        label2.setFrameStyle(QtGui.QFrame.Panel)

        print label1.text(), type(label1.text()), label1.text() == text1
        print label2.text(), type(label2.text()), label2.text() == web.safeunicode(text2)

Example 3

Project: Qt-Python-Binding-Examples Source File: markdown_editor.py
    def __init__(self):
        super(Foo, self).__init__()

        x, y, w, h = 100, 100, 900, 600
        self.setGeometry(x, y, w, h)
        

        self.source = QtGui.QTextEdit(self)
#        self.preview = QtWebKit.QWebView(self)
        self.preview = QtGui.QTextEdit(self)
        self.preview.setReadOnly(True)
        self.preview.setFrameShape(QtGui.QFrame.NoFrame)

        qd = QtGui.QTextDocuement()
        qd.setDefaultStyleSheet(DEFAULT_STYLE)

        self.preview.setDocuement(qd)

        self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
        self.splitter.addWidget(self.source)
        self.splitter.addWidget(self.preview)


#        widget = self.splitter.widget(0)
#        policy = widget.sizePolicy()
#        policy.setHorizontalStretch(1)
#        policy.setVerticalStretch(1)
#        widget.setSizePolicy(policy)

        self.hbox = QtGui.QHBoxLayout(self)
        self.hbox.setContentsMargins(0, 0, 0, 0)
        self.hbox.setSpacing(0)
        self.hbox.addWidget(self.splitter)
        self.setLayout(self.hbox)

        
        self.font = QtGui.QFont("Monaco", 12)
        self.setFont(self.font)


        self.source.textChanged.connect(self.source_text_changed)
        
        self.source.setText(web.safeunicode(buf))