pyside

pyside - how to delete widgets from gridLayout

别说谁变了你拦得住时间么 提交于 2019-12-02 01:39:40
I built a ui in QT Designer and then used pyside-uic turned it into a python file and have then written some code to edit it programmatically. In otherwords I have a pushbutton Add Row that when clicked will rename itself to Remove1 and create another pusbutton name it Add Row and add it to the layout. Code when clicking Add Row , changes the name and the signals/slots: self.pb_Row[-1].setText('Remove'+str(self.nRows)) self.pb_Row[-1].clicked.disconnect( self.addRow ) self.pb_Row[-1].clicked.connect( self.removeRow ) Code when clicking Remove , removes selected button: iRow = int(self.sender()

PyQt listview with html rich text delegate moves text bit out of place(pic and code included)

▼魔方 西西 提交于 2019-12-02 01:26:00
Got a listview where items need to make use of bold text, so a html delegate is the way to go. I looked around and found several solutions and out of them I made this code, but it has the issue that you can see in the gif, which shows the results with the use of the delegate and without. from PyQt4.QtCore import * from PyQt4.QtGui import * import sys class HTMLDelegate(QStyledItemDelegate): def __init__(self, parent=None): super(HTMLDelegate, self).__init__(parent) self.doc = QTextDocument(self) def paint(self, painter, option, index): painter.save() options = QStyleOptionViewItemV4(option)

Pyside install fails (Python 2.7.4)

纵然是瞬间 提交于 2019-12-02 01:04:56
I just upgraded to Ubuntu 13.04 (beta) and I'm getting an error when trying to install pyside into a Virtualenv (python 2.7.4) using pip: error: Failed to locate the Python library /usr/lib/libpython2.7.so.1 Anyone have any ideas? I've tried previous versions as well as the dev version, still no luck. EDIT: Console Log for post_install (monster)tony@tonyubuntu:~/Downloads/pyside-setup$ python pyside_postinstall.py -install PySide package found in /home/tony/Downloads/pyside-setup/PySide... Patched rpath in /home/tony/Downloads/pyside-setup/PySide/QtUiTools.so to /home/tony/Downloads/pyside

pythonGUI -- pyside安装与初试

元气小坏坏 提交于 2019-12-02 00:49:11
(一)说在前面 Python自带了GUI模块Tkinter,只是界面风格有些老旧。另外就是各种GUI框架了。 之前安装过WxPython,并做了简单的界面。遂最近又重新搜索了一下网上关于Python GUI框架的问题,发现还是Qt呀。 Python的Qt有PyQt和PySide吧。PyQt 是商业及 GPL 的版权, 而 PySide 是 LGPL。大意也就是PyQt开发商业软件是要购买授权的,而PySide则不需要。二者代码基本一致,修改下import 基本剩余的代码皆可通用。所以毫不犹豫的选择了PySide。 接下来的这段时间,将会一边学习Pyside,一边学习Django更深层次的东西。如果还有时间,就再熟悉一下Python基础的一些东西。 (二)PySide的安装 (1)官网教程略显麻烦。 官网: http://qt-project.org/wiki/PySide (2)比较快捷省事的安装 dizzy@dizzy-pc:~$ sudo add-apt-repository ppa:pyside You are about to add the following PPA to your system: Official Ubuntu packages for PySide Qt Bindings. dizzy@dizzy-pc:~$ sudo apt-get update

migrating from Inherited QThread to Worker model

Deadly 提交于 2019-12-02 00:30:58
So through a lot of help in my previous questions ( Interrupting QThread sleep and PySide passing signals from QThread to a slot in another QThread ) I decided to attempt to change from the inherited QThread model to the Worker model. I am thinking I should stay with the QThread model as I had that working, and the other model is not. However I am not sure why the Worker model isn't working for me. I am attempting to do this please let me know if there is something inherently wrong in my methodology? I have a QtGui.QWidget that is my main GUI. I am using a QPushButton to signal I have

PySide/PyQt: Is it possible to make strings that you attach to the QTextBrowser separate clickable units

元气小坏坏 提交于 2019-12-02 00:19:05
This might be a silly question but: When you append a given string to a QTextBrowser object, can you make it a link to a signal to a function that takes its text and does something with it? All I need is for it to save the text to a variable actually. As in, can a link lead to a function instead of to a website. It certainly is possible. Here is a code example: import sys from PyQt4 import QtGui from PyQt4 import QtCore class MainWindow(QtGui.QWidget): def __init__(self): super(MainWindow, self).__init__() main_layout = QtGui.QVBoxLayout() self.browser = QtGui.QTextBrowser() self.browser

Semi-transparent highlights using PySide and QTextEdit

烂漫一生 提交于 2019-12-01 23:36:06
I've created a QTextEdit object. The code below adds randomly colored highlights to the currently selected text. I need the highlights to be semi-transparent so I can see highlights layered upon each other. Using "setAlpha" does not appear to do anything. How can I set the alpha for the highlight or otherwise obtain semi-transparency? # Define cursor & span self.cursor = self.textdoc.textCursor() self.selstart = self.cursor.selectionStart() self.selend = self.cursor.selectionEnd() self.seltext = self.cursor.selectedText() # Create random color r = randint(0,255) g = randint(0, 255) b = randint

How to vertically center a single-line in a QTextEdit instance (PySide/PyQt)?

痴心易碎 提交于 2019-12-01 22:31:08
问题 I have a line editor that inherits from QTextEdit , and I am using it to edit view items that show rich text. The second parameter for QTextEdit.setAlignment is `QtAligntment' and the docs say: Valid alignments are Qt.AlignLeft, Qt.AlignRight, Qt.AlignJustify and Qt.AlignCenter (which centers horizontally). That is, there is no native support for vertical alignment. Is there an indirect way to vertically center the text in QTextEdit ? Related link Center the Text of QTextEdit horizontally and

How do I load children from .ui file in PySide?

。_饼干妹妹 提交于 2019-12-01 21:59:42
For now I'm loading them like this: if __name__ == '__main__': app = QApplication(sys.argv) loader = QUiLoader() file = QFile('main.ui') file.open(QFile.ReadOnly) window = loader.load(file) file.close() window.show() # Here: window.centralwidget.findChild(QListWidget, 'listWidget').addItems(['Item {0}'.format(x) for x in range(100)]) sys.exit(app.exec_()) But I think it's uncomfortably, is there any other way, probably to load whole namespace or whatever? At the moment, the PySide QUiLoader class doesn't have a convenient way to load widgets into to an instance of the top-level class like the

How to vertically center a single-line in a QTextEdit instance (PySide/PyQt)?

冷暖自知 提交于 2019-12-01 21:01:25
I have a line editor that inherits from QTextEdit , and I am using it to edit view items that show rich text. The second parameter for QTextEdit.setAlignment is `QtAligntment' and the docs say: Valid alignments are Qt.AlignLeft, Qt.AlignRight, Qt.AlignJustify and Qt.AlignCenter (which centers horizontally). That is, there is no native support for vertical alignment. Is there an indirect way to vertically center the text in QTextEdit ? Related link Center the Text of QTextEdit horizontally and vertically : Unfortunately, the accepted answer uses QLineEdit which won't work for me. A clue? At the