Re: Python users in Stavanger, Norway?
On Sunday 03 April 2011 09:32, Austin Bingham wrote: > I'm a Python developer in Stavanger, Norway looking for other Python > users/developers/etc. who might be interested in starting a local user > group. Anyone interested? This group might actually evolve into a > general programming/computer group, depending on the mix of people, > but I think that's probably a good thing. > > I know there are a lot of computer types in the area, but there > doesn't seem to be much of a "community". I'd like to change that if > we can, so let me know if you're interested. If you manage to get something started, please update the list on the Python Wiki: http://wiki.python.org/moin/LocalUserGroups#Norway David (not in Stavanger) -- http://mail.python.org/mailman/listinfo/python-list
Re: Development tools and practices for Pythonistas
On Sunday 01 May 2011 18:11, Dietmar Schwertberger wrote: > Am 01.05.2011 02:47, schrieb Shawn Milochik: >> Look at the big two sites for open-source repositories -- github and >> bitbucket. One's git, the other Mercurial. I don't think you can go >> wrong picking either one. > > Can any of those be used from Python as a library, i.e. something like > import Hg > r = Hg.open(path) > > When I had a look at Mercurial, which is implemented in Python, > it was implemented in a way that I could not do that. It was implemented > as rather monolithic program which could be used from os.system(...) > only. After noting the warnings it contains, see the following page for a description of the Python API for Mercurial: http://mercurial.selenic.com/wiki/MercurialApi Git also has a Python API, which is fairly reasonable to use, though a bit different to the Mercurial one: http://www.samba.org/~jelmer/dulwich/ I've used both with some success. David -- http://mail.python.org/mailman/listinfo/python-list
Re: PDF Viewer
John J. Lee wrote: > Alternatively, if you feel rather adventurous, try compiling KPDF on > Windows with the free Qt3 port(s?) or Qt4, if that's arrived yet. I think you might be slightly too optimistic about getting KPDF to run natively on Windows. The project you mention does have a page describing how to run KDE 3.4 on Windows, but I think that may be taking things further than the original poster intended: http://kde-cygwin.sourceforge.net/kde3/index.php I believe someone is working on a Qt 4 renderer for Poppler, a PDF rendering library based on xpdf, so it could potentially be used in an application on Windows: http://poppler.freedesktop.org/ > If you're successful there, you still need to figure out writing KPart > plugins in Python, which certainly used to be tricky, but maybe that's > a solved problem by now... Writing KPart plugins in Python (for embedding into applications) was never all _that_ tricky; it just required some messing around with shared libraries. As it turns out, you don't need to do this if you just want to control KPDF from a client application written in Python. There are two approaches you can take (for Windows users, this is where we go off-topic): 1. Use DCOP to control two running instances of KPDF. At the simplest level, you could use the popen2 module and the "dcop" tool to control what KPDF displays. This could be integrated into a client application to varying degrees, with the application getting the window manager to do things with window placement, but it would probably end up being a lot of effort for less than the desired result. http://developer.kde.org/documentation/tutorials/ 2. Use the kparts module from PyKDE to display KPDF KParts in the client application's GUI. You can still control the KParts via their DCOP interfaces, and you can call methods on them directly to, for example, open specific URLs or add user interface elements. http://www.riverbankcomputing.co.uk/pykde/ Since I discovered how easy it was to embed KPDF like this, it makes me want to experiment more with using KParts in Python. It's already trivial to use KHTML from Python, and KParts like these could be used to create specialised tools for documentation and visualisation. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking Python script to compare two files
Tim Golden wrote: > + PDF: David Boddie's pdftools looks like about the only possibility: > (ducks as a thousand people jump on him and point out the alternatives) I might as well do that! Here are a couple of alternatives: http://www.sourceforge.net/projects/pdfplayground http://www.adaptive-enterprises.com.au/~d/software/pdffile/ Both of these are arguably more "Pythonic" than my solution, and the first is also able to write out modified files. Cameron Laird also maintains a page about PDF conversion tools: http://phaseit.net/claird/comp.text.pdf/PDF_converters.html > http://www.boddie.org.uk/david/Projects/Python/pdftools/ > > Something like this might do the business. I'm afraid I've > no idea how to determine where the line-breaks are. This > was the first time I'd used pdftools, and the fact that > I could do this much is a credit to its usability! Thanks for the compliment! The read_text method in the PDFContents class also lets you extract text from a given page in a document, but you have to remember that text in PDF files isn't always composed as a series of lines or paragraphs, and often doesn't even contain whitespace characters. David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt layout question: QScrollView and QGridLayout?
Volker Lenhardt wrote: > Phil Thompson schrieb: > > On Thursday 17 November 2005 2:56 pm, Volker Lenhardt wrote: [Using a QGridLayout in a QScrollView] > >>Is there a way to get it to work? Filling a box viewport with lots of > >>padding boxes and white space labels to establish grids is very > >>cumbersome. And I need 4 different layouts to change places. > > > > QGridLayout is not a sub-class of QWidget, which is what addChild() is > > expecting. You probably want QGrid. > > I hoped to find a more assuring answer. There's no MultiCellWidget, no > Col/RowStretching, no Col/RowSpacing in QGrid. I've got to patch up one > VBox with a whole bunch of QV/QHBoxes and QGrids not to mention the > white space QLabels to fill not used grid cells. You can still use QGridLayout, but you need to put a widget into the QScrollView in what the documentation describes as "Using One Big Widget" (http://doc.trolltech.com/3.3/qscrollview.html). Something along these lines should do basically what you want: sv = QScrollView() w = QWidget(sv.viewport()) sv.addChild(w) grid = QGridLayout(w, 3, 3) for i in range(0,3): for j in range(0,3): grid.addWidget(QLabel("(%i,%i)" % (i,j), w), i, j) Of course, the widget that contains the layout is only as large as it needs to be, so you may need to call its setMinimumSize() method if you want it to be larger. However, it's often a better idea to ensure that the child widgets have the sizes they need - their parent will then be as large as they require. Hope this helps, David -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get started in GUI Programming?
[EMAIL PROTECTED] wrote: > I am trying to learn GUI programming in Python, but have to confess I > am finding it difficult. > > I am not an experienced programmer - just someone who from time to > time writes small programs for my use. Over the years I have moved > from GWBASIC to QBASIC to Visual Basic, and now trying to move across > to a Linux platform. Python seems to be the best compromise between > the limitations of command line basic programming and the total > incomprehensibility of C. > > Googling around it seems the best GUI is either Tkinter or PyGtk. You might also want to try PyQt: http://www.riverbankcomputing.co.uk/pyqt/ I'm sure fans of wxWidgets will also point you in the direction of their favourite bindings. ;-) David -- http://mail.python.org/mailman/listinfo/python-list
Re: QCheckListItem signal question
You could connect the currentChanged() or clicked() signals in your QListView to a slot in some other object (perhaps the parent of the QListView). When the signal is emitted, you can examine the state of the item passed to the slot. Hope this helps, David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT installation /configuration
[EMAIL PROTECTED] wrote: > I've got another problem, I'm afraid - I've installed Qt 4.1.4 and PyQt > GPL v4.0 over Python 2.4, and the demos for both run happily enough, > but when I try to run the first example (in IDLE) from Boudewijn > Rempt's GUI Programming with Python: QT Edition I just get > "ImportError: No module named qt". Is there something I need to add to > my sys.path here? The module structures for PyQt3 and PyQt4 are quite different: the monolithic qt module from PyQt3 has been replaced by a number of modules in PyQt4. Despite this, there is a similar way to "import qt" in PyQt4: from PyQt4 import Qt However, you will have difficulty using the examples in that book because it was written for PyQt3. Work is underway to "port" the book to PyQt4, but it will take some time. (You can help with this and learn about PyQt4 at the same time, if you want.) In the meantime, the set of slides from a talk at EuroPython 2006 is probably the only learning material on the web for PyQt4: http://indico.cern.ch/contributionDisplay.py?contribId=33&sessionId=41&confId=44 There's plenty of learning material for Qt 4; the official documentation at http://doc.trolltech.com/4.1 contains examples and overviews that are readable if you already know C++. Those of us who use PyQt4 are still catching up! All the best, David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT installation /configuration
[EMAIL PROTECTED] wrote: > David Boddie wrote: > > > However, you will have difficulty using the examples in that book > > because it was written for PyQt3. > > Ah yes, it doesn't recognise "QApplication" now. Never mind. QApplication is still there. You can access it via the Qt module and create an application object in the following way: import sys from PyQt4 import Qt app = Qt.QApplication(sys.argv) > > Work is underway to "port" the book > > to PyQt4, but it will take some time. (You can help with this and learn > > about PyQt4 at the same time, if you want.) > > Er...you might be overestimating my potential unless there's some > *really* entry-level material to be dealt with there. Though they do > say it's a good way to learn. Is there a forum? Yes, it's at http://mats.imk.fraunhofer.de/mailman/listinfo/pykde > > There's plenty of learning material for Qt 4; the official > > documentation at http://doc.trolltech.com/4.1 contains examples > > and overviews that are readable if you already know C++. > > One of the reasons I chose Python was so I wouldn't have to, alas. Much of the example code for Qt is readable even if you only know Python. Some of the main differences between Qt and PyQt are described in this document: http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe & (Py)QT4
[EMAIL PROTECTED] wrote: > I'm having trouble using Py2exe with a PyQT-based python project. Or > possibly I'm having a problem with PyQT and Py2exe makes it apparent. > Whichever it is, I run into trouble with importing QtCore and QtGui. > The error reported is: > > Traceback (most recent call last): >File "xmlEdit.py", line 3, in ? >File "PyQt4\QtCore.pyc", line 12, in ? >File "PyQt4\QtCore.pyc", line 10, in __load > ImportError: DLL load failed: Invalid access to memory location. > > Line 10 is the import of QtCore.pyd, which is included in the dist > folder. Curiously, this is the same error I get when I input "from > PyQt4 import QtCore, QtGui" into IDLE, so I'm not even sure it's a > Py2exe issue. I'm not quite sure what the error means, only that it > isn't that the file is not found (a Module Not Found error occurs if I > remove QtCore.pyd). I don't use Windows, so I can only guess at what the problem is. Maybe the libraries that QtCore.pyd depends on aren't available, or they are in a place that the import machinery doesn't know about. > It run just fine from the command line. Can anyone shed some light on > this? QT version is 4.1.3. Python is 2.4.3 and PyQT is 4.0.1. I can only suggest looking in the py2exe Wiki: http://starship.python.net/crew/theller/moin.cgi/Py2Exe I tried searching for similar report but only found this one http://groups.google.com/group/comp.lang.python/msg/75317974fd73ea88 that might help you diagnose the problem. If you want to take this to a PyQt-related mailing list, visit http://mats.imk.fraunhofer.de/mailman/listinfo/pykde David -- http://mail.python.org/mailman/listinfo/python-list
Re: Using PyQT and OpenGL
Peter TB Brett wrote: > Although the PyQt documentation indicates that QGLWidget & friends have > been ported to Python for the PyQt bindings, I'm not entirely sure what's > necessary to make the normal OpenGL/GLUT interface available. > > Does PyQt work okay with PyOpenGL? Or is a more complicated workaround > needed? PyQt works fine with PyOpenGL. The QtOpenGL module only provides widgets and other features for use with an existing OpenGL library. It doesn't provide or expose its own OpenGL implementation. For example, you would typically subclass QGLWidget and reimplement the initializeGL(), paintGL() and resizeGL() methods to handle initialization, painting (with PyOpenGL calls) and updates to the transformation matrices. Since QGLWidget is itself a subclass of QWidget, you can use standard PyQt code to handle user input and other non-OpenGL tasks. > If anyone has experience with working with Python/Qt/OpenGL and can offer > any advice I'd much appreciate it. Take a look at the examples provided in the PyQt distribution to get started. Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: X windows and Python?
Paul Rubin wrote: > I'd like to program my Python script to put a string into the X > windows cut buffer. Can anyone suggest the simplest way to do that? > Maybe I can do it by putting up a Tkinter text widget, sticking the > string into it, and selecting it (I'm checking the docs) but uggh. > I'd prefer not to have to put anything on the screen. I just want to > put the string into the cut buffer so I can paste it into another > program. Maybe this does what you need: http://python-xlib.sourceforge.net/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: X windows and Python?
The usual follow-up to "fix" Google's "formatting". Maybe this does what you need: http://python-xlib.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Disable close button in management window.(KDE- pyQT)
Gabriel - BR wrote: > Hi,,, > Is possible disable the close button in KDE management window? Using > python+qt? Can you say exactly which window you're talking about? The "Control Center" or something else? David -- http://mail.python.org/mailman/listinfo/python-list
Re: Disable close button in management window.(KDE- pyQT)
Gabriel - BR wrote: > HI, > I am talking about the close button "X", that appears when I execute > my application (pyQt), in kde. Initially, I thought this might be possible with PyQt, just by setting the appropriate window flags when you create a widget, or with the setWFlags() method afterwards: http://doc.trolltech.com/3.3/qwidget.html#QWidget However, these flags are only hints to the window system, and you may only be able to remove the close button by removing the entire window title. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Kde Taskbar
On Saturday 07 October 2006 14:59, DarkBlue wrote: > In linux I use kmail as my email client under KDE, > if a message comes in the Kontact button in the > taskbar changes to blue. > How can I have the same behaviour in a python app ? You need to activate the window associated with the application. > I have a python script which runs nicely under linux > now every so often I want to be notified by some event, > in this case that a record has been added to a database > and I want to have the application button in the taskbar > to change color If the script is running in a console, you'll need to activate the window containing the console. I tried doing this by accessing konsole's DCOP interface, but couldn't find a suitable method to call. If you know which konsole your script is running in, you might find that you can raise the window with dcop konsole- konsole-mainwindow#1 raise where is the process ID of the konsole. This might have the effect of causing its taskbar button to change color. You can find information about the konsole from the KONSOLE_* environment variables. It would be good if konsole had a DCOP method that enabled you to activate its window, or if kicker exported an interface for the taskbar, or even if kwin had some way of letting you activate a window given its ID. Unfortunately, I couldn't find methods for any of these, so you would have to think about using PyKDE to get at this functionality. It would be good if someone could prove me wrong on any of this. ;-) David -- http://mail.python.org/mailman/listinfo/python-list
Re: Kde Taskbar
On Saturday 07 October 2006 15:41, Diez B. Roggisch wrote: > pykde afaik supports systray-iconified apps. And you could use the > dcop-mechanisms that are available as command line tools as well I > guess, and invoke knotify. I think DarkBlue wanted to affect the behaviour of the taskbar, though a system tray icon might be a reasonable alternative. > Hope this gives you some pointers - I'm currently on my mac so I can't > provide an actual example. I'd be interested in an example of how to use knotify via DCOP. A few minutes at the command line looking at the DCOP interface didn't prove particularly fruitful for me. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Kde Taskbar
On Saturday 07 October 2006 16:29, DarkBlue wrote: > David Boddie wrote: >> You need to activate the window associated with the application. [...] > My python app actually is a pythoncard app > which I hope will make things easier. If PythonCard or its underlying API has a function for activating windows, this _should_ do what you want. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Kde Taskbar
On Sunday 08 October 2006 14:16, Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, David Boddie > wrote: > >> I'd be interested in an example of how to use knotify via DCOP. > > Found a tutorial here <http://lukeplant.me.uk/articles.php?id=3>. Thanks for the link. Maybe the original poster can use something from the tutorial if the window activation trick doesn't work. David -- http://mail.python.org/mailman/listinfo/python-list
Re: python GUIs comparison (want)
On Tuesday 24 October 2006 17:38, Kevin Walzer wrote: > PyQt: > Pro: Powerful, cross-platform, sophisticated GUI's > Con: Based on C++ toolkit; That's not a bad thing in itself. > docs assume knowledge of C++; Only to a point. I knew Python before I knew C++, and it didn't stop me from learning PyQt. Think of it as an easy introduction to C++. ;-) Actually, when it comes to code snippets and examples for Qt, you only really need to perform some basic search and replace operations to get close to the same code in Python: :: maps to . -> maps to . this maps to self && maps to and || maps to or and so on. Unless you're just copying the code out of the browser, it should be fairly straightforward to follow. > commercial deployment is expensive; free deployment must be GPL; Opinions differ on the first one of these. It's a matter of perspective. > smaller development and user community than wxPython Can you back that up with some numbers? David -- http://mail.python.org/mailman/listinfo/python-list
Re: python GUIs comparison (want)
Fredrik Lundh wrote: > Christophe wrote: > > Even if you consider that the huge time saving you get out of using Qt > > is worth more than what you pay to acquire a licence? > > then it sounds like a combination between "it's a silver bullet!" and > "commercial software is better than free software!". Well, nobody's stopping you from paying the commercial license fee (to get access to support services) and releasing software under the GPL. > no matter how good Qt is, the reality is that if you spend that much > time on the UI implementation parts of your project, you're probably > developing at the wrong abstraction level -- no matter what toolkit > you're using. and if you're doing UI development the wrong way, chances > are that you're doing other things the wrong way too. You're forgetting that Qt isn't just a widget toolkit. David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt-x11-gpl-3.16 compile error
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] PyQt-x11-gpl-3.16]# python configure.py -q > /usr/lib/qt-3.3/ > This is the GPL version of PyQt 3.16 (licensed under the GNU General > Public > License) for Python 2.4.2 on linux2. [...] > Creating features file... > Error: Unable to build mkfeatures utility. Can you run the configure.py script again with the -w option as well as the others you specified, then post the output here? David -- http://mail.python.org/mailman/listinfo/python-list
Re: python GUIs comparison (want)
On Friday 27 October 2006 16:36, Magnus Lycka wrote: > David Boddie wrote: >> You're forgetting that Qt isn't just a widget toolkit. > > I suspect that the non-GUI parts are (just like in Wx) C++ stuff > which is more or less equivalent with things that are either Python > builtins or parts of Python's standard library. Besides, getting > those proprietary dependencies even further down into the code than > the GUI is not a plus in my book. It depends on who you are. If you're writing GPL applications, whether you use framework-specific classes for SQL, XML or networking (for example) is more a question of making appropriate design choices. If you're writing proprietary closed source applications, you're probably paying for the benefits those dependencies bring. One of the advantage of using Qt from Python is that you get a choice of dependencies. > Last time I looked, Qt code wasn't even pure C++ but needed some > preprocessing like embedded SQL. Yet another programming language > in other words. I suppose I can ignore that from Python, but it > still smells... You're referring to the meta-object compiler, I suppose. This has been discussed many times by people who don't have the luxury of being able to write all their code in Python; for example: http://doc.trolltech.com/4.2/templates.html http://www.scottcollins.net/articles/a-deeper-look-at-signals-and-slots.html It's a trade off that some people choose to make to take advantage of those features. Of course, Python has a perfectly good type system, so you never need to preprocess Python code when you use PyQt. David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt-x11-gpl-3.16 compile error
On Saturday 28 October 2006 06:42, [EMAIL PROTECTED] wrote: > here is th output : > > [EMAIL PROTECTED] PyQt-x11-gpl-3.16]# python configure.py -q > /usr/lib/qt-3.3/ -w [...] > Checking to see if the qtcanvas module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the qtnetwork module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the qttable module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the qtxml module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the qtgl module should be built... > In file included from cfgtest.cpp:1: > /usr/lib/qt-3.3/include/qgl.h:79:20: error: GL/gl.h: No such file or > directory > /usr/lib/qt-3.3/include/qgl.h:80:21: error: GL/glu.h: No such file or > directory > Checking to see if the qtui module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the qtsql module should be built... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Checking to see if the QAssistantClient class is available... > /usr/bin/ld: cannot find -lmng > collect2: ld returned 1 exit status > Creating features file... > /usr/bin/ld: cannot find -lXext > collect2: ld returned 1 exit status > Error: Unable to build mkfeatures utility. OK. It looks like the directory you specified using the -q option isn't the one you need. You haven't said whether you installed Qt from source, or whether it was installed with the rest of your Linux distribution. If you need to use the -q option (if the script doesn't work without it), try using /usr/share/qt3 - this works for Debian-based distributions, and may also work for other distributions. David -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Tool69 wrote: > I followed the docs to build qscintilla2, all is going well with no > errors, but when I launched the PyQt Syntax Highlighter Example, > nothing is highlighted but the first line of text, whereas the C++ > sample works well in the demo. Do you mean the example from the PyQt4 distribution? That uses a port of an old syntax highlighting example from Qt 4.0. Someone needs to "port" the C++ example from Qt 4.2 to PyQt4. The example itself doesn't actually use QScintilla2 - there used to be a demo from Qt that was converted to use QScintilla. Maybe that's been ported to PyQt as well. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Really strange behavior
Sion Arrowsmith wrote: > I don't know if this is the problem or not (knowing neither Qt nor > Twisted), but creWin() creates a window (or two) then throws it > (them?) away on returning to main() (I assume you've chopped > off the bit where main() is actually called). So it's not too > surprising your window doesn't show: by the time you get to > running anything, you don't have a window object to show. It seems to me that your analysis is correct. The first example works as expected because MainWindow is still in scope when the reactor is run. def main(): app = QtGui.QApplication(sys.argv) qt4reactor.install(app) MainWindow = QtGui.QMainWindow() win = Window(MainWindow) MainWindow.show() from twisted.internet import reactor reactor.run() However, in the second example, MainWindow is created as a local variable inside creWin() and is deleted when that function returns. def creWin(): MainWindow = QtGui.QMainWindow() win = Window(MainWindow) MainWindow.show() def main(): app = creApp() creWin() from twisted.internet import reactor reactor.run() By the time the reactor runs, there's no window (open or otherwise) so the application will never exit the Qt event loop (or whatever actually runs when Twisted is involved). > (Unless a Qt application object is a discoverable global and > windows inject a reference to themselves into it.) Well, you can access the application's instance, once it's been set up, via the qApp global variable in the PyQt4.QtGui module. However, you can't take advantage of Qt's parent-based object ownership mechanism to get round this issue with local variables because widgets need to be given QWidget parents, and QApplication is not a QWidget subclass. The original poster should either use a global MainWindow variable or encapsulate the functions in a class. David -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Tool69 wrote: > > That uses a port of an old syntax highlighting example from Qt 4.0. Someone > needs to "port" the C++ example from Qt 4.2 to PyQt4. > > So, we've got no sample to use QScintilla2 ?? Well, this should get you started: import sys from PyQt4.QtGui import QApplication from PyQt4.Qsci import QsciScintilla, QsciLexerPython if __name__ == "__main__": app = QApplication(sys.argv) editor = QsciScintilla() lexer = QsciLexerPython() editor.setLexer(lexer) editor.show() editor.setText(open("qscintilla2_example.py").read()) sys.exit(app.exec_()) QScintilla provides a selection of different lexers, so you might want to experiment with those. Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: pyqt show wizard
Yves Glodt wrote: > I have a mainwindow in my pyqt application, and on click of a button I > want to start an assistant (wizard). > > I have create the wizard with the Qt Designer, generated the python code > with pyuic, imported it "from assistant import *", and subclassed it as > usual. > > To show it, the onclick method of the button does: > > w = Wizard() > w.show() > > bot nothing happens... If this is within a method that returns immediately after the show() call, the wizard will go out of scope and be deleted. I suspect that you really want to call w.exec_loop() intead, since this will only return control to the method after the user has finished interacting with the wizard. Take a look at the QWizard documentation for more information: http://doc.trolltech.com/3.3/qwizard.html David -- http://mail.python.org/mailman/listinfo/python-list
Re: pyqt show wizard
Summary of the usual mess made by the Google Groups web interface: I suspect that you really want to call w.exec_loop() instead, since this will only return control to the method after the user has finished interacting with the wizard. Take a look at the QWizard documentation for more information: http://doc.trolltech.com/3.3/qwizard.html David -- http://mail.python.org/mailman/listinfo/python-list
Re: convert .pdf files to .txt files
Davor wrote: > Hi, my name is david. > I need to read information from .pdf files and convert to .txt files, > and I have to do this on python, > I have been looking for libraries on python and the pdftools seems to > be the solution, but I do not know how to use them well, > this is the example that I found on the internet is: [...] > for n_page in range (1, (n_pages+1)): >print "Page", n_page >page = doc.read_page (n_page) >contents = page.read_contents ().contents >text.extend (contents_to_text (contents)) > > print "".join (text) > > the problem is that on some pdf´s it generates join words and In > spanish the "acentos" > in words like: "camión" goes to --> cami/86n or > "IMPLEMENTACIÓN" -> "IMPLEMENTACI?" give strange > characters pdftools just extracts the textual data in the file and stores it in Text instances - it doesn't try to interpret or decode the text. I'd like to fix the library so that it does try and decode the text properly and put it into unicode strings, but I don't have the time right now. Remember that text can be stored in PDF files in many different ways, and that the text cannot always be extracted in its original form. > if someone knows how to use the pdftools and can help me it makes me > very happy. > > Another thing is that I can see the letters readden from .pdf on the > screen, but I do not know how to create a file and save this > information inside the file a .txt You need to do something like this: f = open("myfilename", "w").write("".join (text)) > Sorry for my english. Don't worry about it. It's much better than my Spanish will ever be. Sorry I couldn't give you more help with this. You may find that the other tools mentioned by people in this thread will do what you need better than pdftools can at the moment. David -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing of python GUI´s
Bayazee wrote: > i want some info ... > plz tell me the benefit (or any data) of each gui (pyqt , pyqtk , > wxpython , tkinter ..) > in the other hand wich one you offer (and why ?) ? Take a look at these resources: http://wiki.python.org/moin/GuiProgramming http://www.awaretek.com/toolkits.html The last one will be especially useful in helping you make some kind of informed decision. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Drag and Drop with PyQt4
Harshad wrote: > When I run the program, DragEnterEvent works as expected, but the > DropEvent does not seem to be working. I'm not an experienced Python > hacker, and am unable to trace out any problems with the source code. > Any and all help will be appreciated! I'm making an educated guess from memory, but I think you need to implement your own dragMoveEvent() method and accept the event there as well. This is because the item view widgets typically like to handle all aspects of drag and drop, and QListView (from which QListWidget is derived) ignores drag move events by default. So, if you want to change the behaviour in a fundamental way, you need to handle many aspects of the process; in this case, you need to provide your own dragEnterEvent(), dragMoveEvent() and dropEvent() methods. These can be simple, as shown in the following example: class ListWidget(QListWidget): def __init__(self, parent = None): QListWidget.__init__(self, parent) self.setAcceptDrops(True) def dragEnterEvent(self, event): event.acceptProposedAction() def dragMoveEvent(self, event): event.acceptProposedAction() def dropEvent(self, event): print "Drop" event.accept() listWidget = ListWidget() listWidget.show() I tested this code with Python 2.4.2, Qt 4.1.4 and PyQt 4.1, and I think you should be able to do the same in your code. Two other points: 1. If you are prepared to try Qt's model/view classes, you can exert more control over the way drag and drop is handled. They're not quite as straightforward as the item-based classes that you're already using, but you benefit from greater reusability of your components and better control over the appearance and behaviour of the view widgets. This guide is for C++, but it translates fairly well into Python: http://doc.trolltech.com/4.1/model-view-programming.html 2. You seem to prefer adding methods to specific instances rather than subclassing and reimplementing methods in the base class. I hope you don't mind me asking, but is that because it takes less code, because you find it conceptually easier, or is there another reason that I'm missing? David -- http://mail.python.org/mailman/listinfo/python-list
Re: models & editors in PyQt4
Skink wrote: > I created simple property classes with editing option, but since i'm not > too much experienced in PyQt4 i'd like to ask if i handle ColorProperty > changing right. Any other Property has its own editor and their control > flow is imho ok. Hovewer i'm not sure about ColorProperty. > > What i do is: in createEditor(self, parent, option, index) i call > QtGui.QColorDialog.getColor() and return None > > What do you think? Is it Ok? It should be OK - it shouldn't crash, anyway. It depends on the view doing the right thing when it finds that it hasn't received an editor widget. You could create an empty placeholder widget in the createEditor() method, call QColorDialog.getColor() with the existing color from the model in setEditorData(), record the color returned by the dialog in some internal instance variable, and finally set the data in the model when setModelData() is called: class ColorProperty(Property): ... def createEditor(self, parent, option, index): return QtGui.QWidget(parent) def setEditorData(self, editor, index): self.color = QtGui.QColorDialog.getColor( index.model().getObjectData(self.name())) def setModelData(self, editor, model, index): if self.color.isValid(): index.model().setObjectData(self.name(), self.color) ... I find it strange that you have to triple-click to edit any of the items in your example. Do you see the same behaviour? David -- http://mail.python.org/mailman/listinfo/python-list
Re: models & editors in PyQt4
Skink wrote: > David Boddie wrote: > > I find it strange that you have to triple-click to edit any of the > > items in your example. Do you see the same behaviour? > oh, this is default Qt behavoiur: first click selects row, second select > editor (for ColorProperty, IntProperty & StringProperty you can now > change the value) but third click is required only for properties w/ > QCombobox editor (EnumProperty & BooleanProperty) ... It seemed that, even if the row was already selected, it took more than a double click to start editing. I'll have to take another look at it. David -- http://mail.python.org/mailman/listinfo/python-list
Re: any portable way to print? (and i mean on a printer)
Steve Holden wrote: > Liquid Snake wrote: > > I think my question is clear.., is there any way to print any text on a > > portable way?..., and actually, i don't know how to print at all.., just > > give me some pointers, name a module, and i can investigate for myself.. > > sorry for my english, thanks in advance.. > > ps: i prefer a Standard Library module. > No, there is no way to print any text (did yo also want to print > graphics?) portably (by which I mean a way that will work on Windows, > Linux, Solaris, HP-UX, AIX, ...). Well, that's not quite true, Steve. Python bindings for various cross-platform frameworks should manage this quite well, depending on what the original poster meant by text. PyQt4, for example, provides classes that let you print to native printers on Linux, Mac OS X, Windows and various other Unix platforms: http://www.riverbankcomputing.co.uk/pyqt/ However, the original poster did specify a preference for a standard library module, so your answer is probably correct within that context. :-) If the printer was a network printer, there might be some more options to explore. I think there's potential for a pure Python solution to this problem to be added to the desktop module: http://cheeseshop.python.org/pypi/desktop/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: evaluating gui modules, any experience on tkinter?
krishnakant Mane wrote: > I seam to have noticed this a bit late but it appears to me that > tkinter is being used very widely for gui development on all platform? > is that right? Tkinter is bundled with Python on all platforms that support Tcl/Tk. As a result there's a low "barrier to entry" to Tkinter programming, so people tend to use it, at least when they start with GUI development. > 3. I don't know if I need any thing else as dependencies on my > windows machine. I am using python24 and I did not find any thing > about installation in the introduction to tkinter. can some one give > me the process of installing tkinter and all necessary things? It's been a long time since I installed Python on Windows, and I think I used ActivePython: http://www.activestate.com/Products/ActivePython/ I believe that this package includes Tkinter, so you shouldn't have to do anything else to install it. > so I am confused between wxpython pyqt and now tkinter. > out of the 3 I only found qt talking extencively about accessibility, > but did not find a way to install qt in the first place. I could not > compile qt nor did I find any run-time dlls for mingw so that I can > use it out of the box. I believe there should be a package which includes pre-built Qt libraries as well as source code, all licensed under the GNU GPL. It may not help you get started with MinGW, though the information on the download page indicates that the package "will also download and install the MinGW compiler, if needed". Take a look at the following page for more information: http://www.trolltech.com/developer/downloads/qt/windows If you're unable to license your own code under the GNU GPL then you'll have to look at commercial licenses for Qt and PyQt. David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt, designer, and directional flow
borntonetwork wrote: > I am creating a simple form using designer (qt4) on Ubuntu. I use pyuic > to create a python script from the form. I run the script and the form > shows up fine. The idiosyncrasy occurs when I try to type text into a > QTextEntry widget. The text is right-aligned, not left-aligned as I had > set it up in the property editor in designer. > > This behavior is not limited to alignment in text fields. If I insert a > QTableWidget and add items to it, the items appear from right to left, > not left to right. For example, if I create a 4-column table and use > setItem() to insert the numbers 1, 2, 3, and 4 into columns 0, 1, 2, 3 > respectively, I get this: > > 4 3 2 1 > > The same thing goes with the headers. I create a QStringList ("1", "2", > "3", "4") and add it using setHorizontalHeaderLabels() then the headers > show up as 4 3 2 1. This sounds like something to do with right-to-left layouts for internationalisation rather than just "normal" right-aligned text and layouts. > This is my first qt app using python instead of C++, so I may be doing > something wrong. Not necessarily, though we should probably run through some checks. :-) * Do Qt applications written in C++ work fine on your system? * Is your system configured to use a right-to-left language, such as Arabic or Hebrew? * Have you tried previewing the form in Qt Designer and entering text, just to see if it behaves the same way there? > I am grateful for any ideas someone might have. Well, it sounds like a strange bug or configuration issue, but we can probably figure out what's happening. David -- http://mail.python.org/mailman/listinfo/python-list
Re: I'm looking to learn pyqt
vj wrote: > Is there a a tutorial or a sample application I can start with (that > works with qt4 and pyqt4)? PyQt4 is distributed with a set of small examples, mostly ported from the C++ ones supplied with Qt. Other than those, you could take a look at the PyQt and PyKDE Wiki for inspiration: http://www.diotavelli.net/PyQtWiki There's a page on there with a list of existing applications, some of which are based on PyQt4. As always, more helpful advice can be found on the PyKDE mailing list, where PyQt questions are also welcome: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde David -- http://mail.python.org/mailman/listinfo/python-list
Re: Using DCOP from Python
Jeffrey Barish wrote: > The package python-dcop makes it possible to use DCOP from Python. Does > anyone know of a tutorial for this package or an example of its use? I > would like to use it to read a journal entry in Korganizer. I got as far > as figuring out that DCOP offers the interface > korganizer.CalendarIface.openJournalEditor(QString text, QDate date) > but I'm having trouble figuring out how to call this function from Python. > And will it become clear how to control whether I am reading or writing the > journal? You might find an answer in the archives of the PyKDE mailing list: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde There are probably people reading that list who can give you hints and tips, at the very least. You might also want to take a look at the documentation at http://www.riverbankcomputing.com/Docs/PyKDE3/dcopext.html This may be enough to get you started. David -- http://mail.python.org/mailman/listinfo/python-list
Re: cross-compiling python: reviewers needed
Han-Wen Nienhuys wrote: > I have a small patch for Python SVN that makes it possible to > cross-compile python on Unix to various other Unix targets. > I have successfully built a binary for FreeBSD on Linux. > > The patch is available at > https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1597850&group_id=5470 > > (file cross.patch) > > but it awaits further review. > > I'm looking for people willing to try this out, and give further > review to the patch, so it may be applied to SVN. > > All you need is a bit of time, and experience in cross-compiling. For various reasons, I don't have the time or resources to really look at your patch in any detail. I was only able to quickly look through it and see how you did certain things, such as specifying a Python build interpreter and splitting up pgen's build rules. I modified the build system in a similar way, so it was reassuring to see similar solutions. Some comments: I noticed that you define a CROSS_COMPILING environment variable so that you know when to use the right tools. Is this a standard variable name in other projects that allow cross-compilation? You rely on an existing Python installation on the build machine. Does this influence the configuration process, or the availability of non-pure Python extension modules? Does the configuration process still cause the tests to be built for the build machine? This seems like a redundant step: ideally, the tests would be run on the target machine in a separate step. The above points are only observations, though. The patch looks like a good first step towards a more configurable build system for Python. It would be even better if, in the future, separate patches could enable custom builds as well. This would, for example, allow minimal Python distributions to be made by stripping out lots of modules that are unavailable or unsuitable for use on embedded hardware. David -- http://mail.python.org/mailman/listinfo/python-list
Re: KPanelApplet using Python
Varun Hiremath wrote: > I was wondering if there is any way to make KDE PanelApplets > using Python. I have made a small window using Qt, kdeui nad > kdecore libs. Now I want to add it to the KDE kicker. Can I > get any help regarding this matter. The other responses in this thread have covered solutions that use the system tray, and you may want to try something like that with the KSystemTray class in kdeui. It's available in PyKDE, so you shouldn't have any trouble adding new items to kicker that way. However, you asked specifically about Panel Applets. Unfortunately, they are a lot more difficult to implement in Python because you need to write a library in C++ to load them. Some of us in the PyQt/PyKDE community did some work towards that, and had working applets but, as far as I know, they don't work with recent releases. You might get some additional help or advice about this if you try mailing the PyKDE list: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a file
Jeremy Sanders wrote: > Fabian Steiner wrote: > > > Unfortunately I don't know how to realize this, since also some images > > and different boxes should be printed out. As the whole application is > > based on QT, QPrinter might be used, but I couldn't find any examples > > how to use it. [...] > It's very easy to do. If you want to handle multiple pages and so on, > there's a bit of work to do to interface to the dialog to get the > user-selected page range, etc. That's where QPrintDialog comes in: http://doc.trolltech.com/4.1/qprintdialog.html It's also secretly available in Qt 3 via the QPrinter.setup() method: printer = QPrinter() printer.setup() # Now, paint onto the printer as usual. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a file
Fabian Steiner wrote: > This is what I have so far: > > app = QApplication(sys.argv) > printer = QPrinter(QPrinter.PrinterResolution) > if printer.setup(): > printer.setPageSize(printer.A4) > painter = QPainter(printer) > metrics = QPaintDeviceMetrics(painter.device()) > marginHeight = 6 > marginWidth = 8 > body = QRect(marginWidth, marginHeight, metrics.widthMM() - 2 * > marginWidth, metrics.heightMM() - 2 * marginHeight) > painter.drawRect(body) > painter.end() > > Doing so I hoped to get a rectangle which is as big as an A4 paper (with > a small border), but unfortunately it is much smaller. Surely you meant to use body = QRect(marginWidth, marginHeight, metrics.width() - 2 * marginWidth, metrics.height() - 2 * marginHeight) > Moreover, I ask myself whether it is necessary that in order to write > text on the paper, I always have to pass the proper x, y values to > QPainter.drawText(). > Isn't there any other possibility? How do I get these values? That depends on what kind of text you're drawing (paragraphs of text vs. simple labels). See the application.py example in the examples3 directory of the PyQt3 distribution for code that implements a simple text editor with support for printing. Information about text and font metrics can be found with the QFontMetrics class: http://doc.trolltech.com/3.3/qfontmetrics.html PyQt4 supports Qt 4's new rich text facilities, so it's easier to format text for printing than it is in Qt 3. A more advanced rich text editor is only available in the C++ Qt 4 demos, but there are other examples bundled with PyQt4 that show how to print "simple" documents: http://www.riverbankcomputing.co.uk/ Finally, it's worth pointing out that there's a higher concentration of people with experience in these matters reading the PyQt/PyKDE mailing list: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde Good luck with your printing, David -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a file
Sorry about that. I must have just skipped over the setup() call in your code. If you're creating highly customized content then I think you'll always need to think about getting the pages to the printer in the right order. For rich text documents, there's code that does this in the Qt 3 text drawing demo (see the filePrint() method in the examples/demo/textdrawing/textedit.cpp file). In Qt 4, the demos/textedit demo does this with a lot less code. Or are you think of something else? David -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing a file
Fabian Steiner wrote: > David Boddie wrote: > > In Qt 4, the demos/textedit demo does this with a lot less code. > > > > Or are you think of something else? > > Thank you very much for this hint! Thanks to this example I was able to > print out my first pages :) That's good to hear. :-) > But some questions still remain. At the moment I am using > QSimpleRichtext and a personal HTML-File. I had a look at the > example.html of textedit.cpp (/usr/share/doc/qt-4.1.1/demos/textedit) > and found out that it contains quite a lot of proprietary HTML elements, > attributes and CSS style definitions. So far I didn't even know that > QSimpleRichText even supports CSS since I couldn't find anything related > to this point in the official docs (--> e.g. QStylesheet). I think I may have confused you by mentioning Qt 4. Since you are using QSimpleRichText, you must be using Qt 3, so you should probably ignore what I said about the /usr/share/doc/qt-4.1.1/demos/textedit demo. :-/ > Is there any tool out there with which I can write those special HTML > files? I am quite familiar with HTML and CSS but I don't want to waste > my time with that. You don't need to include all those style attributes in the HTML. Anyway, that's a different version of Qt to the one you are using, so you can safely ignore it. You should probably look at the text drawing part of the demo included in Qt 3 (examples/demo/textdrawing) and see how printing is done for the rich text editor there (in the TextEdit::filePrint() function). Translating it to Python _shouldn't_ be a problem. I hope I didn't confuse you too much by talking about two different versions of Qt at the same time. Let us know how it goes. David -- http://mail.python.org/mailman/listinfo/python-list
Re: scripting browsers from Python
Michele Simionato wrote: > This looks interesting, but I need an example here. What would be the > command to open Konqueror to a given page and to post a form with given > parameters? Launch Konqueror, note the process ID (pid), and use the dcop command line tool to open the page at a specified URL: dcop konqueror- konqueror-mainwindow#1 openURL Unfortunately, I don't think it's possible to manipulate the page purely with DCOP, even with Python bindings, although I hope that someone can prove me wrong. > kde.org has tons a material, but I am getting lost and I don't find > anything relevant to my simple problem. A quick search revealed this discussion about using JavaScript with DCOP: http://lists.kde.org/?l=kfm-devel&m=103661664427286&w=2 This might be the best you can hope for with scripting outside the browser. I've been trying to enable support for in-browser scripting with Konqueror using KPart plugins, but this requires up to date versions of sip, PyQt and PyKDE: http://www.riverbankcomputing.co.uk If you want to pursue that route, let me know and I'll try and tidy up what I have. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Questions about mathematical and statistical functionality in Python
On Fri Jun 15 03:08:08 CEST 2007, Josh Gilbert wrote: > In a similar vein, I wish there was a reasonable Free Software equivalent to > Spotfire. The closest I've found (and they're nowhere near as good) are > Orange (http://www.ailab.si/orange) and WEKA > (http://www.cs.waikato.ac.nz/ml/weka/). Orange is written in Python, but its > tied to QT 2.x as the 3.x series was not available on Windows under the GPL. It should be possible to get Orange working with Qt 4, which is available under the GPL on Windows, but it could take some work to update some of the more specialized components to use the latest classes. On a positive note, there should be enough information available to help with the "porting" process, and the updated components would be able to take advantage of the improvements made to Qt and PyQt since Qt 2 was released! David -- http://mail.python.org/mailman/listinfo/python-list
Re: how to query/test the state of a qt widget?
On Sun Jun 24 02:20:55 CEST 2007, raacampbell wrote: > I'm writing a simple Python/Qt3 application and I am trying to write > some code in which the user presses a button and the program performs > action A or B depending upon the state of a pair of radio buttons. You would typically connect the button's clicked() signal to a function or method and perform the actions there. Since I don't know exactly what you are doing, I can't give you an exact answer, but you probably want to write something like this: self.connect(self.pushButton, SIGNAL("clicked()"), self.perform_action) This assumes that you're calling connect() from a QObject subclass. If not, you could call connect() on the button itself. > I would therefore like Python to read the state of the buttons. I was > expecting this to be straightforward but I've not been able to work > out how to do it and searching on Google hasn't helped. Surely there's > a one-liner that will do what I want? It seems like an every-day sort > of problem. I'm after something like: > > if self.polPlotRadioButton.enabled==1: print "BLAH" This is more or less what you would write in the method that gets invoked when the clicked() signal is emitted, though you would need to call enabled() since it's a method and not an attribute. > I've found squish from www.froglogic.com but that seems over the top. > Possibly pythonqt.sourceforge.net has something that will solve my > problem but that wants Qt4 and at the moment I'm making heavy use of > matplotlib widgets and I've not worked out how to get them to > incorporate into a Qt4 app so I'm stuck with Qt3. It's been a while since I've looked at using matplotlib with PyQt. Looking at the 0.90.1 release, it seems that there is support for PyQt4, so maybe you'll get what you need if you upgrade to that. I don't think you need Squish for this - it's a tool for automated user interface testing, and you're not doing that as far as I can tell. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Memory leak in PyQt application
On Thu Jun 28 19:21:36 CEST 2007, Alexander Eisenhuth wrote: > I've a memory leak in a PyQt application and no idea how to find it. What > happens in the application ? > > From QWindow a QDialog is called on a button "pressed()" signal, that > instantiate a QThread and waits for it. If the thread has finished, the > QDialog closes. Do you delete the dialog when you close it? Did you create it with a parent object? > I've stipped down everything that nothing more happens (to me obviously). > Boost.Python is used to wrap a C++ Lib (used in the thread). Every time > memory usage increases for ~70 KB. > > Sometimes the application crash on closing QWindow. (QtCore.dll) > > - One thing I ask me is weather garbage collection is done in the PyQt main > loop? Some objects will be garbage collected but others may will be kept around if they are used from C++. > What hints do you have to find the leak? You may need to show us some of your code so that we can see exactly what you're doing. If you can post the stripped down example you have here, we can take a look at it. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-URL! - weekly Python news and links (Jul 16)
On Wed Jul 18 23:20:51 CEST 2007, Cameron Laird wrote: > Kay Schluehr wrote: > > >Not sure if it's important enough to be mentioned in weekly Python > >news but Europython 2007 actually happened and took place in Vilnius. > > *I* sure think it's important; is there a summary or narrative > from the event you recommend? I've started to collect reports, photos and videos from the conference on the relevant PythonInfo Wiki page: http://wiki.python.org/moin/EuroPython2007 There's no definitive report out there, as far as I can tell. I imagine that everyone is getting their strength back after a week of talks, hacking, sightseeing and socialising. :-) David -- http://mail.python.org/mailman/listinfo/python-list
Re: PYQT 3 communication with 2 windows
On Thursday 19 April 2007 22:38, Marcpp wrote: > Hi, I'm introducing to program in python + pyqt. > I have a main window that call a second window (to introduce a info > with textedit) > when press the second window button I need to return to the main > window the info > introduced in the second window. > I've seek in the pyqt doc examples but i don't find it. > Have you any example? You could connect the button to a slot in the second window that sends the text back to the first window. Here's an example that sends the text to a function. You could substitute a class for the function to get what you want. import sys from qt import * class Window(QWidget): def __init__(self, parent = None): QWidget.__init__(self, parent) self.textEdit = QTextEdit(self) okButton = QPushButton(self.tr("&OK"), self) self.connect(okButton, SIGNAL("clicked()"), self.sendText) layout = QVBoxLayout(self) layout.addWidget(self.textEdit) layout.addWidget(okButton) def sendText(self): self.emit(PYSIGNAL("textEntered(QString)"), (self.textEdit.text(),)) def fn(text): print text if __name__ == "__main__": app = QApplication(sys.argv) window = Window() window.connect(window, PYSIGNAL("textEntered(QString)"), fn) window.show() app.setMainWidget(window) sys.exit(app.exec_loop()) Note the use of PYSIGNAL() instead of SIGNAL(). With PyQt4 you would be able to use SIGNAL() and write the emit() call in a simpler form. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
On Thursday 19 April 2007 00:50, Glen wrote: > What seems to be happening is that the font that pyqt is using is not > fixed width, so I did this: > qTxtFormat = QTextCharFormat() > qTxtFormat.setFontFixedPitch(True) > ui.textEdit.setCurrentCharFormat(qTxtFormat) It may be that the font you're using isn't actually a monospaced font. The result of this is that the font used to display the text won't be a fixed pitch font. To test this, try specifying a known monospaced font and see if you get the output you expect. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Simple Output to a Dialog PyQt4
On Tuesday 17 April 2007 07:42, Glen wrote: > I've written a script in python and put together a simple QFrame with a > QTextBrowser with Designer. I've translated the C++ into python using > puic4. Just to avoid any misunderstanding: the form is actually stored as XML. You can create C++ code with uic or Python code with pyuic4. > The .py file is called outputWin.py. My Script and its > functions are in cnt.py. OK. Ideally, your window will contain a button (or some other control) that the user can click to execute the functions. > Finally, my main is in pball.py which follows > here: > import sys > from PyQt4 import Qt, QtCore > from outputWin import * > from cnt import * > if __name__ == "__main__": > app = Qt.QApplication(sys.argv) > window = Qt.QDialog() > ui = Ui_Dialog() > ui.setupUi(window) > window.show() > app.exec_() > > I want to call my functions in cnt and have an output to my QDialog. Can > somebody give me a clue as to how to proceed? I can't find good an easy > tutorial for PyQt4 and I've never used Qt before. If, for example, you included a push button (QPushButton) in the form you created with Qt Designer, and called it executeButton, you could connect its clicked() signal to a function in cnt by including the following line after setting up the user interface: window.connect(ui.executeButton, SIGNAL("clicked()"), cnt.myFunction) This assumes that your function is called myFunction(), of course. However, you wouldn't be able to get the output from this function back to the dialog just by using a signal-slot connection like this. One way to solve this would be to wrap the function using another function or instance that is able to modify the contents of the dialog. Another cleaner approach would be to subclass the user interface class (Ui_Dialog) and implement a custom slot that can both call the function and modify the dialog. For example: class Dialog(QDialog, Ui_Dialog) def __init__(self, parent = None): QDialog.__init__(self, parent) self.setupUi(self) self.connect(self.executeButton, SIGNAL("clicked()"), self.callFunction) def callFunction(self): data = cnt.myFunction() # Do something with the data. Hope this gets you started, David -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate report containing pdf or ps figures?
On Tuesday 24 April 2007 20:42, Cameron Laird wrote: > I want to make sure we're all keeping up with each other, so > I'll make explicit a couple of points, despite the risk of > redundancy: > A. Bundling GS is a little touchy, depending on > what you mean by that. Check out its license. > My summary: it's feasible, but not as trans- > parent as the technology in isolation might > suggest. I'm surprised you don't have more suggestions, Cameron, given that you collect links to PDF convertors. ;-) http://phaseit.net/claird/comp.text.pdf/PDF_converters.html > B. As Steve's already noted, the for-fee ReportLab > *does* (at least some of) the things you want. Another interesting approach might be to look at other members of ReportLab's family tree: http://sping.sourceforge.net/ http://sping.sourceforge.net/notesPDF/index.html However, it doesn't seem that either are capable of inserting the kinds of vector files you are using. It may be worth writing a quick and dirty PDF writer using an existing backend library, though I can imagine that the hard work would involve reading the different input formats you want to use. Anyway, for future reference, the following projects might prove to be inspiring: http://pyx.sourceforge.net/ http://pybrary.net/pyPdf/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: Do other Python GUI toolkits require this?
On Monday 23 April 2007 15:55, Kevin Walzer wrote: > I had originally thought that learning PyObjC might preclude me from > having to learn Objective-C, but that seems not to be the case. I have > previously found the same to be true with PyQt and wxPython--not knowing > the toolkits as they are implemented in C++ is a serious handicap. I'm not so sure about that. Certainly, it's useful to be able to read C++ example code, but none of the examples you see should require more than a basic proficiency in C++. I started using PyQt before I had more than basic C++ skills, and I don't think it slowed me down too much. > I've even found this to be the case with Tkinter: understanding the Tcl > implementation of Tk (which I do, because I am also a Tcl developer) is > a huge advantage. > > Am I wrong to conclude that, if you want to do GUI programming in > Python, then some level of proficiency with another language is not just > recommended, but almost required? This is the case at least in my > experience. When I first started learning Python a couple of years ago, > I spun my wheels with it for months, because I couldn't figure out where > to get started with GUI programming. Of the common toolkits and frameworks, I started using Tkinter because that's what came with Python, but I can't say that I'm comfortable with it. Once I started using PyQt, I started to forget Tkinter, and now I don't have a reason to go back to using it. > Finally I set Python aside and took > up Tcl/Tk for awhile--its simplicity in building GUI's is more > beginner-friendly. (No "there's more than one way to do it"--there's > only one way to do it, and that's Tk.) > > Now, coming back to Python with the Tk model of GUI development burned > in my brain, I appreciate the breadth of functions that Python > supports--but I still find myself "dropping down into Tcl" (!) to > assemble elements of my GUI's--either to write a Python wrapper, or > figure out how to implement something in pure Python. While this is one of the strengths of Tcl/Tk/Tkinter, I think this is a relatively rare thing to do with other toolkits and frameworks. For example, there are people writing wrappers around Qt-based classes, but the only people writing wrappers for Qt or KDE classes are the bindings authors themselves. > I understand the argument for Python having lots of bindings to > different GUI toolkits. If you are already proficient with a GUI toolkit > in a compiled language (Gtk, wxWidgets, Cocoa, Qt) then presumably > switching to Python will speed up your development--learning Python is > easy if you already know C++, for instance, and usually the Python > bindings are just a "thin wrapper" over the compiled bits. Yes and no. The bindings may be thin, but there are often other advantages that make the bindings subtly different/better to use than the underlying toolkit/framework. :-) >From memory, PyGTK is more natural to use the GTK+ on its own because Python provides the object-oriented features that you don't get in C, though there are C++ bindings to GTK+ as well. Another example would be the way PyQt handles Qt's signals and slots. In C++ you need to declare these with specific signatures at compile time, but that would be a bit restrictive in Python. The result is that PyQt lets you define and connect arbitrary signals, slots and normal Python methods at run-time. (Actually, you don't even need to define signals.) So, even the thin wrappers contain some value other than simply enabling you to use Python. :-) > But if you come to Python from the other direction--you're a relative > beginner and you want to learn GUI programming without the complexities of > compiled languages--then it's a lot harder to get started, ironically. > Even Tkinter is a challenge for someone who doesn't know Tcl. The basics > are easy enough--buttons, menus, labels, images--but doing anything > sophisticated, such as trees, column views, drag-and-drop, and so on, > requires extensions that may or may not be implemented in Python. I think that's a specific Tkinter problem in many ways. However, the expectations of many new users have also increased since I wrote my first GUI program in Python, and that also influences the way people respond to the different solutions on offer. David -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI tutorial
On May 14, 2:57 am, BartlebyScrivener <[EMAIL PROTECTED]> wrote: > On May 13, 12:51 pm, John K Masters <[EMAIL PROTECTED]> > wrote: > > > Can someone point me in the direction of a good tutorial on programming > > python with a GUI? > > Alan Gauld added a gui programming tutorial to his main course. > > http://www.freenetpages.co.uk/hp/alan.gauld/ > > It's a frame page so I can't link directly, but select "GUI > Programming" under Advanced Topics on the left. It may be worth pointing out that the information about licensing on that page is a little vague and inaccurate in places. PyGTK is actually licensed under the GNU LGPL, not the GPL, and both PyQt and PyGTK can be used to create commercial applications as long as those applications are not closed source. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Distributing programs depending on third party modules.
On May 16, 7:44 am, Tina I <[EMAIL PROTECTED]> wrote: > A binary would be ideal. I'll look into the freeze modules and > Pyinstaller. Even if they don't handle huge things like Qt it would be a > step in the right direction if it handles smaller third part modules. > And maybe the smartest thing to do would be to dump PyQt and just > go for tkinter, however ugly it is :/ It's may be worth reading this message before making such a drastic decision: http://www.riverbankcomputing.com/pipermail/pyqt/2007-May/016092.html David ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: No Python for Blackberry?
On Saturday 19 May 2007 03:19, walterbyrd wrote: > I could not find a version of Python that runs on a Blackberrry. > > I'm just amazed. A fairly popular platform, and no Python > implementation? If you can get the hardware into the hands of capable developers, they'll put Python on it. ;-) David -- http://mail.python.org/mailman/listinfo/python-list
Re: Scope PyQt question
On Thu Jul 26 18:00:44 CEST 2007, dittonamed wrote: > On Jul 26, 10:15 pm, Stargaming wrote: > > Answering from a non-Qt point of view (ie. I don't know if there were > > cleaner ways using Qt stuff), you have to bind p somewhere not local to > > the function. Any attribute of `self` (that's hopefully not used by > > QMainWindow) should be fine. [...] > I was having trouble getting that to work and thought it because of > event driven nature of gui/qt programming. But i'll give it another go > anyway .. any examples? ;-) from qt import * class Form2(QMainWindow): def __init__(self,parent = None,name = None,fl = 0): QMainWindow.__init__(self,parent,name,fl) self.statusBar() def playAudio(self): self.p = QProcess(self, 'player') playcmd = '/usr/bin/play' filename = 'song.ogg' self.p.addArgument(playcmd) self.p.addArgument(filename) self.p.start() def stopAudio(self): self.p.kill() > Im wondering what the "right" way to do this is - the Qt way, or is > what you mentioned in fact the "right" way? Can i access the QObject > another way or am i barking up the wrong tree? If you store the process in the instance of Form2, you don't need to access it via the object tree. Most Qt programs (in C++) would also use the same approach. You _can_ access the process via the object tree, as you discovered - it's just less convenient to do it that way. Just to satisfy your curiosity, let's look at your code again: ''' #This is just to show that i can "see" the object, though i #dont know how to "access" it #the output shows the QProcess object by name... # but how do i reference it?? allobjs = list(QObject.objectTrees()) for obj in allobjs: objName = QObject.name(obj) if objName == 'Form2': print QObject.children(obj) ''' When you obtain the Form2 instance, you could inspect its children, testing whether each one is a QProcess object with either Python's isinstance() function or QObject's inherits() method. Alternatively, you could use QObject's queryList() method or the qt_find_obj_child() function. With PyQt4, QObject has a findChild() method to perform these kinds of searches. Still, I'd recommend just keeping a reference to the process in your Form2 instance. David -- http://mail.python.org/mailman/listinfo/python-list
Re: [python-list] pdf read & write
On Fri Jul 27 15:35:02 CEST 2007, Hyunchul Kim wrote: > How can I read a pdf file and add invisible comment? > I want to make a script which read a pdf file and add tags inside the > file invisibly. Then, I will make a script for managing tags of given > pdf files. > > I know "referencer" can manage tags for pdf file but it seems store tag > information to additional file outside pdf file. > > Any suggestion are welcome. pyPdf may do some or all of what you are asking for: http://pybrary.net/pyPdf/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: Best programs written completly in Python
On Sun Aug 5 14:44:55 CEST 2007, Franz Steinhäusler wrote: > I'm only interested to have a list, or even help to > extend an existing one. If the main criterion is that the programs are written in Python then surely the PythonInfo Wiki is the place for such a list: http://wiki.python.org/moin/Applications May I suggest that you extend this one? David -- http://mail.python.org/mailman/listinfo/python-list
Re: Adventure-Engines in Python
On Mon Aug 13 11:33:14 CEST 2007, Wildemar Wildenburger wrote: > Are there any? > > I've set out to make an adventure game and now I'm trying to find a set > of python-modules to help me do that. I know of the usual non-python > suspects (AGAST, AGS, Wintermute, ...) and while I they are really good, > I'd like one that is cross platform. > > I've found pyScumm and pyAdv but both don't seem to be ready for use > yet. So are there any "usable" engines written in python? It's been a while since I looked at anything like this, but I seem to remember two Python powered engines: PAWS and PUB. http://py-universe.sourceforge.net/ http://members.nuvox.net/~zt.wolf/PAWS.htm If you want to write adventures with more graphics and less text, you could do worse than looking at existing projects and solutions written with Pygame: http://www.pygame.org/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: Co-developers wanted: document markup language
On Fri Aug 24 11:04:33 CEST 2007, Torsten Bronger wrote: > Paul Rubin writes: > > > TeX/LateX have been around forever and are well established > > standards, as awful as they are. Why do we want ANOTHER markup > > language? > > Well, because they are awful. ;-) I don't see that there is a > bunch of already existing projects, in fact, I don't see anyone > challenging LaTeX at all. However, competition is a good thing, and > I think there are enough aspects about LaTeX that can be done better > so that this project is worth being done. There are alternatives to LaTeX if you are prepared to look for them. One of these is Lout: http://lout.sourceforge.net/ Another option is to use TeX, but with Python as an alternative "macro language": http://www.pytex.org/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt4: Clickable links in QLabel?
On Thursday 01 March 2007 09:00, Tina I wrote: > A short and sweet question: Is it possible to put a clickable link in a > QLabel that will open in the systems default browser? Yes. > I tried to put in some HTML but it did (of course?) simply display the > code instead of a link. I also tried to set openExternalLinks 'true' but > then pyuic4 bombed. Well, that shouldn't happen. :-( Can you send a bug report to the PyQt mailing list (assuming you're subscribed to it) with the error message or backtrace that you get when this happens? > I see that QLabel does not have a html text format but I'm still hoping > it's possible. I really need a link on my main window form. If you enclose the HTML with and tags, the HTML should be displayed properly. Any other matching tags should also work, so you could use and if you want. Setting the label's openExternalLinks property to True should then enable what you want. You can try this out by previewing the form in Qt Designer. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Python GUI + OpenGL
On Monday 05 March 2007 18:22, Chris Mellon wrote: > On 3/5/07, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> Beside that, I do love the Qt library and would always use it in >> preference to wx, but this is a general thing and by no means tied to the >> OpenGL-programming. After all, that actually is done using PyOpenGL > > wx and Qt support OpenGL in essentially the same manner. I believe he > took from your earlier post that Qt had its own built in OpenGL > wrapper (and thus didn't rely on PyOpenGL) but to my knowledge that is > not correct. Yes, you need PyOpenGL (or any other suitable OpenGL wrapper) to use OpenGL with PyQt. Qt itself doesn't provide its own API for OpenGL; you just use the implementation available on your system. It is possible to get OpenGL-rendered 2D graphics without having PyOpenGL installed; you just paint on a QGLWidget in the usual way. However, I suspect that the original poster wanted to render 3D graphics, so Python bindings to the system's OpenGL library are still required. David -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I Color a QTableView row in PyQt4
On Friday 02 March 2007 21:55, Mel wrote: [This message is a bit old now. Still...] > Now that I can change the row colors of QTableView when loading data I > now need to be able to set the color of the row at anytime. I've been > trying by using an item delegate but I'm not sure if I'm using it > correctly. Thinking about it a bit, I'd probably avoid using a delegate for this. Ideally, you want to influence the BackgroundRole for each item in the row somehow. > Would I try and set an item delegate for the row and > change the background color that way? An example or a link to easy > to understand documentation on changing a row color for an object > based on QTableView using QSqlQueryModel as a model would be greatly > appreciated. I'm still a bit confused in Qt4. That's a very specific request! Anyway, using QTableView and QSqlQueryModel together is quite common, but we can look at a way to achieve this. One way would be to store a list of colors in the custom model, or use another database table to hold them, and access these whenever you need to return BackgroundRole data for any item in a row. You could lazily initialize these colors by setting each one when the corresponding row is accessed for the first time, and only updating it when the relevant item in the row is modified. David -- http://mail.python.org/mailman/listinfo/python-list
Re: a better solution for GUI in python
On Monday 12 March 2007 16:57, Chris Mellon wrote: > Gtk I consider an extremely poor contender as a cross platform > toolkit. The runtime is enormous and it makes little effort to appear > native on any non-GNOME platform. Given that wxPython more or less relies on GTK+ on Linux, I think you're probably shooting yourself in the foot here, particularly when you go on to say this: > wxPython is also a perfectly reasonable solution, especially if you > want a "native" seeming app on all platforms. All platforms would ideally include KDE, of course. ;-) David (sorry, couldn't resist) -- http://mail.python.org/mailman/listinfo/python-list
Re: qt ver. 3, linux, windows, and modal forms
On Saturday 24 March 2007 23:08, Mike wrote: > I'm having a problem with modal forms on windows. I've written a very > short test program, with a main window and a form called from the main > window. The form is set to modal with form.setModal(1) before calling > form.show(). Is form an instance of a QWidget subclass or a QDialog subclass? Have you tried calling form.exec_loop() instead of form.show()? > All works as expected on Linux. The form is modal, not allowing the main > window to received the focus. If I call the form from within itself, the > topmost form is modal, and not of the previous forms will receive the > focus until the topmost form is closed; then the next topmost is modal, > and so on. This sounds like the desired behaviour. > However, on Windows XP Pro (at work - don't use windows at home), the > form is not modal. The main window will receive the focus with a mouse > click even though the modal form is still on top. But this should show the same behaviour. I suspect that the use of show() rather than exec_loop() leads to the platform-specific behaviour you are seeing. > The source code is identical on both OS's. > > Has anyone run into this before? Is there a fix? I haven't been able to > find anything with google searches, and Trolltech's forums don't seem to > have any entries addressing the problem, either. > > I have a progam that I'm writing for work using Qt and Python, which was > like pulling teeth with our Microsoft oriented IT department, and I very > much do not want to tell them that it's not going to work (modal forms > are essential). Modal forms are quite commonplace, so they should work as you expect. If you above advice doesn't help, you'll need to supply some more information about the versions of Qt, PyQt, SIP and Python you are using. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Is http://cheeseshop.python.org/pypi/ having issues
On Saturday 07 April 2007 19:36, RobJ wrote: > Has any one noticed any issues with http://cheeseshop.python.org/pypi/ > ? I have been trying for hours to install packages (using > easy_install) but the connection keeps timing out. Don't worry, you're not the first person to notice: http://mail.python.org/pipermail/catalog-sig/2007-April/001050.html Maybe someone can suggest a workaround for easy_install while the server is unavailable. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyqt calling a custom dialog and returning the vars
On Monday 16 April 2007 22:06, Marcpp wrote: > I call a dialog from a principal program but cannot return the value > of the > variables (text box's). Here is a example... [...] > class ag (Agenda): > ... > ... > def _slotAddClicked(self): > d=dialogo1() > d.exec_() > d.connect(d.buttonOk,SIGNAL("clicked()"),self._procesadialog1) > > def _procesadialog1(): > d=dialogo1() > drempresa = d.dempresa.text() > print drempresa # Without seeing more of what you've done, it's difficult to tell, but you are just creating a new dialog in _procesadialog1() and reading the default text in its "dempresa" attribute which I presume is a QLineEdit widget. Assuming everything else is working correctly, I think you should remove the second method and rewrite the first one in the following way: class ag (Agenda): ... ... def _slotAddClicked(self): d=dialogo1() if d.exec_() == QDialog.Accepted: drempresa = d.dempresa.text() print drempresa # David -- http://mail.python.org/mailman/listinfo/python-list
QPicture and Qpainter PyQt4
On Mon Sep 17 09:29:43 CEST 2007, luca72 wrote: > class PictureFrame(QtGui.QFrame): > > def __init__(self, parent = None): > QFrame.__init__(self, parent) > picture = QtGui.QPicture() > > def paintEvent(self, event): > picture.load('dis.pic') > gr = QtGui.QPainter() > gr.begin(self.frame) > gr.drawPicture(0, 0, picture) > gr.end() > > But nothing is paint. > Can you give me some help You should probably be painting on "self" instead of "self.frame". It may not be related to your problem, but why don't you store the picture in "self.picture" rather than the local "picture" variable? David -- http://mail.python.org/mailman/listinfo/python-list
Re: building a GUI
On Mon Sep 24 00:08:09 CEST 2007, stef mientki wrote: > Phil Thompson wrote: > > On Sunday 23 September 2007, stef mientki wrote: > > >> Could well be, > >> but I never looked at PyQt seriously, > >> because of their weird license. > > > > It's not weird. It's either GPL or proprietary. Your choice. That's as > > complicated as it gets. > > This is what I find "weird": > == quote == > Trolltech's commercial license terms do not allow you to start > developing proprietary software using the Open Source edition. > == end quote == Well, if you know you're going to be developing proprietary software, what on earth are you doing with the Open Source edition? OK, perhaps by asking that rhetorical question I'm simplifying people's reasons and motives for using Open Source (and in this case Free/Libre) software to develop tools or solutions that they later want to release as closed, proprietary products. There are lots of ways people can end up in that position, of course. Some people find their way there by accident; others know what the situation is going to be well in advance... In any case, I think it's useful to be clear about what each license does or does not allow, especially if this leads to people making informed decisions well before they learn about the consequences. In this case, the terms of the commercial license place certain demands on the licensee, just as with many other commercial licenses. If someone develops a product using a GPL-licensed library, they can always release that product under the GPL, even if that's not what they had in mind when they started. ;-) David -- http://mail.python.org/mailman/listinfo/python-list
Script to extract text from PDF files
On Wed Sep 26 15:06:54 CEST 2007, byte8bits wrote: > On Sep 25, 10:19 pm, Lawrence D'Oliveiro central.gen.new_zealand> wrote: > > > This is inherent in the nature of PDF: it's a page-description language, > > not a document-interchange language. Each text-drawing command can put a > > block of text anywhere on the page, so you have no idea, just from > > parsing the PDF content, how to join these blocks up into lines, > > paragraphs, columns etc. > > So (I'm not being a wise guy) how does pdftotext do it so well? There's a little information on that online: http://www.glyphandcog.com/textext.html You would need to look at the source code to see exactly what it does. > The text I can extract from PDFs is extracted as it appears in the doc. > Although there are various ways to insert and encode text in PDFs, > it's also well documented in the PDF specifications (http:// > www.adobe.com/devnet/pdf/pdf_reference.html). Just because inserting and encoding is well documented doesn't mean that the reverse processes are easy. :-/ > Going back to pdftotext... it works well at extracting text from PDF. > I'd like a native Python library that does the same. Maybe you should look at the source code for pdftotext, if that's an option. > This can be done. > And, it can be done in Python. I've made a small start, my hope was that > others would be interested in helping, but I can do it on my own > too... it'll just take a lot longer :) Can I suggest that you approach one or more authors of the existing Python PDF solutions and work with them on this? There are at least four PDF parsers written in Python out there. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Script to extract text from PDF files
On Wed Sep 26 23:50:16 CEST 2007, byte8bits wrote: > On Sep 26, 4:49 pm, Svenn Are Bjerkem > wrote: > > > I have downloaded this package and installed it and found that the > > text-extraction is more or less useless. Looking into the code and > > comparing with the PDF spec show a very early implementation of text > > extraction. Luckily it is possible to overwrite the textextraction > > method in the base class without having to fiddle with the original > > code. I tried to contact the developer to offer some help on > > implementing text extraction, but he didn't answer my emails. That's disappointing to hear, but it's understandable. I must have one or two outstanding requests to add features to pdftools from a year ago. I keep meaning to look into making the necessary changes, but it's not something I'm looking forward to. > Well, feel free to send any ideas or help to me! It seems simple... Do > a binary read. Find 'stream' and 'endstream' sections. > zlib.decompress() all the streams. Assuming that they're FlateEncoded... > Find BT and ET markers (Begin Text > & End Text) and finally locate the parens within those and string the > text together. Which works fine if the generator put in space characters. Otherwise, it seems to me that you need to figure out where any spaces should go. > This works great on 3 out of 10 PDF documents, but my > main issue seems to be the zlib compressed streams. Some of them don't > seem to be FlateDecodeable (although they claim to be) or the header > is somehow incorrect. But, once I get a good stream and decompress it, > things are OK from that point on. Seriously, if you have ideas, please > let me know. I'll be glad to share what I've got so far. You need to take a good parser and work on a higher level text extraction library. > Not many people seem to be interested. I'll stop adding to this > thread... I don't want to beat a dead horse. Anyone interested in > helping, can contact me via emial. On the contrary, lots of people are interested in this sort of thing: http://phaseit.net/claird/comp.text.pdf/PDF_converters.html http://sourceforge.net/projects/pdfplayground http://www.adaptive-enterprises.com.au/~d/software/pdffile/ http://pybrary.net/pyPdf/ http://www.boddie.org.uk/david/Projects/Python/pdftools/ I discussed working with the author of pdfplayground, but things never really got going. I'd like to be part of a team working on a PDF library for Python, but my views on software licensing mean that I'd prefer to use a strong copyleft license rather than the permissive licenses found attached to most of the above libraries. David -- http://mail.python.org/mailman/listinfo/python-list
Re: How to display a videostream in the PyQt GUI by a efficient way
On Sat Sep 29 05:12:25 CEST 2007, kivilaya wrote: > As required, I need to get a videostream from a camera, and process > every frame to add some information on it, and then display the frame > in a PyQt GUI. > But I don't know how to display the videostream in the PyQt GUI by a > efficient way. > > Currently, I do these like this: > 1. Get the videostream by the videocapture module (a useful module > written by Markus Gritsch) in the format of PIL images; This sounds interesting. I wasn't aware of that module. > 2. Process every PIL image and add the information; > 3. Convert every PIL image to QPixmap and display it using > QLabel.setPixmap. This could be quite inefficient, though I think there's some support for Qt's image classes in PIL these days. > I think it is a very inefficient way, but I don't known how to display > the videostream in other ways, so I need your help, Thanks! > > PS:I do it with Windows XP, Python 2.5.1, PyQt4.3.0 If you're using a commercially-licensed Qt library, you'll have access to the ActiveQt classes that can be used to embed ActiveX controls: http://doc.trolltech.com/4.3/activeqt.html Otherwise, you might find this recent thread on qt-interest to be of interest: http://lists.trolltech.com/qt-interest/2007-09/msg00806.html I also tried to document ways to do this on the PyQt/PyKDE Wiki: http://www.diotavelli.net/PyQtWiki/Multimedia_Resources David -- http://mail.python.org/mailman/listinfo/python-list
Re: How to display a videostream in the PyQt GUI by a efficient way
On Sun Sep 30 09:10:40 CEST 2007, Kivilaya wrote: >I read the method in the given link and learn a lot from it. I'll > try to display the data inside a QWidget directly instead of the > current way. But I still have a question, is there any way to make the > displaying of RGB data in a QWidget more quickly. You can set certain flags to ensure that the widget isn't being updated or painted on too often. See the WA_OpaquePaintEvent and WA_NoSystemBackground flags: http://www.riverbankcomputing.com/Docs/PyQt4/html/qt.html#WidgetAttribute-enum The problem may be related to the conversion process rather than the time it takes to display the image. You mentioned that you were obtaining the images as PIL Image objects, but these need to be converted to QImage or QPixmap objects, so the raw data from the camera is being converted at least twice before it reaches the screen! >In fact, my work is to make a gui for displaying my > partners'experimental results to our teacher, the source video is no > need to be encoded to mpeg or h264 format, so I get the video from > camera in the raw format and display them without encodeing or > decoding process. Which operating system is this on? (I'm guessing that it's Windows because you mentioned the videocapture module.) >As my partners will do some experiments on the raw data, maybe add > a mark to label some area in the current frame, or change some part of > it, I get every frame as a picture before they process the picture > data, and then display the picture after their process. So, do you intend to process the video and store it in a file, or do you want to make these changes on a live video stream? > But displaying the pictures one by one in my current way is so slow, > I'm afraid that time spend on it is too long and the displaying of > results will be discontinuous. So I think maybe there is another way > to show these pictures. Is there another way of getting the data from the camera? Perhaps the author of videocapture has some ideas that can help you speed up the conversion and rendering process. Maybe the Device.getBuffer() function will provide data that can be passed directly to QPixmap.loadFromData(). David -- http://mail.python.org/mailman/listinfo/python-list
Re: Cross-platform GUI development
On Fri Oct 12 12:30:13 CEST 2007, Nick Craig-Wood wrote: > I'd recommend wxPython over those becase > > 1) native look and feel on all platforms > 2) doesn't require expensive licensing for non-commercial apps (QT) "Expensive" licensing is not required if you use the GNU General Public License (version 2) for your software, or a license that falls under the Trolltech GPL Exception: http://doc.trolltech.com/4.3/gpl.html > 3) Isn't a pain to install on windows (GTK) > > That said, times change and 1-3 may have changed since I last looked > at it! Yes, times have changed. (Other people in this thread have addressed points 1 and 3.) David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt ProgressBar
On Mon Oct 15 14:24:09 CEST 2007, luca72 wrote: > Hello i have made anly one test like this: > > from time import sleep > barra = QtGui.QProgressBar() > barra.setMinimum(0) > barra.setMaximum(10) > for a in range(10): >sleep(1) >barra.setValue(a) >app.processEvents() > > But the bar remain fix to 0% don't increase. > > can you tell me how to prooced Can you post a complete runnable code example, either here (if it's short enough) or to the PyQt mailing list? Thanks, David -- David Boddie Lead Technical Writer, Trolltech ASA -- http://mail.python.org/mailman/listinfo/python-list
Re: fclient project seeking co-coders
On Sun Oct 28 11:49:17 CET 2007, Jürgen Urner wrote: > I Just recently registered a project fclient to sourceforge.net > [http://sourceforge.net/projects/fclient]. fclient is intended to > become desktop client for the freenet [freenetproject.org] > network written in python and Qt4. It sounds like an interesting project. > fclient is very alpha, in fact only parts of the freenet client > protocol are curently implementated and loads of work ahead. But I > would appreciate very much finding interested co-coders to take part > in the project. > > Me, I am no professional coder, but an enthusiast with one or the > other year of python (and Qt) experience. If interested in the project > (and freenet), feel free to drop a mail to the users mailing list at > the project page. If you need advice on parts of the implementation, there are plenty of Python and Qt experts on the PyQt mailing list: http://www.riverbankcomputing.com/mailman/listinfo/pyqt If you're trying to avoid subscribing to additional mailing lists, don't worry: quite a few of us read python-list/comp.lang.python as well. Incidentally, you might find it useful to add your project to the list of application on the PyQt Wiki: http://www.diotavelli.net/PyQtWiki/SomeExistingApplications David -- http://mail.python.org/mailman/listinfo/python-list
PyQt with embedded python in Qt App
On Fri Nov 2 12:59:48 CET 2007, Bart. wrote: > Or I want to use PyQt in scripts to have similar gui for plugins written in > python > Or I want to extend application by scripts with PyQt. > > Or better question: > How to easy add python scripting in Qt application and have almast all > objects of app accesible in scripts? > Kross could be good solution? You can use PyQt, Kross or PythonQt for this, but only PyQt will give you a comprehensive API "out of the box". There is code in the PyQt source distribution that shows how to set up the Python interpreter inside a C++ plugin and import modules - it's used to load custom Python widgets into Qt Designer. Look at the designer/pluginloader.cpp file to get an idea of what you need to do. There are simpler ways to initialize Python, but this code should be helpful if you want to extend what you've done at a later time. David -- http://mail.python.org/mailman/listinfo/python-list
Re: creating simple Python scripting interfaces via C++
Ben Sizer wrote: > And is there anywhere else more appropriate that I should be asking > this question, given the lack of responses to this and my other embedding > topic so far? You could try asking on the C++ SIG mailing list at python.org: http://mail.python.org/mailman/listinfo/c++-sig David -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt: QListviewItemIterator
On Tuesday 16 January 2007 18:57, Tina I wrote: > I have a QListView with a number of columns. In order to filter the > output I iterate using QListViewItemIterator looking for the string > entered by the user (filterString). Currently I do it this way: [Reformatted code for quoting purposes] > it = QListViewItemIterator(self.authListView) > try: > while it: >item = it.current() >if item.text(0).contains(filterString) or \ > item.text(1).contains(filterString) or \ > item.text(2).contains(filterString): > >item.setVisible(1) >else: >item.setVisible(0) >it +=1 > except AttributeError: > pass > > Basically I iterate through the ListView until it goes beyond the list > and raise an exception, which I catch. It works but to be honest it > looks and feels ugly; "Do something until it goes wrong" > > So, question: How can I know I have reached the last item in the > QListView? When it.current() returns None. You can rewrite what you already have like this: it = QListViewItemIterator(self.authListView) while it.current(): item = it.current() if item.text(0).contains(filterString) or \ item.text(1).contains(filterString) or \ item.text(2).contains(filterString): item.setVisible(1) else: item.setVisible(0) it += 1 If you don't like calling item.current() twice for some reason, you could write this: it = QListViewItemIterator(self.authListView) item = it.current() while item: if item.text(0).contains(filterString) or \ item.text(1).contains(filterString) or \ item.text(2).contains(filterString): item.setVisible(1) else: item.setVisible(0) it += 1 item = it.current() David -- http://mail.python.org/mailman/listinfo/python-list
Re: The proper use of QSignalMapper
borntonetwork wrote: > I am trying to implement QTCore.QSignalMapper using PyQT. I finally got > to a point where I don't receive any compile or runtime error messages, > but I also do not see the final slot function fire off. Here is a > snippet of the code: > > self.signalMapper = QtCore.QSignalMapper(window) > # Use qsignalmapper to use of one slot function for multiple > # widgets. The map() function sends the slot an extra param > # that identifies the sender. > for idx in range(1, maxIngredients+1): > wName = 'chkProductIngredientsDelete_'+str(idx) > w = self.__dict__[wName] > self.app.connect(w, QtCore.SIGNAL("stateChanged(int)"), > self.signalMapper, > QtCore.SLOT("self.signalMapper.map")) You need to pass the C++ signature to the SLOT() function. I believe you want the form that does not accept any arguments: self.app.connect(w, QtCore.SIGNAL("stateChanged(int)"), self.signalMapper, QtCore.SLOT("map()")) Alternatively, you can pass the slot directly to the function: self.app.connect(w, QtCore.SIGNAL("stateChanged(int)"), self.signalMapper.map) PyQt accepts Python methods as slots, without requiring that they be wrapped in calls to SLOT(). David -- http://mail.python.org/mailman/listinfo/python-list
Re: The proper use of QSignalMapper
borntonetwork wrote: > Thanks, David, for you help. > > When I change the slot function to what you show in your second > example, I get the same results: nothing. This may be due to something I missed in your code. When you connect the signal from the signal mapper to your class, you need to specify the signal as a C++ signature as well: self.connect(self.signalMapper, QtCore.SIGNAL( "mapped(int)"), self.deleteProductIngredient) The second example should now work. Looking at the first example, which uses SLOT() rather than specifying a Python method, the following might be due to the way you call connect, though it is surprising: > When I change it to what you > have in your first example, I get the following: > > Object::connect: No such slot QApplication::map() > Object::connect: (sender name: 'chkProductIngredientsDelete_1') > Object::connect: (receiver name: 'main.py') [...] It looks like you should try something like this: self.connect(w, QtCore.SIGNAL("stateChanged(int)"), self.signalMapper, QtCore.SLOT("map()")) I can't understand why calling self.app.connect() would cause the connection to be attempted between self.signalMapper and self.app. Maybe someone on the PyQt/PyKDE mailing list would be able to explain the behaviour you're seeing: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde David -- http://mail.python.org/mailman/listinfo/python-list
Re: The proper use of QSignalMapper
On Saturday 20 January 2007 16:03, borntonetwork wrote: > David, thanks for your help. Unfortunately, all attempts of making this > solution work have failed. I would be interested to know if anyone has > used QSignalMapper successfully in a similar situation. Looking again at what you originally wrote, and looking at your solution below, I don't think it's really appropriate to use a QSignalMapper for this purpose. (That's what I understood from the signature of the deleteProductIngredient() method you had in your original code.) What you appear to want is a way of being notified about state changes to widgets that also identifies the individual widget that changed. You can do that by connecting the individual widgets to the same slot and call sender() to find out which object emitted the signal; for example: # ... for idx in range(1, maxIngredients+1): wName = 'chkProductIngredientsDelete_'+str(idx) w = self.__dict__[wName] self.connect(w, QtCore.SIGNAL("stateChanged(int)"), self.deleteProductIngredient) def deleteProductIngredient(self, state): """Delete a product ingredient.""" print self.sender(), "changed state to", state What QSignalMapper does is collect signals from different objects, assigning an ID to each of them, and emits a single signal with an ID whenever it receives a signal from one of those objects. In other words, it allows the actions of a group of objects to be described by a parameter but discards the signal's arguments. It's most useful for things like collections of push buttons where you only need to know that they were clicked. > For any interested, I worked around the problem using a closure, > which seems a bit cleaner from a coding point of view, although > I don't have any idea if it is more efficient or not: [...] > Each iteration then created a new function based on the closure: [...] It's good to know that you got something working in the end. There's also another solution that involves QSignalMapper, but it may not make the resulting code any simpler. David -- http://mail.python.org/mailman/listinfo/python-list
Re: My python programs need a GUI, wxPython or PyQt4?
On Jan 24, 12:09 am, "Daniel" <[EMAIL PROTECTED]> wrote: > I've downloaded both the wxPython and the PyQt4 package, and by the > first impression I must say that the PyQt4 system had a very > compelling presentation. From what I can understand from the feedback > I've gotten so far is that the wxPython is a better choice when it > comes to compability (with linux), and it's free even if I want to > create applications and sell them. Can you explain why you think wxPython is a better choice with respect to "compatibility (with linux)"? > So, from what I understand I will have to go with PyQt4 since (from > my understanding): > 1. I will not sell the applications I'm working with since they will > only be used by the internal QA at a computer game company. > 2. There seems to be a lot of documentation available for PyQt4. > 3. PyQt4 seems to be easier to learn. > 4. My programs does not need to support Linux or Unix. Qt is a cross-platform framework, so you would get support for X11-based platforms, anyway. David -- http://mail.python.org/mailman/listinfo/python-list
Re: My python programs need a GUI, wxPython or PyQt4?
On Jan 24, 3:00 pm, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Thus, it is well possible to write internal GPL software, using the Qt Open > Source library, and to release/distribute/use it *ONLY* internally. http://www.gnu.org/licenses/gpl-faq.html#GPLRequireSourcePostedPublic > Also, it > should be made clear that a company can of course relicense its own > proprietary libraries as GPL for internal usage only, so that they can be > linked to other GPL libraries "legally". That seems to be a reasonable approach, though it seems to me that the GPL grants even "internal" users certain rights. > [[ Another page of similar babble is the one where they try to convince you > that you cannot use the Qt Open Source edition to develop a software, and then > buy the commercial edition only the day before you want to release it as non > open-source. I can't even understand how they can even try to support such a > nonsense position. You're free to develop your software for years as GPL > without distributing it, and then relicense your own code whenever you want. > They're obviously just trying to scare people. ]] That's nothing to do with any restrictions in the GPL; it's more to do with purchasing a commercial license. Obviously, if you're operating a dual licensing scheme, it's not in your interest to encourage people to pretend to write open source software up until the day it is released as a closed source product. That sort of behaviour is not exactly inviting mutual trust between vendor and customer, is it? David -- http://mail.python.org/mailman/listinfo/python-list
Re: My python programs need a GUI, wxPython or PyQt4?
On Jan 24, 11:54 am, Harry George <[EMAIL PROTECTED]> wrote: > It is all interpretation -- even after some cases have wandered > through the courts. Mostly the trolltech statements indicate their > intent to sue. That right there tells me I want to go elsewhere. Well, one could alternatively read the GPL, look at the FSF FAQs, consult a lawyer, or talk to the Trolltech salespeople. I'd suggest to the original poster that they do one or more of those things instead of relying on your interpretation and guesswork. David -- http://mail.python.org/mailman/listinfo/python-list
Re: pdf to text
On Thursday 25 January 2007 22:05, tubby wrote: > I know this question comes up a lot, so here goes again. I want to read > text from a PDF file, run re searches on the text, etc. I do not care > about layout, fonts, borders, etc. I just want the text. I've been > reading Adobe's PDF Reference Guide and I'm beginning to develop a > better understanding of PDF in general, but I need a bit of help... this > seems like it should be easier than it is. It _seems_ that way. ;-) One of the more promising suggestions for a way to solve this came up in a comp.lang.python thread last year: http://groups.google.com/group/comp.lang.python/msg/cb6c97a44ce4cbe9?dmode=source Basically, if you have access to the pdftotext command on a system that supports xpdf, you should be able to get something reasonable out of a PDF file. > I know the text is compressed... that it would have stream and endstream > makers and BT (Begin Text) and ET (End Text) and that the uncompressed > text is enclosed in parenthesis (this is my text). Has anyone here done > this in a simple fashion? I've played with the pyPdf library some, but > it seems overly complex for my needs (merge PDFs, write PDFs, etc). I > just want a simple PDF text extractor. The pdftotext tool may do what you want: http://www.foolabs.com/xpdf/download.html Let us know how you get on with it. David -- http://mail.python.org/mailman/listinfo/python-list
Re: DCOP memory leak?
On Jan 31, 6:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > The code I posted is not my actual program and was only to demonstrate > my problem. The complete program I'm writing uses QT and so the loop > is replaced by a Timer event. > I tried out the suggestion. I had already tried the del dcop > instruction, so I knew that wasn't it. I also placed the DCOP variable > outside my loop but that didn't help either. You might get a precise answer to your question if you send a message to the PyQt/PyKDE mailing list: http://mats.imk.fraunhofer.de/mailman/listinfo/pykde The original authors and contributors of various Python DCOP modules read that list, so there's a chance they can either solve your problem or offer some advice on how to work around it. > What I did notice that my program only grew in memory use when the > 'ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs() ' code was > executed (or any other function using the AmarokDcopRes variable like > 'ok, volume = AmarokDcopRes.player.getVolume()' ) Do you find the same problem with other DCOP interfaces? David -- http://mail.python.org/mailman/listinfo/python-list
Re: Regd. Regular expressions PyQt
On Saturday 03 February 2007 09:52, Paddy wrote: > On Feb 3, 8:24 am, [EMAIL PROTECTED] wrote: >> I am trying to work out a regular expression in a PyQt environment for >> time in hh:mm:ss format. Any suggestions? > > Yep, > Use Kodos! > http://kodos.sourceforge.net/ > > - It's Fab. There's also a Python port of the Regular Expressions example from Qt in the PyQt source distribution, though it's not as feature complete as Kodos, obviously. :-) Vishal should probably start by trying one of these tools, typing something like (\d\d):(\d\d):(\d\d) into the regular expression (or pattern) field. David -- http://mail.python.org/mailman/listinfo/python-list
Re: irclib problems
On Sunday 11 February 2007 09:29, Tina I wrote: > I'm playing around with the 'irclib' library working with the first > example at > http://www.devshed.com/c/a/Python/IRC-on-a-Higher-Level-Concluded/ > > When copying the example verbatim and running it from a console it works > flawlessly. It connects to the server, join the channel and sits there > 'forever'... OK. So it works on its own. > However, I want to use it in a PyQt application and have done the > following. I have created a module named 'irclibtest.py' that looks like > this: [...] class Conn: def __init__(self): # Network information self.network = '192.x.x.x' self.port = 6667 self.channel = '#test' self.nick = 'IRClibt' self.name = 'Python Test' # Subclass SimpleIRCClient class ClientClass ( irclib.SimpleIRCClient ): pass # Create an instance of ClientClass and connect. self.client = ClientClass() self.client.connect ( self.network, self.port, self.nick, ircname = self.name ) self.client.connection.join ( self.channel ) [...] > if __name__ == "__main__": > app = QtGui.QApplication(sys.argv) > f = TircMain() > f.show() > sys.exit(app.exec_()) > ### Main application end ## > > The problem is that this pings out (PING timeout). As far as I > understand it rclib.SimpleIRCClient is supposed to handle PING-PONG with > the server so I don't understand why it does not in my Qt test, but it > does 'raw'. You don't call self.client.start() anywhere. Even if you did, you would still have problems because you need to call app.exec_(), and this would only happen after self.client.start() returns - if ever. > I can send to the channel right up to the point it times out by the way. I think this is just a result of the way the IRC protocol works. > Anyone know what I'm missing here? You have an application with two event loops, and you can't run them both in the usual way. If SimpleIRCClient has a method that only processes pending events and returns immediately afterwards, you could create a QTimer, connect its timeout() signal to that method, and make it fire every half a second or so, to ensure that the client doesn't time out. There may be other solutions with threads, but things could get quite complicated. Making one event loop play well with the other is probably the best approach to take. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
On Tuesday 13 February 2007 11:04, [EMAIL PROTECTED] wrote: > To be true, I don't know if any of these toolkits (GTK, wxWindows, QT) > and their GUIDesigners have the features you like in Delphi. What I > know is that: > 1/ these three toolkits have everything *needed* to write serious GUI > apps > 2/ they are all (more or less) portable > 3/ the first two are free software And, for the sake of completeness, it should be mentioned that the third is available under the GPL, which is a Free Software license. David -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I Color a QTableView row in PyQt4
On Wednesday 28 February 2007 18:55, Mel wrote: > I am currently porting an SQL centered Visual Basic application to run > on Linux, Python, and Qt4. Currently I am stumped on changing row > colors in the QTableView widget. My test code is based on code from > the PyQt4 examples and looks like this: > > *** Start Code *** > > import sys > from PyQt4 import QtCore, QtGui, QtSql > > import connection > > > class CustomSqlModel(QtSql.QSqlQueryModel): > def data(self, index, role): > value = QtSql.QSqlQueryModel.data(self, index, role) > if value.isValid() and role == QtCore.Qt.DisplayRole: > if index.column() == 0: > return QtCore.QVariant(value.toString().prepend("#")) > elif index.column() == 2: > return QtCore.QVariant(value.toString().toUpper()) > if role == QtCore.Qt.TextColorRole and index.column() == 1: > return QtCore.QVariant(QtGui.QColor(QtCore.Qt.blue)) > return value [Snipping the rest of the code to keep this post short.] > Column 18 in the table shows a number from 1 to 3. I would like to > change the color of the row based on the value in column 18 but I have > not been able to find any resources that show me how. Can anyone lend > a hand? It's interesting to see that you subclassed QSqlQueryModel instead of using a custom delegate to display the data. It's usually recommended that you subclass QItemDelegate if you want to customize the way items are represented, but you can also customize the model if you want. What you can do is to check to see if the requested role is the Qt.BackgroundRole and, if so, query the base class for the data in column 18 in the same row. Then you can supply a different colour (as a brush, actually) depending on the value you obtained. if role == QtCore.Qt.BackgroundRole: # Get the data from column 18. column18_data = index.sibling(index.row(), 18).data() # The data is stored in a QVariant, so we unpack it. integer_value = column18_data.toInt()[0] # just the value # Look up the associated color in a dictionary which you # have already defined, and return it. color = self.colors.get(integer_value, self.default_color) return QtCore.QVariant(QtGui.QBrush(color)) You might also find the following pages useful: http://www.riverbankcomputing.com/Docs/PyQt4/html/qt.html#ItemDataRole-enum http://doc.trolltech.com/4.2/model-view-model.html Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I Color a QTableView row in PyQt4
[Following up my own post.] On Thursday 01 March 2007 01:08, David Boddie wrote: > It's interesting to see that you subclassed QSqlQueryModel instead of > using a custom delegate to display the data. It's usually recommended > that you subclass QItemDelegate if you want to customize the way items > are represented, but you can also customize the model if you want. On reflection, I think subclassing the model is probably the right thing to do here. Delegates are much more useful if you want to substantially alter the appearance of items, but that's not what you're trying to do here. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Low-overhead GUI toolkit for Linux w/o X11?
On Sat Nov 3 20:45:54 CET 2007, Grant Edwards wrote: > I'm looking for GUI toolkits that work with directly with the > Linux frambuffer (no X11). It's an embedded device with > limited resources, and getting X out of the picture would be a > big plus. > > The toolkit needs to be free and open-source. > > So far, I've found two options that will work without X11: > > 1) QTopia (nee QT/Embedded). I assume that I can probably get > PyQT to work with the embedded version of QT? Qtopia Core (formerly known as Qt/Embedded) should be fairly painless to get working, though the embedded-specific features aren't supported by a plain PyQt4 build. However, it is possible to get bindings for it up and running - I've done it twice for different versions of Qtopia Core http://www.diotavelli.net/PyQtWiki/PyQt4_on_the_Qtopia_Greenphone so it should be possible to get something working for the latest version. You don't really have to worry too much about having all the bells and whistles wrapped for use from Python, anyway. > 2) PySDL or PyGame. I'm not really sure what the differences > are between those two. The latter seems to be a little > more active. Are there any traditional GUI "widgets" > available for these two? PyGame is definitely more visible than PySDL. You might find something you can use in the list of libraries for PyGame: http://www.pygame.org/tags/libraries There's also a list of "gui" tagged projects: http://www.pygame.org/tags/gui > Google found me this thread from a few years ago: [...] > Which mentions the same two choices and confirms that PyQt at > worked at one time with Qt/E (which would lead one to believe > it could be made to work with QTopia). I guess I should be pushing my patches for PyQt4 back upstream, or at least publishing them somewhere. I suppose it would also be useful if I looked at making them work with a recent version of PyQt4 and made sure that any new widgets in Qtopia Core 4.3 are handled by the configuration system. This lets you exclude features you don't need in order to reduce library sizes. If you're interested in using PyQt4, I'll add an item for these changes near the top of my "to do" list. If not, I'll probably get around to doing it, but it might not happen soon. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Low-overhead GUI toolkit for Linux w/o X11?
On Sun Nov 4 03:22:27 CET 2007, Grant Edwards wrote: > I think we're definitely going to try to evaluate Qtopia on our > platform to see if it's any quicker and smaller than > wxWidgets/GTK+/X11. I guess that evaluation doesn't need to > use Python -- in theory we sould be able to compare performance > of "equivalent" C/C++ apps running on wxWidgets/GTK+/X11 and on > QTopia. Good luck with that. Just remember to read the guide to configuring features in Qtopia Core so you don't build in things you don't need: http://doc.trolltech.com/4.3/qtopiacore-features.html The overview page might also be useful to you: http://doc.trolltech.com/4.3/qtopiacore.html David -- http://mail.python.org/mailman/listinfo/python-list
Re: Drawing charts in Qt
On Tue Nov 6 15:46:07 CET 2007, Michel Albert wrote: [PyQwt and matplotlib] > PyQwt looks much more interesting, but I have trouble installing it. > On my machine it complains that sipconfig "has no attribute > '_pkg_config'". Is the configuration script finding the sipconfig file for SIP 3 or SIP 4? > In the end the application should also run on Windows boxes. And I > suppose as long as I use the right versions and use the precompiled > binaries, I should get it at least installed. But the thing with the > version numbers looks like some major lottery game to me. If one of > the elements in the chain (be it Qt, or Qwt) release new versions and > the available binary distributions get "out of sync", future support > for the written application becomes foggy. I'm not sure what you mean. Can you explain? > Has anyone ever successfully used these graphing libraries with PyQt? > Or are there other graphing libraries available? In fact, my needs are > modest. A Line- and Bar-Chart would solve the majority of problems. I've installed PyQwt for PyQt4 and tried the examples, but only out of curiosity because I wasn't writing an application that needed those facilities at the time. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Contextmenu in a QTreeWidget with PyQT
On Wed Nov 21 19:46:48 CET 2007, blaven wrote: > I apologize in advance if this is not the correct forum to ask this > and if someone knows a better place, please let me know. There is a mailing list for PyQt/PyKDE issues: http://www.riverbankcomputing.com/mailman/listinfo/pyqt It's not a problem to post questions here - some of the people on that list also read python-list/comp.lang.python. > But, I am trying to create a Contextmenu (a right-click popup menu) from > within a QTreeWidget. I tried setting the contextMenuPolicy to > CustomContextMenu and then handling the signal > customContextMenuRequested() but nothing seems to be happening. ie: >self.tree = QTreeWidget() >self.tree.setContextMenuPolicy(Qt.CustomContextMenu) > > self.connect(self.tree,SIGNAL('customContextMenuRequested()'), > self.newContext) You need to specify the parameters that the signal passes in the signature: self.connect(self.tree,SIGNAL('customContextMenuRequested(QPoint)'), self.newContext) In this case, a QPoint object is passed; see the documentation for more details: http://www.riverbankcomputing.com/Docs/PyQt4/html/qwidget.html#customContextMenuRequested > Does anyone have a sample or tutorial on how to do this? One other > question, whe I right click, it changes the selection in the > TreeWidget, would I need to remove the handler for right clicks to get > the menu? With your custom context menu enabled, you may find that right clicks no longer cause the selection to change. If it does, post another question, either here or on the PyQt/PyKDE list, and I'm sure someone will help you out. Good luck! David -- http://mail.python.org/mailman/listinfo/python-list
Re: OPLC purchase period extended
On Sat Nov 24 19:30:03 CET 2007, Grant Edwards wrote: > The XO laptop comes with a built-in Python IDE, so everybody on > c.l.p ought to have one... A nice idea in theory, but... 2. XO laptops will be shipped only to G1G1 participants and only to the street addresses they provide for themselves in the fifty United States, Puerto Rico, Guam, the U.S. Virgin Islands, the District of Columbia and Canada. [http://laptopgiving.org/en/terms-and-conditions.php] David :-( -- http://mail.python.org/mailman/listinfo/python-list