Search Results

Search found 118 results on 5 pages for 'pyqt4'.

Page 2/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Make qwidget in new window in PyQt4

    - by matt
    I'm trying to make a class that extends qwidget, that pops up a new window, I must be missing something fundamental, class NewQuery(QtGui.QWidget): def __init__(self, parent): QtGui.QMainWindow.__init__(self,parent) self.setWindowTitle('Add New Query') grid = QtGui.QGridLayout() label = QtGui.QLabel('blah') grid.addWidget(label,0,0) self.setLayout(grid) self.resize(300,200) when a new instance of this is made in main window's class, and show() called, the content is overlaid on the main window, how can I make it display in a new window?

    Read the article

  • Télécharger un fichier du Web avec PyQt4 et QThread, un article de Jean-Paul Vidal

    Bonjour, Je vous informe d'un nouveau tuto sur developpez : comment télécharger un fichier sur le Web avec PyQt4. Le code utilise QThread (le thread de Qt4) et, pour le téléchargement, le module urllib. Il permet de montrer comment les threads peuvent communiquer par messages avec l'interface graphique afin de mettre à jour une barre de progression du téléchargement. Il a été développé suite au fil de discussion http://www.developpez.net/forums/d10...s-urlretrieve/. Tyrtamos...

    Read the article

  • Segmentation fault while switching QCompleter for QLineEdit [on hold]

    - by san
    I have a QLineEdit that uses autocompletion one which on focusIn event in which it shows paths from XML List(here I have used hardcoded list) but if user doesn't find the path from that list popped by QCompleter than I want user to be able to browse to path typing '/' in QLineEdit , I am not able to select the paths say /Users etc and on trying to type Segmentation fault occurs. from PyQt4.Qt import Qt, QObject,QLineEdit from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT from PyQt4 import QtGui, QtCore import sys class DirLineEdit(QLineEdit, QtCore.QObject): """docstring for DirLineEdit""" def __init__(self): super(DirLineEdit, self).__init__() self.defaultList = ['~/Development/python/searchMethod', '~/Development/Nuke_python', '~/Development/python/openexr', '~/Development/python/cpp2python'] self.textChanged.connect(self.__dirCompleter) def focusInEvent(self, event): if len(self.text()) == 0: self._pathsList() QtGui.QLineEdit.focusInEvent(self, event) self.completer().complete() def __dirCompleter(self): if len(self.text()) == 0: model = MyListModel(self.defaultList, self) completer = QtGui.QCompleter(model, self) completer.setModel(model) else: dirModel = QtGui.QFileSystemModel() dirModel.setRootPath(QtCore.QDir.currentPath()) dirModel.setFilter(QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Files) dirModel.setNameFilterDisables(0) completer = QtGui.QCompleter(dirModel, self) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) completer.setModel(dirModel) self.setCompleter(completer) def _pathsList(self): completerList = QtCore.QStringList() for i in self.defaultList: completerList.append(QtCore.QString(i)) lineEditCompleter = QtGui.QCompleter(completerList) lineEditCompleter.setCompletionMode(QtGui.QCompleter.UnfilteredPopupCompletion) self.setCompleter(lineEditCompleter) class MyListModel(QtCore.QAbstractListModel): def __init__(self, datain, parent=None, *args): """ datain: a list where each item is a row """ QtCore.QAbstractTableModel.__init__(self, parent, *args) self.listdata = datain def rowCount(self, parent=QtCore.QModelIndex()): return len(self.listdata) def data(self, index, role): if index.isValid() and role == QtCore.Qt.DisplayRole: return QtCore.QVariant(self.listdata[index.row()]) else: return QtCore.QVariant() app = QtGui.QApplication(sys.argv) smObj = DirLineEdit() smObj.show() app.exec_() Please help fix this or suggest better way of implementation?

    Read the article

  • PyQt4: Why does Python crash on close when using QTreeWidgetItem?

    - by Rini
    I'm using Python 3.1.1 and PyQt4 (not sure how to get that version number?). Python is crashing whenever I exit my application. I've seen this before as a garbage collection issue, but this time I'm not sure how to correct the problem. This code crashes: import sys from PyQt4 import QtGui class MyWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.tree = QtGui.QTreeWidget(self) self.setCentralWidget(self.tree) QtGui.QTreeWidgetItem(self.tree) # This line is the problem self.show() app = QtGui.QApplication(sys.argv) mw = MyWindow() sys.exit(app.exec_()) If I remove the commented line, the code exits without a problem. If I remove the 'self.tree' parent from the initialization, the code exits without a problem. If I try to use self.tree.addTopLevelItem, the code crashes again. What could be the problem?

    Read the article

  • Why doesn't my QsciLexerCustom subclass work in PyQt4 using QsciScintilla?

    - by Jon Watte
    My end goal is to get Erlang syntax highlighting in QsciScintilla using PyQt4 and Python 2.6. I'm running on Windows 7, but will also need Ubuntu support. PyQt4 is missing the necessary wrapper code for the Erlang lexer/highlighter that "base" scintilla has, so I figured I'd write a lightweight one on top of QsciLexerCustom. It's a little bit problematic, because the Qsci wrapper seems to really want to talk about line+index rather than offset-from-start when getting/setting subranges of text. Meanwhile, the lexer gets arguments as offset-from-start. For now, I get a copy of the entire text, and split that up as appropriate. I have the following lexer, and I apply it with setLexer(). It gets all the appropriate calls when I open a new file and sets this as the lexer, and prints a bunch of appropriate lines based on what it's doing... but there is no styling in the document. I tried making all the defined styles red, and the document is still stubbornly black-on-white, so apparently the styles don't really "take effect" What am I doing wrong? If nobody here knows, what's the appropriate discussion forum where people might actually know these things? (It's an interesting intersection between Python, Qt and Scintilla, so I imagine the set of people who would know is small) Let's assume prefs.declare() just sets up a dict that returns the value for the given key (I've verified this -- it's not the problem). Let's assume scintilla is reasonably properly constructed into its host window QWidget. Specifically, if I apply a bundled lexer (such as QsciLexerPython), it takes effect and does show styled text. prefs.declare('font.name.margin', "MS Dlg") prefs.declare('font.size.margin', 8) prefs.declare('font.name.code', "Courier New") prefs.declare('font.size.code', 10) prefs.declare('color.editline', "#d0e0ff") class LexerErlang(Qsci.QsciLexerCustom): def __init__(self, obj = None): Qsci.QsciLexerCustom.__init__(self, obj) self.sci = None self.plainFont = QtGui.QFont() self.plainFont.setPointSize(int(prefs.get('font.size.code'))) self.plainFont.setFamily(prefs.get('font.name.code')) self.marginFont = QtGui.QFont() self.marginFont.setPointSize(int(prefs.get('font.size.code'))) self.marginFont.setFamily(prefs.get('font.name.margin')) self.boldFont = QtGui.QFont() self.boldFont.setPointSize(int(prefs.get('font.size.code'))) self.boldFont.setFamily(prefs.get('font.name.code')) self.boldFont.setBold(True) self.styles = [ Qsci.QsciStyle(0, QtCore.QString("base"), QtGui.QColor("#000000"), QtGui.QColor("#ffffff"), self.plainFont, True), Qsci.QsciStyle(1, QtCore.QString("comment"), QtGui.QColor("#008000"), QtGui.QColor("#eeffee"), self.marginFont, True), Qsci.QsciStyle(2, QtCore.QString("keyword"), QtGui.QColor("#000080"), QtGui.QColor("#ffffff"), self.boldFont, True), Qsci.QsciStyle(3, QtCore.QString("string"), QtGui.QColor("#800000"), QtGui.QColor("#ffffff"), self.marginFont, True), Qsci.QsciStyle(4, QtCore.QString("atom"), QtGui.QColor("#008080"), QtGui.QColor("#ffffff"), self.plainFont, True), Qsci.QsciStyle(5, QtCore.QString("macro"), QtGui.QColor("#808000"), QtGui.QColor("#ffffff"), self.boldFont, True), Qsci.QsciStyle(6, QtCore.QString("error"), QtGui.QColor("#000000"), QtGui.QColor("#ffd0d0"), self.plainFont, True), ] print("LexerErlang created") def description(self, ix): for i in self.styles: if i.style() == ix: return QtCore.QString(i.description()) return QtCore.QString("") def setEditor(self, sci): self.sci = sci Qsci.QsciLexerCustom.setEditor(self, sci) print("LexerErlang.setEditor()") def styleText(self, start, end): print("LexerErlang.styleText(%d,%d)" % (start, end)) lines = self.getText(start, end) offset = start self.startStyling(offset, 0) print("startStyling()") for i in lines: if i == "": self.setStyling(1, self.styles[0]) print("setStyling(1)") offset += 1 continue if i[0] == '%': self.setStyling(len(i)+1, self.styles[1]) print("setStyling(%)") offset += len(i)+1 continue self.setStyling(len(i)+1, self.styles[0]) print("setStyling(n)") offset += len(i)+1 def getText(self, start, end): data = self.sci.text() print("LexerErlang.getText(): " + str(len(data)) + " chars") return data[start:end].split('\n') Applied to the QsciScintilla widget as follows: _lexers = { 'erl': (Q.SCLEX_ERLANG, LexerErlang), 'hrl': (Q.SCLEX_ERLANG, LexerErlang), 'html': (Q.SCLEX_HTML, Qsci.QsciLexerHTML), 'css': (Q.SCLEX_CSS, Qsci.QsciLexerCSS), 'py': (Q.SCLEX_PYTHON, Qsci.QsciLexerPython), 'php': (Q.SCLEX_PHP, Qsci.QsciLexerHTML), 'inc': (Q.SCLEX_PHP, Qsci.QsciLexerHTML), 'js': (Q.SCLEX_CPP, Qsci.QsciLexerJavaScript), 'cpp': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'h': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'cxx': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'hpp': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'c': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'hxx': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'tpl': (Q.SCLEX_CPP, Qsci.QsciLexerCPP), 'xml': (Q.SCLEX_XML, Qsci.QsciLexerXML), } ... inside my document window class ... def addContentsDocument(self, contents, title): handler = self.makeScintilla() handler.title = title sci = handler.sci sci.append(contents) self.tabWidget.addTab(sci, title) self.tabWidget.setCurrentWidget(sci) self.applyLexer(sci, title) EventBus.bus.broadcast('command.done', {'text': 'Opened ' + title}) return handler def applyLexer(self, sci, title): (language, lexer) = language_and_lexer_from_title(title) if lexer: l = lexer() print("making lexer: " + str(l)) sci.setLexer(l) else: print("setting lexer by id: " + str(language)) sci.SendScintilla(Qsci.QsciScintillaBase.SCI_SETLEXER, language) linst = sci.lexer() print("lexer: " + str(linst)) def makeScintilla(self): sci = Qsci.QsciScintilla() sci.setUtf8(True) sci.setTabIndents(True) sci.setIndentationsUseTabs(False) sci.setIndentationWidth(4) sci.setMarginsFont(self.smallFont) sci.setMarginWidth(0, self.smallFontMetrics.width('00000')) sci.setFont(self.monoFont) sci.setAutoIndent(True) sci.setBraceMatching(Qsci.QsciScintilla.StrictBraceMatch) handler = SciHandler(sci) self.handlers[sci] = handler sci.setMarginLineNumbers(0, True) sci.setCaretLineVisible(True) sci.setCaretLineBackgroundColor(QtGui.QColor(prefs.get('color.editline'))) return handler Let's assume the rest of the application works, too (because it does :-)

    Read the article

  • Qwidget window disappears [migrated]

    - by user3716006
    Okay... This has been bugging me for hours. I have a qtmainwindow with a menubar. I've managed to connect an action in tje menubar to an independent Qwidget. But as soon as the Qwidget appears it disappears. I'm using the latest version of pyqt. Here's the code: Import sys from PyQt4 import QtGui, QtCore Class Main(QtGui.QtMainWindow) : def __init__(self) : QtGui.QtMainWindow.__init__(self) self.setGeometry(300,300,240,320) self.show() menubar = self. menuBar() filemenu = menubar. addMenu('&File') new = QtGui.QAction(QtGui.QIcon('new.png'), 'New', self) new.triggered.connect(self.pop) filemenu.addAction(new) def pop(self) : pop = Pop() class Pop(QtGui.QWidget) : def __init__(self) : QtGui.QWidget.__init__(self) self.setGeometry(300,300,240,320> self.setWindowTitle('Pop up') self.show()

    Read the article

  • Tying PyQt4 QAction triggered() to local class callable doesn't seem to work. How to debug this?

    - by Jon Watte
    I create this object when I want to create a QAction. I then add this QAction to a menu: class ActionObject(object): def __init__(self, owner, command): action = QtGui.QAction(command.name, owner) self.action = action self.command = command action.setShortcut(command.shortcut) action.setStatusTip(command.name) QtCore.QObject.connect(action, QtCore.SIGNAL('triggered()'), self.triggered) def triggered(self): print("got triggered " + self.command.id + " " + repr(checked)) Unfortunately, when the menu item is selected, the 'triggered' function is not called. QtCore.QObject.connect() returns True. Nothing is printed on the console to indicate that anything is wrong, and no exception is thrown. How can I debug this? (or, what am I doing wrong?)

    Read the article

  • PyQt4, QThread and opening big files without freezing the GUI

    - by jmrbcu
    Hi, I would like to ask how to read a big file from disk and maintain the PyQt4 UI responsive (not blocked). I had moved the load of the file to a QThread subclass but my GUI thread get freezed. Any suggestions? I think it must be something with the GIL but I don't know how to sort it? EDIT: I am using vtkGDCMImageReader from the GDCM project to read a multiframe DICOM image and display it with vtk and pyqt4. I do this load in a different thread (QThread) but my app freeze until the image is loaded. here is an example code: class ReadThread(QThread): def __init__(self, file_name): super(ReadThread, self).__init__(self) self.file_name = file_name self.reader.vtkgdcm.vtkGDCMImageReader() def run(self): self.reader.SetFileName(self.file_name) self.reader.Update() self.emit(QtCore.SIGNAL('image_loaded'), self.reader.GetOutput())

    Read the article

  • PyQt4.QtCore doesn't contain many of its classes and attributes

    - by toc777
    Hi everyone, I have built PyQt4 from source and everything went smoothly until I tried to use some of the classes and attributes located in QtCore. For some reason QtCore is missing a lot of functionality and data that should be there. For example from PyQt4.QtCore import QT_VERSION_STR is an import error. There were no errors or warnings given when building the packages and I have also tried with the PyQt packages from yum but I have the same problem. Has anyone else encountered this problem before? Thanks.

    Read the article

  • ImportError: No module named QtWebKit

    - by Hallik
    I am on centos5. I installed python26 source with a make altinstall. Then I did a: yum install qt4 yum install qt4-devel yum install qt4-doc From riverbankcomputing.co.uk I downloaded the source for sip 4.10.2, compiled and installed fine. Then from the same site I downloaded and compiled from source PyQt-x11-4.7.3 Both installs were using the python26 version (/usr/local/bin/python2.6). So configure.py, make, and make install worked with no errors. Finally, I tried to run this script, but got the error in the subject of this post: import sys import signal from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import QWebPage def onLoadFinished(result): if not result: print "Request failed" sys.exit(1) #screen = QtGui.QDesktopWidget().screenGeometry() size = webpage.mainFrame().contentsSize() # Set the size of the (virtual) browser window webpage.setViewportSize(webpage.mainFrame().contentsSize()) # Paint this frame into an image image = QImage(webpage.viewportSize(), QImage.Format_ARGB32) painter = QPainter(image) webpage.mainFrame().render(painter) painter.end() image.save("output2.png") sys.exit(0) app = QApplication(sys.argv) signal.signal(signal.SIGINT, signal.SIG_DFL) webpage = QWebPage() webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished) webpage.mainFrame().load(QUrl("http://www.google.com")) sys.exit(app.exec_()) Even in the beginning of the configure for pyqt4, I saw it say QtWebKit should be installed, but apparently it's not? What's going on? I just did a find, and it looks like it wasn't installed. What are my options? [root@localhost ~]# find / -name '*QtWebKit*' /root/PyQt-x11-gpl-4.7.3/sip/QtWebKit /root/PyQt-x11-gpl-4.7.3/sip/QtWebKit/QtWebKitmod.sip /root/PyQt-x11-gpl-4.7.3/cfgtest_QtWebKit.cpp

    Read the article

  • Qt - QWebView Problem

    - by user547057
    Hi, I have a PyQt gui script which consists of a QWebView widget. I'm trying to send a GET request, i.e go to a page, fill a form and hit click using the code at the bottom of this question. Since i'm dealing with the documentElement(a QWebElement) of the webview, I need to place all DOM actions in a separate function(which I have named fillForm) and connect the loadFinished() signal into the function. Without connecting the signal, the document will not have loaded and I won't be able to get the elements I want. I'm able to submit the form correctly and get the proper response from the webpage. The problem i'm having is that, the above leads to a sort of infinite loop. This is because the webpage gets reloaded each time a new page is loaded, so the form gets filled each and every single time without stopping. I'd like to know if there's some way of finding out whether the WebView's page has loaded fully, non-asynchronously or maybe pause execution of the script(without freezing the gui) until the whole document has loaded. I'm unable to come up with a satisfactory solution(my idea consisted of keeping a global variable to track clicks) to this problem. I would appreciate it if someone could help me out with a better way to tackle this. Thanks! Here's the code i'm using import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * from PyQt4 import QtCore app = QApplication(sys.argv) web = QWebView() web.load(QUrl("http://mywebsite.com")) def fillForm(): doc = web.page().mainFrame().documentElement() searchform = doc.findFirst("input[type=text]") searchform.setAttribute("value", "hello") button = doc.findFirst("input[type=submit]") button.evaluateJavaScript("click()") QtCore.QObject.connect(web, QtCore.SIGNAL("loadFinished"), fillForm) web.show() sys.exit(app.exec_())

    Read the article

  • PyQt application architecture

    - by L. De Leo
    I'm trying to give a sound structure to a PyQt application that implements a card game. So far I have the following classes: Ui_Game: this describes the ui of course and is responsible of reacting to the events emitted by my CardWidget instances MainController: this is responsible for managing the whole application: setup and all the subsequent states of the application (like starting a new hand, displaying the notification of state changes on the ui or ending the game) GameEngine: this is a set of classes that implement the whole game logic Now, the way I concretely coded this in Python is the following: class CardWidget(QtGui.QLabel): def __init__(self, filename, *args, **kwargs): QtGui.QLabel.__init__(self, *args, **kwargs) self.setPixmap(QtGui.QPixmap(':/res/res/' + filename)) def mouseReleaseEvent(self, ev): self.emit(QtCore.SIGNAL('card_clicked'), self) class Ui_Game(QtGui.QWidget): def __init__(self, window, *args, **kwargs): QtGui.QWidget.__init__(self, *args, **kwargs) self.setupUi(window) self.controller = None def place_card(self, card): cards_on_table = self.played_cards.count() + 1 print cards_on_table if cards_on_table <= 2: self.played_cards.addWidget(card) if cards_on_table == 2: self.controller.play_hand() class MainController(object): def __init__(self): self.app = QtGui.QApplication(sys.argv) self.window = QtGui.QMainWindow() self.ui = Ui_Game(self.window) self.ui.controller = self self.game_setup() Is there a better way other than injecting the controller into the Ui_Game class in the Ui_Game.controller? Or am I totally off-road?

    Read the article

  • How would you adblock using Python?

    - by regomodo
    I'm slowly building a web browser in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser. How would you go about it using python/PyQt4? [edit1] Ok. I think i've setup Privoxy. I haven't setup any additional filters and it seems to work. The PyQt4 i've tried to use looks like this self.proxyIP = "127.0.0.1" self.proxyPORT= 8118 proxy = QNetworkProxy() proxy.setType(QNetworkProxy.HttpProxy) proxy.setHostName(self.proxyIP) proxy.setPort(self.proxyPORT) QNetworkProxy.setApplicationProxy(proxy) However, this does absolutely nothing and I cannot make sense of the docs and can not find any examples. [edit2] I've just noticed that i'f I change self.proxyIP to my actual local IP rather than 127.0.0.1 the page doesn't load. So something is happening.

    Read the article

  • More compact layout

    - by Jesse Aldridge
    In the following code, I'd like to get rid of the margin around the buttons. I'd like to have the buttons stretch all the way to the edge of the frame. How can I do that? import sys from PyQt4.QtGui import * from PyQt4.QtCore import * app = QApplication(sys.argv) window = QWidget() layout = QVBoxLayout() layout.setSpacing(0) window.setLayout(layout) for i in range(2): layout.addWidget(QPushButton()) window.show() app.exec_()

    Read the article

  • How to get text in QlineEdit when QpushButton is pressed in a string?

    - by esafwan
    I have given my code below, have problem in implementing a function I want the text in lineedit with objectname 'host' in a string say 'shost'. when the user click the pushbutton with name 'connect'.How do i do it? I tried and failed. How to implement this function? import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) le = QLineEdit() le.setObjectName("host") le.setText("Host") pb = QPushButton() pb.setObjectName("connect") pb.setText("Connect") layout.addWidget(le) layout.addWidget(pb) self.setLayout(layout) self.connect(pb, SIGNAL("clicked()"),self.button_click) self.setWindowTitle("Learning") def button_click(self): #i want the text in lineedit with objectname #'host' in a string say 'shost'. when the user click # the pushbutton with name connect.How do i do it? # I tried and failed. How to implement this function? app = QApplication(sys.argv) form = Form() form.show() app.exec_() Now how do i implement the function "def button_click(self):" ? I have just started with pyQt!

    Read the article

  • Using QTDesigner with PyQT and Python 2.6

    - by PyNewbie27
    Hi. I'm fairly new to Python and trying to work with the latest versions of QTDesigner, PyQT 4.7 and QT4.7 (I downloaded the whole package from PyQT4.7 website). I can't figure out how to make QTDesigner integrate closely with Python: ie. If I select "Form" View Code in QTDesigners menu, it errors saying "Unable to launch C:/Python26/Lib/site-packages/PyQT4/bin\uic." If I look in that directory there is a pyuic.py but not "uic". From searching online it seems this doesn't exist because it's expecting a C++ install instead of the python version. Is there anyway to make QTDesigner use/call pyuic.py to generate the code, then open an IDE or text editor of my choice to show me the PYTHON code generated by the QTDesigner-PyUIC chain? I'd like Designer to integrate closely with python, so I can make custom slots/signals in Designer while designing, then tweak the python code directly in my IDE later. If it is not possible to code directly inside QTDesigner using python, does that mean I have to hand code my programs entire UI directly in my PythonIDE? Using Designer directly would seemingly be nearly very very nice for a newbie such as myself, since I can see what properties each widget has and visually edit them while still learning the QT syntax without constantly having to use web resources to see what properties each widget should have and helps with boilerplate code generation, and what their defaults are, etc. I've googled and nobody seems to be using QTDesigner and Python in this manner together. It seems most are either handcoding all the QT code in their Python IDE of choice, or have found an obvious/easy method of doing what I want, therefore not really producing up to date tutorials on making this work together. Please enlighten me if you can. Thanks in advance for your time. Please include any suggestions you might have to a newbie trying to use Python with QT and QTDesigner. Thank you.

    Read the article

  • QWebView not loading external resources

    - by Nick
    Hi. I'm working on a kiosk web browser using Qt and PyQt4. QWebView seems to work quite well except for one quirk. If a URL fails to load for any reason, I want to redirect the user to a custom error page. I've done this using the loadFinished() signal to check the result, and change the URL to the custom page if necessary using QWebView.load(). However, any page I attempt to load here fails to pull in external resources like CSS or images. Using QWebView.load() to set the initial page at startup seems to work fine, and clicking any link on the custom error page will result in the destination page loading fine. It's just the error page that doesn't work. I'm really not sure where to go next. I've included the source for an app that will replicate the problem below. It takes a URL as a command line argument - a valid URL will display correctly, a bad URL (eg. DNS resolution fails) will redirect to Google, but with the logo missing. import sys from PyQt4 import QtGui, QtCore, QtWebKit class MyWebView(QtWebKit.QWebView): def __init__(self, parent=None): QtWebKit.QWebView.__init__(self, parent) self.resize(800, 600) self.load(QtCore.QUrl(sys.argv[1])) self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.checkLoadResult) def checkLoadResult(self, result): if (result == False): self.load(QtCore.QUrl('http://google.com')) app = QtGui.QApplication(sys.argv) main = MyWebView() main.show() sys.exit(app.exec_()) If anyone could offer some advice it would be greatly appreciated.

    Read the article

  • Supported Audio Formats of Qt4 Phonon?

    - by Nikwin
    I am making a music player in PyQt4, and I am using Phonon to play the music itself. This application is aimed primarily at Windows, but I plan on also supporting Mac and Linux versions. What I want to know is which audio formats are supported by Phonon so that I can ensure that the user only enters those files.

    Read the article

  • changing cell background color in qt

    - by Moayyad Yaghi
    hello .. i'm new to pyqt , and i'm still facing some newbie problems :D i have a QTableWidget that is item delegated on a QChoice control ( hope i said it right ) i need to have the cell background color changes whenever a user change the choice control selection briefly: how to change a cell background color in a table widget ?? i use pyqt4 and python 2.6 thanx in advance

    Read the article

  • PyQt4 and QTableView with spinbox and checkbox

    - by ekapek
    Hi, I have a QTableView with QSqlTableModel and with 3 columns, now I need to have: - second column: spinbox after clicked to edit - third column: checkbox (displayed center) My code: class SpinBoxDelegate(QtGui.QItemDelegate): def createEditor(self, parent, option, index): editor = QtGui.QSpinBox(parent) editor.setMinimum(0) editor.setMaximum(100) print 'spinbox' return editor def setEditorData(self, spinBox, index): value = index.model().data(index, QtCore.Qt.EditRole).toInt()[0] spinBox.setValue(value) def setModelData(self, spinBox, model, index): spinBox.interpretText() value = spinBox.value() model.setData(index, value, QtCore.Qt.EditRole) def updateEditorGeometry(self, editor, option, index): editor.setGeometry(option.rect) class myQSqlTableModel(QtSql.QSqlTableModel): def flags(self,index): result = QtSql.QSqlTableModel.flags(self,index); if index.column() == 2: result |= QtCore.Qt.ItemIsUserCheckable return result def data(self,index,role): if not index.isValid: return QtCore.QVariant() value = QtSql.QSqlTableModel.data(self, index, role) if index.column() == 2: if role == QtCore.Qt.CheckStateRole: return QtCore.Qt.Unchecked if QtSql.QSqlTableModel.data(self, index).toInt()[0] else QtCore.Qt.Checked elif role == QtCore.Qt.DisplayRole: return QtCore.QVariant() return value and self.model = myQSqlTableModel(self) self.model.setTable("person") self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit) self.model.select(): self.model.setHeaderData(0, QtCore.Qt.Horizontal, self.tr("ID")) self.model.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("A")) self.model.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("B")) self.view = QtGui.QTableView() self.view.setModel(self.model) self.view.setSortingEnabled(True) spinDelegate = SpinBoxDelegate() self.view.setItemDelegateForColumn(1,spinDelegate) but it does't work: spinbox don't show after click and checkbox can't be clicked and is aligned to left Any help?

    Read the article

  • Python PyQT4 - Adding an unknown number of QComboBox widgets to QGridLayout

    - by ZZ
    Hi all, I want to retrieve a list of people's names from a queue and, for each person, place a checkbox with their name to a QGridLayout using the addWidget() function. I can successfully place the items in a QListView, but they just write over the top of each other rather than creating a new row. Does anyone have any thoughts on how I could fix this? self.chk_People = QtGui.QListView() items = self.jobQueue.getPeopleOffQueue() for item in items: QtGui.QCheckBox('%s' % item, self.chk_People) self.jobQueue.getPeopleOffQueue() would return something like ['Bob', 'Sally', 'Jimmy'] if that helps.

    Read the article

  • matplotlib 3D plot with PyQt4 in Qtabwidget (mplwidget)

    - by artdijk
    I am working on my first Python app using PythonXY (2.6 and Qt4). I have a window with some buttons and a QtabWidget. When I press a button I want to plot a 3D image on a specific tab. I managed to get a 2D plot but I can't get the axes to 3D. Via Qt desiger I use the mplwidget. In many examples I see the use of figure(), but I can't get that to work with the mplwidget. (I am not sure if that is even possible) Can you please show me an example of code defining the 3D axes (in a QtabWidget) with a simple plot ? Thanks very much

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >