Re: [PyQt] Examples of Big PyQt application with sources
On 19/01/2010 8:28, David Douard wrote: Le Thursday 14 January 2010 03:23:00 AON LAZIO, vous avez écrit : Hi, You guys know the sources where we can get source codes for some big pyqt applications? I mean the applications that are actually deployed for real use Thanks For a not so big (but really used) application, you may have a look at hgview http://www.logilab.org/project/hgview This is also a good reference: http://spyrit.ierne.eu.org/ -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] First bottom-up GUI, acting strange
Nonyaz wrote: I made an attempt to port over a little command line file DL script I wrote into a GUI as a practice working with PyQt. While I have seemingly achieved that goal, the resulting product is not acting as I suspected. When I start a download, the GUI will continue to update as long as I don't click it, as soon as I do, the OS throws up Not Responding in the title bar and the GUI no longer updates. Even when I don't click it, I can tell somethings not right, the start button never releases, and the progress bar effects on vista are not apparent. Hopefully someone can point out to me what I'm doing wrong, I have a feeling its just bad event loop execution, although I'm not quite sure how I could rewrite it so it wouldn't have this problem. import urllib, os, time, sys, win32con import win32clipboard as w from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) self.lineedit = QLineEdit() self.getclip = QCommandLinkButton(Poll Clipboard) self.progbar = QProgressBar() self.speed = QLabel() self.status = QLabel() self.startb = QPushButton(Start DL) grid = QGridLayout() buttlay = QHBoxLayout() buttlay.addStretch() buttlay.addWidget(self.startb) grid.addWidget(self.lineedit,0,0) grid.addWidget(self.getclip,0,1) grid.addWidget(self.progbar,1,0,1,0) grid.addWidget(self.status,3,0) grid.addWidget(self.speed,3,1) grid.addLayout(buttlay,4,1) self.setLayout(grid) self.setWindowTitle(Clipboard DL V.001) self.lineedit.setText(getText()) self.lineedit.setMinimumSize(300,0) self.startb.setMaximumSize(75,300) self.connect(self.startb, SIGNAL(clicked()), fileDL) self.connect(self.getclip, SIGNAL(clicked()), setClipText) class myURLOpener(urllib.FancyURLopener): def http_error_206(self, url, fp, errcode, errmsg, headers, data=None): print I've been 206'd! pass def getText(): w.OpenClipboard() try: d = w.GetClipboardData(win32con.CF_TEXT) except: d = None. w.CloseClipboard() if d[:7] != http://: d = Clipboard does not contain a valid URL. return d def fileDL(): loop = 1 existSize = 0 dlFile = getFilename() url = str(daprog.lineedit.text()) myUrlclass = myURLOpener() webPage = myUrlclass.open(url) contentLength = int(webPage.headers['Content-Length']) if os.path.exists(str(dlFile)): outputFile = open(dlFile,ab) existSize = os.path.getsize(dlFile) if existSize contentLength: webPage.close() myUrlclass = None myUrlclass = myURLOpener() myUrlclass.addheader(Range,bytes=%s- % (existSize)) webPage = myUrlclass.open(url) else: try: outputFile = open(dlFile,wb) except: os.mkdir(dldir+'/'+show) outputFile = open(dlFile,wb) existSize = 0 if existSize == contentLength: daprog.status.setText(All %s bytes already downloaded!\n % (contentLength)) raw_input() loop = 0 elif existSize == 0: pass elif existSize contentLength: daprog.status.setText(Resuming download) numBytes = existSize daprog.status.setText(Download Started) counterr = 0 while loop: if counterr == 0: intime = time.time() daprog.progbar.setValue((float(numBytes)/float(contentLength)*100)) data = webPage.read(8192) if not data: break outputFile.write(data) numBytes += len(data) if counterr == 10: counterr = -1 outtime = time.time() lab = %.2f KB/s % (((8192*10)/(outtime-intime))/1000) daprog.speed.setText(lab) counterr += 1 daprog.progbar.setValue(100) daprog.status.setText(Done) webPage.close() outputFile.close() def getFilename(): hack_fin = 0 fname = '' for x in str(daprog.lineedit.text())[::-1]: if x == /: hack_fin = 1 if x != /: if hack_fin == 0: fname += x return fname[::-1] def setClipText(): daprog.lineedit.setText(getText()) app = QApplication(sys.argv) daprog = Window() daprog.show() daprog.exec_() Thanks for your help, - Adam ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Could it be that you need a QApplication.processEvents() call in your while loop? This command gives some CPU to the GUI to update itself. I'm afraid the while loop eats all CPU and there's no time/possibility to update the UI... From the documentation (QCoreApplication.processEvents()): You can call this function occasionally when your program is busy performing a long operation
Re: [PyQt] Any Large PyQt Projects?
Brent Villalobos wrote: I'm looking for examples from people who have written large PyQt applications and I would like to hear your opinions on what worked well and what did not specifically with choosing python over C/C++. In particular, how does your python application handle tasks that require a lot of computation? How does it handle multiple thread performance given python's limitations on only running on one CPU (global interpreter lock)? I don't need too much detail (obviously nothing proprietary), but I just want to know if anyone has any red flags that people should be aware of before writing a large python gui app with things like openGL contexts and heavy mathematical computation? Let's make this interesting and see who has written the largest PyQt application. How many lines of code are we talking about? 10,000? 100,000? 1,000,000??? -Brent ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Maybe the application *Spyrit* might inspyre you too? See http://sourceforge.net/projects/spyrit. Not that big, but very interesting to learn a lot of things... -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Possible to stop a QTimer.singleShot()?
Hi, 1. Is it possible to stop a QTimer.singleShot() timer (pls. don't tell me to use the stop() function of a QTimer() object, I really want to know if the static function QTimer.singleShot() can be stopped before its time has elapsed)? 2. What happens if a second QTimer.singleShot() is launched before the first one has elapsed? Is the first one killed or is a second one started instead? -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Avoiding freeze of the application
Hi, I want to achieve the following: * My (Windows) application is trying to make a connection with a Linux server, using another application (plink, part of the Putty distro) * Since an external application is to be called, I'm using the method subprocess in this way: retcode = subprocess.call( plink -batch %...@%s echo % (self.beqLineEdit.text(), self.linuxmachineComboBox.currentText()) , shell=True , stderr=errptr ) * However, that call can take up to 10 seconds (worst case). In the mean time, my main application is frozen, I can't do anything else. Now, what I would like to do, is to decouple the above call from the main thread, such that the main application becomes free again. I also would like to start a one shot timer (using QTimer.singleShot()) to create a time-out. This is to prevent a hang of the application, in case something goes wrong during the subprocess call. So, my intention is to check when the one shot timer elapses, if the subprocess call is still busy. If not, then all is fine and I simply ignore the time out. If the subprocess is still busy, I would like to be able to (if needed, forcefully) stop the subprocess call. I currently started the one shot timer just before I launched the subprocess call, but I see that the one shot timer is also blocked by the subprocess call. So, that doesn't do what I in fact want to do. My questions: 1. How can I decouple the subprocess call? 2. How can I forcefully stop a subprocess call (that should be the case if my one shot timer elapses after 10 seconds, and the subprocess call is not returned yet)? 3. What's the best approach to achieve the above requirements? Using a kind of a state machine, where I first start the subprocess call (decoupled), then start the one shot timer, change the state and then check in that state if the subprocess call has indeed ended? And if not, forcefully stop the subprocess call? Any practical helpful tips much appreciated! -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Add some text in QFileDialog
projet...@club-internet.fr wrote: Hello, I would like to add some informations in a TextEdit or a Label in QFileDialog to help the users to know what it must searchs. How can I do that ? Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Something like this? self.upgfile = QFileDialog.getOpenFileName(\ None, self.trUtf8(Select the UPG file), self.upgfile, self.trUtf8(*.upg), None) -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Dialogue box with hyperlink
Sundance wrote: http://spyrit.svn.sourceforge.net/viewvc/spyrit/trunk/AboutDialog.py?revision=187view=markup Basically, you use a QLabel that contains your link in HTML, and don't forget to setOpenExternalLinks( True ) on that label. Links are then opened when clicked with the user's default Web browser. That's all! Great example! Will give me lots of insight on how to write a well-structured program with lots of different features... -- -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Resizing widgets in a window.
Sandro Dutra wrote: Hi. I create a mainWindow and put some widgets in there, textEdit for example, but if I maximize the mainWindow, the textEdit don't strech with the mainWindow. I try to set the size policy of the textEdit to Expanding | Expanding and tested some other things related to size of the child widget without sucess. I'm using QtDesigner to build the interface and Eric4 to program, anyone could help me? Thanks in advance! Sandro Dutra Brazil. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Hi, Did you apply a layout to your main window in Qt Designer? If not, right-click on an empty place in the main window, select Lay out (bottom item in the context menu) and apply the horizontal layout (or vertical one, if that suites your app better). This will hook all your existing widgets to the main window and will make sure they're resized (until min/max values defined are reached) when you resize the main window. HTH, -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Dialogue box with hyperlink
Hi, Has anyone somewhere an example code of a small dialogue box which contains a hyperlink to a web site? I would like to point the user to some web site, in the confirmation dialogue I want to show. -- Best rgds, Geert *Use EcoCho http://www.ecocho.com: environmentally friendly search the internet!* ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt