pyside

Why does PySide implicitely create object members from class members for Signals?

与世无争的帅哥 提交于 2019-11-26 23:37:22
问题 On the PySide signals and slots page it says: "Signals are runtime objects owned by instances, they are not class attributes". Apparently the QObject constructor looks in the class attributes for Signals and copies them to the object instance. This is confirmed by my test program. from PySide import QtCore class Klass(QtCore.QObject): lst = [] sig = QtCore.Signal(str) def main(): obj1 = Klass() obj2 = Klass() print "id: obj1.lst = {}, obj1.sig = {}".format(id(obj1.lst), id(obj1.sig)) print

How QApplication() and QWidget() objects are connected in PySide/PyQt?

ε祈祈猫儿з 提交于 2019-11-26 23:35:10
问题 How QApplication() and QWidget() are connected? This is an example code that I copied, it creates QApplication object and QWidget object, but there is no link between the two objects. I expected something like app.setWidget(did) to teach PySide/PyQt controller about the widget that was created. # http://zetcode.com/gui/pysidetutorial/firstprograms/ # 1. PySide.QtGui is the class import sys from PySide import QtGui # 2. setup the application app = QtGui.QApplication(sys.argv) # 3. create the

How to print a QTableView [closed]

女生的网名这么多〃 提交于 2019-11-26 23:32:12
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have a Python and PySide app that connects to a mysql database and displays the results of a query in a QTableView. I need to print the contents of the table view. Here's some code: self.db_table = QtGui

How to change text alignment in QTabWidget?

天涯浪子 提交于 2019-11-26 17:45:47
问题 I cannot find a way to set the text alignment in a QTabWidget. After I've created an instance of this widget, I've set its tabPosition property to West, but I wish it showed text/label horizontally. I've given a look to the Qt's stylesheets, but as you can see, the text-align property can only be set on QPushButton and QProgressBar. I already searched on the web, but I just found a bugreport, a non-answered question, and finally a user that suggests to re-implement the paint() method. Maybe I

simple IPython example raises exception on sys.exit()

孤街醉人 提交于 2019-11-26 16:36:19
问题 I'm doing some very simple PySide (and PyQt) tutorials in IPython. One tutorial just creates a window with some sliders to demonstrate slots and signals. When I close the window of the running demo application, I see this error: An exception has occurred, use %tb to see the full traceback. SystemExit: 0 To exit: use 'exit', 'quit', or Ctrl-D. So I run %tb and get this: SystemExit Traceback (most recent call last) /Workspaces/scratch/<ipython-input-1-88966dcfb499> in <module>() 33 34 if __name

PySide / PyQt detect if user trying to close window

断了今生、忘了曾经 提交于 2019-11-26 16:34:10
问题 is there a way to detect if user trying to close window? For example, in Tkinter we can do something like this: def exit_dialog(): #do stuff pass root = Tk() root.protocol("WM_DELETE_WINDOW", exit_dialog) root.mainloop() Thanks. 回答1: Override the closeEvent method of QWidget in your main window. For example: class MainWindow(QWidget): # or QMainWindow ... def closeEvent(self, event): # do stuff if can_exit: event.accept() # let the window close else: event.ignore() Another possibility is to

Python code generation with pyside-uic

偶尔善良 提交于 2019-11-26 14:07:48
问题 How can I generate python code from a QtDesigner file ? I found pyside-uic but I can't find an example for the syntax. I run win7 and pythonxy with spyder. 回答1: pyside-uic is more or less identical to pyuic4, as such the man page specifies: Usage: pyside-uic [options] <ui-file> Options: --version show program's version number and exit -h,--help show this help message and exit -oFILE,--output=FILE write generated code to FILE instead of stdout -x,--execute generate extra code to test and

QWidget does not draw background color

自古美人都是妖i 提交于 2019-11-26 11:31:07
问题 I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here

Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?

心已入冬 提交于 2019-11-26 08:47:07
问题 I\'m using Virtualenv with profit on my development environment with web.py , simplejson and other web oriented packages. I\'m going to develop a simple python client using Qt to reuse some Api developed with web.py. Does anybody here had succesfully installed PyQt4 with Virtualenv? Is it possible? I\'ve downloaded all the binaries and have PyQt4 installed globally on my python2.6 directory. If I don\'t use --no-site--packages option, Virtualenv correctly includes PyQt4 in my new sandbox but,