Das deutsche Python-Forum

python,pythonx,pyqt,pyqt4 I think the problem is with your 866866.pw file. You have a function refreshgui which re imports 866866.pw import will run every part of the code in the file.

This is useful whenever you need to give the user the option of neither checking nor unchecking a checkbox. If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items.


The QComboBox widget is a combined button and popup list. A QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space. A combobox is a selection widget that displays the current item, and can pop up a list of selectable items.

The most flexible way is to use a QListView, which provides a UI view on a highly-flexible list model which must be defined by the programmer; a simpler way is to use a QListWidget, which has a pre-defined item-based model that allows it to handle common use-cases for a list box.

We'll start with the simpler QListWidget. The constructor of a QListWidget is like that of many QWidget-descended objects, and takes only an optional parent argument:. You can also add slightly more complicated list items using the QListWidgetItem class. A QListWidgetItem can be created in isolation and added to a list later using the list's addItem method:. Or it can be created with the list as a parent, in which case it is automatically added to the list:.

You can also specify the text or an icon and text in the QListWidgetItem 's constructor:. The QListWidget offers several convenient signals that you can use to respond to user input. The most important is the currentItemChanged signal, which is emitted when the user changes the selected item; its slots receive two arguments, current and previous , which are the currently and previously selected QListWidgetItems.

There are also signals for when a user clicks , double-clicks , activates , or presses an item, and when the set of selected items is changed. To get the currently selected item, you can either use the arguments passed by the currentItemChanged signal or you can use the QListWidget's currentItem method. One of the few ways you can customize a QListWidgetItem is by adding an icon , so it is important that you gain some understanding of QIcons. There are many ways of constructing a QIcon ; you can create them by:.

A couple comments on the different methods: On my system, it returns:. As I said, a pretty wide selection. Theme-based icon creation is problematic outside of well-established platforms; on Windows and OS X you should be fine, as well as if you're on Linux using Gnome or KDE, but if you use a less common desktop environment, such as OpenBox or XFCE, Qt might not be able to find your icons; there are ways around that, but no good ones, so you may be stuck with text only.

Let's create a simple list widget that displays the file-name and a thumbnail icon for all the images in a directory. First off, we'll need to know what image formats are supported by your installation, so our list control can tell what's a valid image. We can use the method mentioned above, QImageReader. We'll convert them all to strings before we return them:. Now that we have that, we can build our image-list widget; we'll call it - intuitively enough - ImageFileWidget.

It will inherit from QListWidget , and in addition to an optional parent argument, like all QWidgets , it will take a required dirpath:. We'll want it to have a way to determine what images are in a given directory.

It'll employ the glob module's glob function, which does shell-style pattern-matching of file and directory paths:. Now that we have a way of figuring out what image files are in the directory, it's a simple matter to add them to our QListWidget. For each file-name, we create a QListWidgetItem with the list as its parent, set its text to the file-name, and set its icon to a QIcon created from the file:. Finally, we'll add a method to set the directory path that repopulates the list every time it is called:.

So let's put our ImageFileList in a simple window so we can see it in action. We'll create a QWidget to serve as our window, stick a QVBoxLayout in it, and add the ImageFileList , along with an entry widget that will display the currently selected item. We'll create a QApplication object, passing it an empty list so we can use sys.

Then, we'll instantiate an ImageFileList , passing in the received image directory path and our window as its parent:. Then, we need to create a slot function to be called when the current item is changed; it has to take arguments, curr and prev , the currently and previously selected items, and should set the entry's text to the text of the current item:. You should subclass QAbstractTableModel to use this list. Here's my code snippet for this: To update the widget, you should repaint it, but calling repaint directly is not very good, so try: This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop.

This permits Qt to optimize The problem is because you are adding self. The first time you add the QLabel, it gets added before the LineEdit and when you add it second time, it Basically, my test shows that: You can just subclass the QCheckBox class. I would use TryCast to get the job done. I specifically did not reduce this expression ' to emphasize the need to check for 'Nothing' ' and I'd propose a solution, based on ICollectionView filtering.

In Datatrigger you are binding enum values as oridinary string. I don't think you can or should want to do this with lambda. See the answer to the possible duplicate that I reference under your question for what you can do.

One way to do something similar would be to simply define a single function which takes two arguments. I understand that the characters used for the thousands separator and the decimal mark may differ between locales, but surely no locale could sensibly interpret 5.

Given that, it's hardly surprising that Qt wants to treat it as ordinary text. But anyway, the docs for QTableItem suggest Due to the GIL global interpretter lock only one Python instance can execute at once. How Python chooses to share time between threads depends a bit on the version of Python but it's substantially based on how many Python bytecodes have been executed see https: I'd guess that since Cython For a dict, this means a QMap - but only if all the keys are strings.

Otherwise, it just wraps a reference to the original dict i. For a list, the conversion Try using a DataTrigger with predefined DataTemplate items: I haven't tried this but your data In it I added a combo box, editing "Edit Items" it and adding a few fruits in there, of course without forgetting the random numbers after the colon.

This I assume is a fair recreation of your ComboBox Items contains objects, which are pretty dumb. The first thing you should do is to create a class, maybe like this: This appears to have been solved in the questions that I linked. For reference, the solution appears to be as follows: All the methods Screenshot inherits from QPixmap will return a QPixmap, so you need to explicitly create and return an instance of Screenshot instead.

The only real issue is to avoid inefficient copying. However, QPixmap provides a very fast copy-constructor for doing just that, so all you need is something This is happening because py2app would not be able to find files specified through string paths in the code.

It will not include those files in the binary. You can do one of two things to solve your problem. Maybe something like this. You need to convert the pixmap returned by QMovie. Disclaimer, only tested on Linux. Try using string insted of ComboboxItem: Write your own style to highlight border and add as resource in FocusVisualStyle of Combobox. No, this seems quite legit. You don't have to worry as this is the way all things get loaded in WinForms This will block the UI thread for a short amount of time, but since your not going to load huge masses of something, you won't even notice it.

The model will be updated when the radio-button option changes, but only if return or enter is pressed. The reason for this, is that the data-mapper uses an item-delegate to notify changes to the model, and this item-delegate installs an event-filter on every widget that is mapped. Title property of combobox to either with space or text of your choice. So it would be like: The main problem is that you are linking against Qt4 rather than Qt5. This is why the QAbstractScrollArea and QPrinter headers are reported as missing, and why you later get the undefined symbol error.

QScintilla uses a features file to control compile-time configuration, and its sources need to be patched You have to add row in table this way: Add newRow ; and then give source to combo: No, it is the primary key of the Person object in the database. So you can get it via Person. But really you should be using a Django form, which will then give you the Person object via form.

Also note, for clarity, this is a select field, or a Your problem is that you should be defining item inside your for loop, as you're currently adding the same item to your ComboBox once for each result in your query, while also updating the item's text and value to match the current query result. At the end of the loop, You can remove the close button of the tabs that should not be closed. RightSide,None Here, we set the button of the first tab to be None. With the same function, you could also create your own If you see the Tag is setting for the combo box itself and not for its individual item.

You can build a dictionary and use it as datasource of your combo box. Specify the value and display members of the combo box with dictionary key and value attributes Try modifying You are trying to bind to a private variable, instead, your enum should be exposed as a Property.

Don't use global variables. Use class variables instead.