FAQ Database Discussion Community


remove padding/margin from QTabBar in QLayout

python,qt,pyqt4,pyqt5,qss
I have an application where I want the QTabBar to be in a separate VBoxLayout from the QTabWidget area. It sort of works using the code below but I'm having styling problems. Before I separated the QTabBar from the QTabWidget I didn't have any problems but now I can't figure...

PyQt: translate module strings at runtime

qt4,pyqt4,translation
Strings in a QObjects translated at runtime. AFAIU, if the translator is changed, all strings are refreshed. However, strings declared at module level or even static class attributes, are translated at import time. I can see 3 ways of allowing module strings to be translated, none of which seems totally...

updating a value every n seconds

python,multithreading,timer,pyqt4,self-updating
I'm creating a real-time application(on a Raspberry Pi) in Python and I have a problem concerning "Updating a value in the program every 5 seconds". I'm using Python 2.7.9 as interpreter and for the GUI programming: PyQt4. I must do a request to a measuring instrument and I get One...

Is using PyQT's QProgressbar in combination with generators efficient?

python,python-2.7,pyqt4,generator
I'm trying to use the QProgressBar to update itself to show the progress of lengthy operations. My code is: #yield trials import sys from PyQt4.QtGui import QDialog, QProgressBar, QPushButton, \ QLabel, QApplication, QVBoxLayout def someprocess(): bignumber = 1000000 for i in range((bignumber+1)): if float(i)/bignumber in [float(count)/10 for count in range(11)]:...

How can I pass data in run method (thread) (python, Pyqt)

python,multithreading,pyqt4
I want to make the thread, in the window, using PyQt(Python). For example class window(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.setGeometry(100, 100, 500, 200) self.setWindowTitle('Hello') self.label = QtGui.QLabel(u'WoRLd', self) self.Layout = QtGui.QVBoxLayout() self.Layout.addWidget(self.label) self.setLayout(self.Layout) self.introduced = 123 self.request = Requests() self.request.start() self.connect(self.request, QtCore.SIGNAL("mysignal(QString)"), self.on_change,...

Printing console message when QPushButton is pressed

python,pyqt4,qpushbutton
I am new to Python and I want to do a simple code to print a message in the Python console when a QPushButton is pressed. I split the code in 2 .py files (one for UI and the other for the main application). Although it supposed to be very...

QTabWidget. How to move one tab to right position?

python,qt,tabs,pyqt4,qtabwidget
Standard layout tabs from left to right. All tabs are nearby. How to change the position of the one tab, so that it was attached to the right edge? Like This: Is it possible to do?...

Drag n Drop Button and Drop-down menu PyQt/Qt designer

qt,python-2.7,pyqt,pyqt4,qt-designer
I would like to know the "best practice" to change the behavior of some buttons to do the following: I want with a click to appear a menu. Or when you drag this same button you could drop it in another and this will "draw" a line connecting them. Here...

why some signals are bound and other unbound?

python,pyqt,pyqt4
I am starting with PyQt and was looking at grouping the signals in a dict (I will have several / many of them and I wanted to initialize them in a loop as opposed to doing this line by line). I noticed however that the dict values are unbound, while...

PyQT4 Datetime widget

python,pyqt,pyqt4
I'm using PyQt4 to make a Application and on the window their is a datetime-label( live updating). I Wan't to put this label into a Hboxlayout, together with two other QLabels. This code is used: import sys,os from PyQt4 import QtGui,QtCore from label_datetime import * class ApplicationWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self)...

CentOS: QtWebKit is missing and Anki won't start

python,qt,webkit,centos,pyqt4
I'm trying to run anki on CentOS and get the following error: Traceback (most recent call last): File "/usr/bin/anki", line 5, in <module> import aqt File "/usr/share/anki/aqt/__init__.py", line 5, in <module> from aqt.qt import * File "/usr/share/anki/aqt/qt.py", line 13, in <module> from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings ImportError: No module...

Casting a QObject subclass instance

python,pyqt,pyqt4
I have a QPixmap subclass with additional class method make: class Screenshot(QtGui.QPixmap): @classmethod def make(cls): desktop_widget = QtGui.QApplication.desktop() image = cls.grabWindow( desktop_widget.winId(), rect.x(), rect.y(), rect.width(), rect.height()) import ipdb; ipdb.set_trace() image.save() return image When I call Screenshot.make() the correct class cls is passed, but the instance created via cls.grabWindow is not...

How do I schedule my desktop application(PyQt) to send emails at some intervals

python-2.7,pyqt4,schedule
So, I have built this nice application(using camelot) and do not know how to implement a scheduled job on it, that can send emails based on some conditions at regular intervals. I am trying to implement it using schedule but don't know how to make my app call it automatically....

Can I embed plotly graphs (offline) in my PyQt4 application?

python,pyqt4,plotly
I know that plotly renders into HTML and can be embedded in web-like environments. I wonder if one can do that inside an HTML window in a PyQt application? Specifically I'd like to know if that works offline, having no internet connection. EDIT: This is an excerpt how I finally...

PyQt4 QComboBox autocomplete without using setModel?

autocomplete,pyqt4,qcombobox
I have found several excellent examples of a PyQt4 QComboBox with autocomplete (e.g. How do I Filter the PyQt QCombobox Items based on the text input?), but they all use setModel and setSourceModel... etc. Is it possible to create an autocomplete QComboBox in PyQt4 without using a model?...

How to update QListWidget

pyqt4,qlistwidget
How to update QLIstWidget to show items as when when it is added. Like i am adding 100 QListWidgetItems to QListWidget in a loop. All these 100 items are visible only after loop is completed. But i want to know if is it possible to show item as and when...

AttributeError: 'QSlider' object has no attribute 'subtractStep'

python-2.7,pyqt4
I am getting an error when I try to run this code: # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'scaler_gui_3.ui' # # Created: Thu May 14 13:05:28 2015 # by: PyQt4 UI code generator 4.11.3 # # WARNING! All changes made in this file...

Issue with my Check Box in PyQt and Python

python,checkbox,pyqt4
I have a checkbox named "selectAllCheckBox". When this in checked state, all the checkboxes(created dynamically) inside the listview should change to checked state and when "selectAllCheckBox" checkbox is in Unchecked state, all the dynamically created checkboxes should change to unchecked state. self.dlg.selectAllCheckBox.stateChanged.connect(self.selectAll) def selectAll(self): """Select All layers loaded inside the...

How to center an icon in QStandardItemModel?

qt,pyqt4,pyqt5
def data(self, index, role): if role == Qt.DecorationRole: if index.column() == 0: return QApplication.style().standardIcon(QStyle.SP_DialogYesButton if self.item(index.row()).valid else QStyle.SP_DialogNoButton) elif role == Qt.TextAlignmentRole: if index.column() == 0: return QVariant(Qt.AlignCenter | Qt.AlignVCenter) The icons are displayed well but they are not centered....

QGraphicsScene on a QMainWindow

python,user-interface,pyqt4,qgraphicsscene
Still new to Python so I'm trying to get a QGraphicsScene to be inside a a QMainWindow. Right now the way I have it coded is that two windows will appear but I only want one window to appear with the QGraphicsScene "inside" the QMainWindow. Here is my code: import...

The event loop is already running

python,python-3.x,pyqt,pyqt4
I have the following 5 files: gui.py # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig)...

pyqt4 drag and drop files in Qlistview

python,python-2.7,drag-and-drop,pyqt4
i can not find drag and drop the files in qlistview. i find sample code. but this is qlistwidget and qpushbutton also this sample is using class i want to make drag and drop below example. Why can not use the dropped in qlistview? main.py from PyQt4 import QtCore, QtGui...

Packaged python .app file crashing, but packaged python .sh file working fine

python,osx,pyqt4,cx-freeze
I've produced an app using Python 3.4.3, Pyqt4 and some other extras (Poppler being among them) on OS X Yosemite. I'm using cx_freeze to produce a working .app file and eventually, a working msi file. I've been testing the app works properly after building it using the build command as...

Iterating all items inside QListView using python

python,pyqt4,qt-designer
I have a QlistView inside is which a checkboxes (created dynamically) with item name (QstandardItem). And below Qlistview is a checkbox named DatacheckercheckBox1. What I want is when this DatacheckercheckBox1 checkbox statechanges to "Checked", all the checkboxes inside the QlistView should be checked. I have made a signal for DatacheckercheckBox1...

Pycharm PyQt4 Autocomplete Not Working for Virtualenv

python,autocomplete,pyqt4,pycharm
For the past couple of days I've tried to get Pycharm autocomplete working for PyQt4 when running a virtualenv on Ubuntu 14.04. The code works perfectly fine, it's just that all the imports are marked as red and I get zero autocomplete when writing code. So far I've tried: copying...

how to auto resize in pyqt4 python?

python,python-2.7,pyqt4
I want to auto resize the above picture at the size shown below when user resize the main window. Is there any function to do this in pyqt4? I was searching for an answer to this problem... but i can't find something related. I've tried to set fixed minimum...

Passing updated parameters to the function via connected button in PyQt

python,python-2.7,matplotlib,plot,pyqt4
I am learning Python and PyQt at the moment. I'm having a problem understanding something. My program calculates the solusion of Newton's Cooling Law using Euler's Method. For now all the parameters are constant but user will be able to change them later. I would like to make it this...

Combining PyQt and Matplotlib

python,python-2.7,matplotlib,pyqt4
I want to combine my Ui generated by QtDesigner. I want to merge it with myplotlib so that everything is in one window. When i run the following code i get an error: "QWidget::setLayout: Attempting to set QLayout "" on Ui_MainWindow "", which already has a layout I know that...

PyQt Enable/Disable elements in a QComboBox

python,python-3.x,pyqt,pyqt4,qcombobox
I have a QComboBox that list all Windows' drive letters and let the user choose among them. During the execution, we need to enable or disable some of the letters (without removing them). Here is the basic code : all_letters = ["{}:".format(chr(i)) for i in range(90, 64, -1)] # Z:...

pyqt - Automatically update widget on user input

python-2.7,pyqt,pyqt4
Total pyqt novice here. Trying to automatically modify the widget to display different options when user selects certain option in combobox 2. IE if user selects 'Cliff Erosion' or 'Dune Erosion', I want the widget to refresh with additional comboboxes. Likewise, if they select back to 'Rising Tides' or 'Coastal...

PyQt4 unable to call function of main Gui class from QThread class

python,pyqt4,qthread
Following is the sample code structure I am intending to implementing a larger time consuming operation. For doing larger operation, I have used QThread and updating progressbar (from main class) using the emited signal. All works fine un till large time consuming operation is completed. However, I run in to...

Using the directory path returned from QTFile Dialogue in Python Code

python,pyqt4
I am returning the directory path from QTFile Dialogue in Pyqt: dname = QtGui.QFileDialog.getExistingDirectory(self, 'Open file', '/home') The path i get back is this: C:\cygwin64\home\My_workspace\HFATool\raw_files I want to use this path in the python code but it gives error that one slash is being read as C:\\cygwin64\\home\\My_workspace\\HFATool\\raw_files. How do I...

How to switch between two windows in python using PyQt

python,python-2.7,pyqt,pyqt4
I am working on some app. I wanted to create a toolbar that after having been clicked will open Settings window. However I don't know how to do it exactly. The way it is now is that i have a Toolbar icon connected to ShowSettings function. This function creates a...

how can i stop module in python?

python,python-2.7,pyqt4,exit
I have a simple code. start button press -> infinite loop and application clear stop button press -> infinite loop is stop by control c event but I want to stop test2.py using other way not control c event. because I made .exe file using pyinstaller by no console. so...

Statusbar doesn't show message immediately and sometimes crash

python,multithreading,pyqt4
I created an interface in pyqt4 designer, there is only a button and a status bar. I want to show a message in the status bar when I click the button. For some reason I have to put this action in a new thread. But when I click the button,...

PyQt4 setParent vs deleteLater

pyqt,pyqt4
I have a layout that I add a lot of custom widgets to with something like layout.addWidget(widget). Later I want to remove all those custom widgets and add new ones. I'm confused on the best way to do this when it comes to deleteLater and setParent(None). For example, here's my...

What's the difference between @pyqtSignature() and @pyqtSlot() pyqt decorators

python,qt,pyqt,pyqt4
I was trying to write a slot that connects to different pyqt signals. What I still can't wrap my head around is the difference between the two decorators @pyqtSignature() and @pyqtSlot(). Example to connect to pyqt clicked signal of QPushButton which is inherited from QAbstractButton, I used the following syntax...

(PyQt and PySide) QFileDialog.getExistingDirectory doesn't work on Windows

python,pyqt4,pyside
This code works perfectly fine on mac, after clicking on the button, the dir dialog show up. On Windows, it freezes after the button clicks (refer to the picture). Here is my code: import os import sys from Pyside import QtGui class OpenDir(QtGui.QWidget): def __init__(self): super(OpenDir, self).__init__() self.initUI() def initUI(self):...

How use PyQt without GUI?

python,pyqt,pyqt4
I want create python server application using PyQt4 without GUI ( signal/slots, threads, process and other core patterns ). How i can create this?

How to change the characters used for QTextOption.ShowTabsAndSpaces?

python,qt,python-3.x,pyqt4
Is there a way to change which character is used for QT's QTextOption.ShowTabsAndSpaces flag? I find that the default character that's used for viewing whitespace (specifically spaces) stands out a little too much. I'd like to change the font or character used so that it's less distinct. It looks like...

Adding HTML to .setText() crashes the script

python,multithreading,pyqt,pyqt4
I have a simple program which displays QLabels and updates them with data retrieved elsewhere. Up to now I was using plain text for the update but would like to use HTML. Specifically the following line (taken out of context) updates a QLabel: self.root.calendar_today.setText(r['calendar']['today']) With some text. It works fine....

Why am I getting a QWidget error?

python,graphics,drawing,pyqt4
I have recently found this person's code that I could possibly be able to use for my project but I'm still pretty new to Python so I'm having a really rough time understanding the code and the error that keeps occurring even though the code is exactly the same as...

How can I plot real time signal in pyqt

pyqt,pyqt4
I want to plot real time signal using pyqt. Can any one tell me how can I do it? What is the procedure I need to follow for real time signal plotting? Any suggestion with basic examples is most appreciable.

How can I have an animated system tray icon in PyQt4?

python,qt,pyqt,pyqt4,system-tray
I am trying to create an animated systray icon for a pyqt4 app but am having trouble finding any examples in python. This is the closest I can find but it's in C++ and I don't know how to translate it over: Is there a way to have (animated)GIF image...

Detect being hovering over specific widgets in PyQt4

python,pyqt4
So currently in my GUI, I have many fields that need some explanation of what they do. I was wondering if there was a way to have a small window or secion popup if the user hovers the mouse over a certain kind of widget? So I have this code:...

matplotlib gui imshow coordinates

python,matplotlib,pyqt4,imshow
I'm making a GUI using pyqt4 which contains an image displayed by matplotlib's imshow using a 2d array. If I displayed this with pyplot, the window would show the x, y coordinates of the cursor if I move the mouse over the image. However, this seems to have disappeared when...

Error with thread in pyqt4

python,multithreading,pyqt,pyqt4
I have the problem. I made the thread and from there I want to open the new window. But it does not work. import sys from grab import Grab from PyQt4 import QtGui, QtCore class Requests(QtCore.QThread): def __init__(self, parent=None): QtCore.QThread.__init__(self, parent) def run(self): # here some comands self.emit(QtCore.SIGNAL("mysignal(QString)"), 'open') class...

PyQt QVBoxLayout and missing widgets?

python,pyqt4
I am trying to set up a window that has a text input & a combo box. At the moment I just want to see the text & the selection displayed under the appropriate widget. I have used QVBoxLayout() as I will be adding more stuff later & thought it...

PyQt4: Non-ASCII character detected in trUtf8 string

python-2.7,utf-8,qt4,pyqt4
I'm trying to figure out how to feed the PyQt tr() or trUtf8() functions UTF-8 text. Here are examples strings: self.tr('λληνικά') self.tr(u'εληνικά') self.tr('ελνικά'.encode('utf-8')) self.tr(u'ελληικά'.encode('utf-8')) self.trUtf8('λληνικ') self.trUtf8(u'εληνιά') self.trUtf8('ελνι'.encode('utf-8')) self.trUtf8(u'ελλκά'.encode('utf-8')) The ones with self.tr display as gibberish in Qt Linguist. The ones with self.trUtf8 display fine, but they trigger a warning when...

QTableView / QTableWidget: Stretch Last Column using Qt Designer

pyqt,pyqt4,qt-designer,pyqt5
I am trying to stretch the last header of my QTableView / QTableWidget in PyQt. Multiple questions have been asked about this topic already by hard coding the value into the file such as: Qt table last column not stretching to fill in parent How to stretch QTableView last column...

pyqt: How to use a same function to set text of different qt widget?

python,qt,pyqt4
I am new to both Qt and python. It may be a easy question to most of your guy, but I can't find it on Google. I have a form, with different sets of "path and button" combinations. click each path it would open a QFileDialog.getOpenFileName() dialog, and setText to...

How can I center a label in the center of a QWizardPage?

python,qt,pyqt,pyqt4,wizard
I have a label: self.label = QtLabel(self) that is inside of a VBoxLayout. That I want to set in the center of a QWizardPage, no matter what size the window becomes. I managed to get it centered horizontally with: self.label.setAlignment(QtCore.Qt.AlignCenter) but I cannot seem to get it to center vertically...

python: how to save dynamically rendered html web page code [SOLVED]

javascript,python,d3.js,pyqt4
I have a setup where a web page in a local server (localhost:8080) is changed dynamically by sending sockets that load some scripts (d3 code mainly). In chrome I can inspect the "rendered html status" of the page, i.e., the resulting html code of the d3/javascript loaded codes. Now, I...

pyside-rcc “dyld: Library not loaded:…”

osx,pyqt4,pyside,enthought,canopy
I'm a python and Qt rookie and I have some problems running pyside-rcc (and pyrcc4). The problem is not the link to the executable but a library problem it seems. That I'm not a unix wizard, probably doesn't help either:) When I run $ pyside-rcc i get the following error...

Matplotlib figure not updating on data change

python,matplotlib,pyqt4
I'm implementing an image viewer using matplotlib. The idea is that changes being made to the image (such as filter application) will update automatically. I create a Figure to show the inital image and have added a button using pyQt to update the data. The data does change, I have...

Detect method by self.sender() in Python

python-2.7,pyqt4
is there a way to detect which method has run other method similarly as you detect object with self.sender()? For example I have a method A that enables all the checkboxes. On one page I have 10 on other 15. Depending on the method B or C that will call...

How to have pushbutton click event to connect to closeEvent? PyQt4

python,pyqt4
I would like to have two different methods for quitting the app: By pressing the default "X" button on the left top corner. Pressing custom QPushButton("Quit") The event where "X" is pressed is connected to a closeEvent function: def closeEvent(self, event): message = QtGui.QMessageBox.question(self, "quit", "Do you really want to...

Highlight item with mouse hover in QTreeView?

qt,pyqt,pyqt4,pyside
I have a QStandardItemModel that I am displaying as a QTreeView with multiple columns (if it matters, I am showing the tree as the central widget of a QMainWindow). I would like to highlight items when the mouse hovers over them. Related pages How to catch mouse over event of...

pyqtgraph ignores some of my data and add some random data

python,pyqt4,pyqtgraph
I am using pyqt4 and PlotWidget for viewing some plots. I have some datetime values in y-axis data. but the problem is that pyqtgraph ignores some of datetime values and add some random data into them. I used setRange method but because some specific data may exists between min and...

What is the purpose of an ampersand (&) in a PyQt4 string? [duplicate]

python,string,pyqt4
This question already has an answer here: Qt - Why add '&' to the string? 2 answers I'm going through some PyQt4 GUI tutorials and often see strings such as "&File" or "&Exit" in menus and the like. My question is what is the purpose of the "&" symbol...

Layout management on PyQt4 Docks

api,pyqt,pyqt4,docking
I am a total GUI n00b developing an application in PyQt4. The application is designed for a lab bench, in which it will first search for equipment, and then populate the main window with docked windows, one for each piece of equipment it finds. The interface for each piece of...

Get plain text from QLineEdit

python-2.7,pyqt4,qstring,qlineedit
I want to retrieve plain text from QLineEdit() object. The text method returns a QString object. I just want a simple string object. I am using pyqt4. def n(self): new_label=QLineEdit() new_label.setText("txt") txt=self.new_label.text() self.name=txt txt should be a simple string not QString....

PyQt: QDataWidgetMapper doesn't show any data in widgets

python-3.x,pyqt,pyqt4
I have a AbstractItemModel that I want to map to some widgets. In the constructor of the window I have: print("creating model") self.model = Model(self.cluster) print("creating mapper") self.mapper = QtGui.QDataWidgetMapper() print("setting model") self.mapper.setModel(self.model) print("setting root index") self.mapper.setRootIndex(self.model.root_index()) print("setting index") self.mapper.setCurrentIndex(0) print("mapping widgets") self.mapper.addMapping(self.realNameLineEdit, 1) self.mapper.addMapping(self.emailLineEdit, 2)...

Pyqt4 accessing objects when creating a dynamic form

python,oop,object,pyqt4
I have created a layout which adds labels and lineedits automatically, once i assigned it into the list, but for me to create a user I need the values from the line edits and comboxes but as you can see I have set each object names, how could i access...

QGIS PyQt4 missing QString class

pyqt,pyqt4,qstring,attributeerror,qgis
i was trying to use a QString in the QGIS Python Console. from PyQt4.QtCore import QString but it says: ImportError: cannot import name QString In my Python IDLE it works fine, but i know that QGIS brings its own PyQt4. What could be the problem here? And could i solve...

Syncing image display with screen refresh rate

opengl,pyqt,pyqt4,pyopengl
What the program does: Using PyQt4 to display images (simple jpg/png files). The objective: Have an image displayed/drawn on the screen in sync with the screen's refresh rate. A pseudo-code sample of what i would like to achieve: pixmap = set_openGL_pixmap(myPixmap) draw_openGL_pixmap(pixmap) doSomthingElse() Ideally, the draw_openGL_pixmap(pixmap) function should only return...

PyQt progress bar not updating or appearing until 100%

python,widget,pyqt,pyqt4
EDIT: There are a number of similar posts on PyQt4 progress bars not updating. They all focus on the issue of threads & where the program actually updates the window. Although helpful, my code was so structured that the replies were not practical. The accepted answer given here is simple,...

matplotlib gauge update dynamically

python,matplotlib,pyqt4,gauge
I tried to create a Gauge like this in matplotlib: http://www.highcharts.com/demo/gauge-solid It almost works. This is the code so far: import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib.patches import Wedge from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure import sys,os from PyQt4...

Window is closing immediately after I run program in PyQt 4 (anaconda) [PyCharm 4.5]

python,window,pyqt4,pycharm
So, I am trying to run a very simple program (a window) in Pycharm that is running anaconda 2.7 & PyQt4. Whenever I click the Run button it opens my program but closes the window too fast for me to even see it. May anyone, please help? Thank you! P.S....

Add scrollbar to grid layout in pyqt4

python,qt,pyqt4
I have coded the following python program. It shows multiple icons in a grid view. import sys from PyQt4.QtGui import * from PyQt4 import QtGui, QtCore class Main(QtGui.QMainWindow): def __init__(self, parent = None): super(Main, self).__init__(parent) self.centralWidget=QWidget() scrollArea=QScrollArea() scrollArea.setWidgetResizable(True) scrollArea.setWidget(self.centralWidget) self.setCentralWidget(self.centralWidget) w=QGridLayout() size=128 icon=QIcon() mode=QIcon.Normal state=QIcon.Off pixma = QPixmap('a.png')...

Using raw_input causes problems with PyQt page loading

python,pyqt4,stdin,raw-input,qwebpage
I'm using PyQt4 to enter credentials into a domain login page and pull data from several additional pages in the domain. Everything works exactly as expected when supplying login or search credentials from within the code. When I open up raw_input to allow the user to enter information, it causes...

Setting the mac task bar menu with pyqt4 and then applying cx_freeze

python,osx,pyqt4,python-3.4,cx-freeze
I have a gui that has a mac task bar menu, see below: The first 3 items on the menu were created using QtDesigner and their sub items and actions connect fine. I created the extra "file" dynamically to see if this would fix the problem. This menu appears exactly...

Creating check boxes dynamically inside the listview based on the layers loaded in QGIS

python-2.7,pyqt,pyqt4
I have a two list views named "Datacheckerlistview1" and "Datacheckerlistview2" in my gui. Now i had loaded layers in QGIS. Based on the number of layers loaded, i want check boxes to be created dynamically with the layer name inside the "Datacheckerlistview1"..( for ex: if there are 4 layers loaded,...

Cannot wrap QWebView.load method

python,pyqt,pyqt4,python-sip
I believe it is common practice (at least it is for me) to be able to wrap function calls. For example, as an example, a minimilistic wrapping function looks like: def wrap(fn, *args, **kwargs): return fn(*args, **kwargs) And you could call an arbitrary method via wrap(qt_method, 1, 2, foo='bar') which...

Can a QListWidget have groupings?

qt,pyqt,pyqt4,qlistwidget,qtreewidget
I currently have a QListWidget that displays many items that are user selectable (and dragable). In my application, when an item is checked it will be reordered above the unchecked items. The user can also drag/drop to adjust the order of the checked items. The problem the users have is...

How can I make link on web page in window using pyqt4?

python,qt,hyperlink,pyqt,pyqt4
I have a problem. Can I make a link on the web page in the window and when the user clicks on it, the web page will be open in the browser. For example: import sys from PyQt4 import QtGui, QtCore app = QtGui.QApplication(sys.argv) main = QtGui.QWidget() main.setGeometry(200, 200, 200,...

Can't add extension to file in QFileDialog

python,pyqt4
I've got a problem with saving file with extension (get path to file and append extension) in PyQt4 with QFileDialog. My Python code looks like that: dialog = QtGui.QFileDialog() dialog.setDefaultSuffix(".json") file = dialog.getSaveFileName(None, "Title", "", "JSON (.json)") It works, path is correct, dialog title and filter are in dialog window,...

Macport-installed python can't find macport-installed sip

qt,pyqt4,macports
I am learning PyQt4 by reading Rapid GUI Programming with Python and Qt and am at chapter 7 which covers QT Designer; however QT Designer doesn't appear to be installed with my MacPort's (py34-pyqt4) or the example code from the book's website www.qtrac.eu. So I'm downloading QT Designer from www.qt.io....

Using threading.timer to delay sub-procedure

python-3.x,pyqt4,self
def emailCheck(self): n=0 (retcode, messages) = mail.search(None, '(UNSEEN)') if retcode == 'OK': for num in messages[0].split() : n=n+1 typ, data = mail.fetch(num,'(RFC822)') for response_part in data: if isinstance(response_part, tuple): original = email.message_from_bytes(response_part[1]) print (original['From']) print (original['Subject']) typ, data = mail.store(num,'+FLAGS','\\Seen') print (n) t = threading.Timer(10.0, emailCheck) t.start() I am trying...

PyQt GUI order of operations

python,python-2.7,user-interface,pyqt,pyqt4
I have a following problem: upon pressing a button in PyQt made GUI I have to do two actions: Immediately update a QTextBrowser Run a method that will wait for some time and enable some buttons after. What I get is that 1 and 2 are done at the same...

Trying to get just “x” coordinate from pos() method python

python,position,mouseevent,pyqt4
I'm currently having an issue getting just the x position of the cursor so I can place a marker on that x and y location. I'm using QGraphicsScene and view to create this circle object at the location of the mouse when the mouse is clicked. Since the QGraphicsEllipseItem takes...

Qgraphicsview items not being placed where they should be

python,mouseevent,pyqt4,qgraphicsscene
I recently created a program that will create QgraphicsEllipseItems whenever the mouse is clicked. That part works! However, it's not in the exact place where my cursor is. It seems to be slightly higher than where my mouse cursor is. I do have a QGraphicsRectItem created so maybe the two...

How to override Pyqt combobox ItemText method so it returns default python string instead of QString?

python,list,combobox,pyqt,pyqt4
When ever I do resos = [_ui.ComboBox.itemText(i) for i in range(_ui.ComboBox.count())] it is giving me list of [PyQt4.QtCore.QString(u'1280x720 from 1.316'), PyQt4.QtCore.QString(u'1920x1080 from 1.316'),] how would it be possible to override ComboBox's itemText method so that it only returns python string ? instead of doing string conversion in the list comprehension...

Custom Locks Threading python

python,multithreading,pyqt4,locks
Hi I am using PyQt4 and i need to implement locks in a QThread but this class does not have a method lock implemented like the library threading. Any idea how can I implement a lock here? I have a question if i use threading i implement the lock like...