pyside

Why is super used so much in PySide/PyQt?

♀尐吖头ヾ 提交于 2019-12-03 07:24:49
问题 Short version (tl;dr) I am learning PySide, and most online tutorials use super to initialize UI elements. Is this important (i.e., more scalable), or is it a matter of taste? Clarification : as I make more clear in the detailed version, this is not another generic thread asking when to use super (this has been done before). Rather, given the number of PySide tutorials that use super instead of <class>.__init__ , I am trying to figure out if using super is standard in PySide applications? If

How do I achieve consistent highlighting of QListWidget items across widget states?

[亡魂溺海] 提交于 2019-12-03 07:14:22
I am using PyQT 4.8.3 to create a dialog with two QListWidgets both allowing multiple selection. I find that if these QListWidgets are enabled, the selected items are highlighted in blue only when the QListWidget has focus, without focus the highlight is light-grey. I also find that if the QListWidgets are disabled, the selected items are highlighted in blue despite lack of focus. As the users go from one list to the other they will find this very confusing. As a developer I find the light-grey/unfocused, blue/disabled behaviours undesirable. I would appreciate any advice on modifying them. I

Are there default icons in PyQt/PySide?

孤街醉人 提交于 2019-12-03 06:43:28
问题 I'm reading a tutorial on PySide and I was thinking , do I need to find my own icons for every thing or is there some way to use some built in icons . That way I wouldn't need to find an entire new set of icons if I want my little gui to run on another desktop environment . 回答1: What you need is Pyside QIcon.fromTheme function. Basicaly it creates QIcon object with needed icon from current system theme. Usage: undoicon = QIcon.fromTheme("edit-undo") "edit undo" - name of the icon "type"/

How to signal slots in a GUI from a different process?

旧街凉风 提交于 2019-12-03 05:52:59
问题 Context: In Python a main thread spawns a 2nd process (using multiprocessing module) and then launches a GUI (using PyQt4). At this point the main thread blocks until the GUI is closed. The 2nd process is always processing and ideally should emit signal(s) to specific slot(s) in the GUI in an asynchronous manner. Question: Which approach/tools are available in Python and PyQt4 to achieve that and how? Preferably in a soft-interrupt manner rather than polling. Abstractly speaking, the solution

Communication between threads in PySide

微笑、不失礼 提交于 2019-12-03 05:06:51
问题 I have a thread which produces some data (a python list) and which shall be available for a widget that will read and display the data in the main thread. Actually, I'm using QMutex to provide access to the data, in this way: class Thread(QThread): def get_data(self): QMutexLock(self.mutex) return deepcopy(self.data) def set_data(self, data): QMutexLock(self.mutex) self.data = deepcopy(data) def run(self): self.mutex = QMutex() while True: self.data = slowly_produce_data() self.emit(SIGNAL(

Getting started with PySide [closed]

心不动则不痛 提交于 2019-12-03 04:35:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I decided to learn Python Gui development and, as PyQt is non-free, the choice was PySide for it. But, unlike PyQt, PySide doesn't have any tutorials or screencasts, just documentation useless for very beginners. I have no Qt experience, so even setting up development environment in Ubuntu is a problem. Could

How to crop a image and save?

巧了我就是萌 提交于 2019-12-03 04:07:10
I have opened a image in a QHBoxLayout . I need to crop the opened image and save the cropped image. How I can do this in PySide? import sys from PySide import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): hbox = QtGui.QHBoxLayout(self) pixmap = QtGui.QPixmap("re.png") lbl = QtGui.QLabel(self) lbl.setPixmap(pixmap) self.rect = QtCore.QRect() hbox.addWidget(lbl) self.setLayout(hbox) self.setGeometry(300, 300, 280, 170) self.setWindowTitle('Open Image') self.show() # Tried here to implement Qpen #self.painter =

Custom Qt Widgets with python for Qt Designer

巧了我就是萌 提交于 2019-12-03 04:04:11
I am trying to write a custom widget for the Qt Designer using only Python. I was following a couple of tutorials I found online but none of them were working or anything close to what I would call to be a minimum working example. So my questions are: What steps are involved to make a a custom widget appear in the Widget Box of Qt Designer? If you can spare the time: Please provide a minimum working example (like a widget with a label in it saying "A truly minimal working Qt custom widget example"). Or is it maybe not possible at all to include a custom widget using only python? swdev I found

Simple File browser / file chooser in Python program with Qt-GUI?

有些话、适合烂在心里 提交于 2019-12-03 03:39:05
I'm currently trying to implement some kind of file browser / "explorer" into a programme... I'm using Python and PySide in connection with the Qt-window-toolkit. More or less this youtube-video shows the behaviour I want to have at the end. However, this tutorial used C++ as programming language and I haven't been able yet to reason the right python code from the C++ example. Basically, my problem is to get the right column (file view) showing the content of the folder clicked in the left column (tree-style folder view). #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PySide

Make an animated wave with drawPolyline in PySide/PyQt

依然范特西╮ 提交于 2019-12-03 03:35:34
I'm trying to animate a polyline (it have to act like a wave). I've tried this way: from PySide.QtCore import * from PySide.QtGui import * import sys, time class Test(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) def poly(self, pts): return QPolygonF(map(lambda p: QPointF(*p), pts)) def paintEvent(self, event): painter = QPainter(self) pts = [[80, 490], [180, 0], [280, 0], [430, 0], [580, 0], [680, 0], [780, 0]] for i in pts: while i[1] < 600: painter.setPen(QPen(QColor(Qt.darkGreen), 3)) painter.drawPolyline(self.poly(pts)) painter.setBrush(QBrush(QColor