[PyQt] Parent/Child widget clipping
Greetings All, Doing some prototyping where I have a simple QTreeWidget with 3 items. Each item has 3 simple children. Using QTreeWidget.setItemWidget()I set/insert a simple QTableWidget into a child of one of the tree's parent items (first column) The problem is that the child-table width is wider than the parent-tree's first column, so that parent-tree-column2 clips the child-table. This phenomena is pretty much identical to this example on stackoverflow (last pix) http://stackoverflow.com/questions/6133367/qtreewidget-with-multiple-columns-limits-number-of-child-items However, in that example, the problem is solved by manually (or could be automatic) resizing of the parent columns by simply pulling it wider,etc.. But in my prototype, I need the entire child-table to display in it's entirety but I need the columns of the parent-tree to remain the same width. In other words, I need to override the default behaviour of having the tree define the child's display region. I've tried several things...all to no avail... I chose to use Tree/Table-Widgets this time, instead of Tree/Table-Viewswould the views method perhaps solve this dilemma? If there's no way to solve this directlyany thoughts about constraining the position of a widget to another widget?...bypassing the parent/child relationship in favor of functionality that would snap a table widget's position to a marker, or anchor on the tree widget? Sounds crude, I know...but trying to figure out any workaround... Would doing something like setItemLayout (instead of setItemWidget) yield a layout that would paint over it's parent?(albeit I can't seem to find a function like setItemLayout, lol) Any and all suggestions or solutions or workarounds are greatly appreciated.. Cheers, Jim (Simple example attached) example2.py Description: Binary data ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bug in QWebKit?...
A great Thank You to Andreas and Kovid for both of your expert-level feedback on this... Since Andrea suggest the bug may be in Qt,...I will post to that forum as well... but think I might wait a day or so to hear what others may say and weigh-in with their expertise before propagating to Qt.. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QWebkit / QWebFrame
Howdy, I believe Guru Hans-Peter ;-) posted a collection of PyQt examples that he converted into Python from the Qt C++ examples.. In one titled fancybrowser.py There's a few lines that read... @QtCore.pyqtSlot() def submit(self): frame = self.ui.webView.page().mainFrame() then firstName = frame.findFirstElement(#firstname) It appears that the function findFirstElement() appeared in a version of Qt that came along after the one I'm on (4.5.3) 1) Can anyone suggest a code workaround that would accomplish same that will work in 4.5.3 rather than 4.7 or 4.8 (whenever that appeared) 2) Secondly,...as an alternative, one that I hesitate to try,...is it possible for two versions of Qt (and I guess two versions of PyQt and Sip) to exist simultaneously? Using one version for *this* and another version for *that* ?___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QWebkit / QWebFrame
whoops,...correction I typed fancybrowser.py but I actually meant formextractor.py Thanks, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Version matching: Qt and PyQt
Thanks for you responses,... lol,.yes, I am aware that Maya requires a certain version combination... My apologies for not being clearer...I was thinking of version relationsship between Qt and PtQt. In practise, you determine the lowest Qt version that you need to support yes,...this is precisely why I was wondering if there was a version table,etc.. Putting Maya aside for a moment, and speaking only in terms of Qt and Py terms.. Phil,...you seem to suggest that for OSX Lion, I can grab the latest version of Qt (or the version that Lion needs) and then grab the latest version of sip/PyQt ? (in a Python 2.6 world) Thank you guys very much for responding, Cheers, Jim From: Hans-Peter Jansen h...@urpla.net To: James Polk jpolk5...@yahoo.com Sent: Friday, December 2, 2011 12:40 AM Subject: Re: [PyQt] Version matching: Qt and PyQt Am Friday 02 December 2011 03:13:52 schrieb James Polk: Is there a online guide anywhere to match a version of Qt with it's corresponding version of PyQt ? For example,...on Windows, in order to work with Maya2011, I had to install Qt 4.5.3 and use PyQt 4.7.3 (and sip too) This is a constraint induced by Maya then. Is there a lookup table somewhere where these versions are matched up? Not only Windows, but OSX, and Linux too..? My current dilemma is finding the right version combo for OSX Lion (10.7.2 64bit) Well, in theory, all versions of PyQt4 should work with all versions of Qt4. If you depend on a Qt feature that appeared in a certain version, this feature is available only, if PyQt4 is adapted to that feature and is compiled against a Qt version containing that feature. This is possible due to sips timeline feature and a complex version dependency scheme. In practise, you determine the lowest Qt version that you need to support, and build the newest sip/PyQt4 against it. Keep in mind, that sip/PyQt4 depends on the particular Python revision, it is build with. I cannot say anything about Mayas PyQt bindings, though. Hth, Pete___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Version matching: Qt and PyQt
Is there a online guide anywhere to match a version of Qt with it's corresponding version of PyQt ? For example,...on Windows, in order to work with Maya2011, I had to install Qt 4.5.3 and use PyQt 4.7.3 (and sip too) Is there a lookup table somewhere where these versions are matched up? Not only Windows, but OSX, and Linux too..? My current dilemma is finding the right version combo for OSX Lion (10.7.2 64bit) Thank you, Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QTimeLine: same code runs different on XP-64bit vs XP-32bit
Hello, A while back, wrote some kinda' simple code to simply move/animate QLabels from left to right, or right to left. Wrote it on WinXP 64bit and it ran fine. Went to run it on WinXP 32bit, and it doesn't execute the same, meaning QLabels end up in wrong position,...close, but off... Basically, doing a #-- self.timeline = QtCore.QTimeLine(1000) self.timeline.setFrameRange(0, 30) self.connect(self.timeline, QtCore.SIGNAL(frameChanged(int)), self.A_Function ) self.timeline.start() where in A_Function something is done like: def A_Function(self, frame): tx = float(self.xtranslate[frame]) # retrieves X-offset value from list for j in range(1,10): # ten QLabels cmd = (rect = QtCore.QRect( self.hpix_%d.geometry() ) % j) exec(cmd) x = rect.x() y = rect.y() w = rect.width() h = rect.height() x = x + tx cmd = (self.hpix_%d.setGeometry(%d,%d,%d,%d) % (j,x,y,w,h) ) exec(cmd) self.update() Later, to try to fix,...I added self.timeline.setCurveShape(QtCore.QTimeLine.LinearCurve) self.timeline.setUpdateInterval(30) to code above, but didn't make any difference... Again, on XP-64bit,...works *everytime*,...but on XP-32bit,...each run seems to be offset by a randomly wrong value, meaning one time it'll be maybe 50 pixels short of target, another time, maybe 30 pixels over... Any and all thoughts and suggestions are most welcome, Cheers, Jim___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Threading: process B slowing execution of process A
Howdy All, I have a situation regarding threading that I'm hoping that you gurus can advise on,... I'm doing a UI where I spawn a second, threaded processthe child process affects the parent process by altering the parent's behaviour and/or animation timing. Using modules threading and functools.. from threading import Thread from functools import wraps ProcessA does a standard .ui load, and presents a revolving door type of interface for selection. It is similar (though not identical) to one used at http://video.pbs.org/ ProcessB is spawned thusly: task1(self) for i in range(0, 10): print(.) ...which calls: @run_async def task1(form): print(task 1) for i in range(0, 1000): for j in range(1, 2): cmd = (rect = QtCore.QRect( form.pix_%d.geometry() ) % j) exec(cmd) x = rect.x() y = rect.y() w = rect.width() h = rect.height() x = x - 1 cmd = (form.pix_%d.setGeometry(%d,%d,%d,%d) % (j,x,y,w,h) ) exec(cmd) form.update() time.sleep(.02) which in turn runs: def run_async(func): @wraps(func) def async_func(*args, **kwargs): func_hl = Thread(target = func, args = args, kwargs = kwargs) func_hl.start() return func_hl return async_func ProcessB uses these...to basic translate some graphical elements back and forth along the X-axis to give the UI an animated, lively look,not unlike many CNN logo treatments on TV,etc... They are simple, transparent planes. ProcessA translates/revolves it's elements via QTimeLine using a 24-step animation cycle that is offset for each subsequent window element. Code snippets look like this: self.tl = QtCore.QTimeLine(1000) self.tl.setFrameRange(0, 30) self.connect(self.tl, QtCore.SIGNAL(frameChanged(int)), self.FocusFadeOutToBlack ) ETC ETC self.connect(self.tl, QtCore.SIGNAL(finished), self.FocusFinishFadeOut ) self.tl.start() The problem that occursis that while ProcessB is translating it's simple graphical elements, the user hits a button that tells ProcessA to move to the next window. ProcessA must move the window to an exact location,...which it does when ProcessB is *not* running. But when ProcessB *is* running,...the windows in ProcessA fall short of their end location. I'm thinking that the sleep command in ProcessB may also be affecting ProcessA's timing, something sure is. From what I've readthreading process should work independently of each other, and shouldn't cause any crosstalk as it were. Not having ProcessB's animating graphical elements really takes away a lot of the UI's sparkle. Again,..if I don't spawn ProcessB, ProcessA works right every time. Can anybody shed any light, experience, or knowledge regarding this phenomena? Thank you very much, Cheers, Jim___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Bring to Front|Send to Back: raise_() and lower()
Aside from the depth modifiers in the email subject,.. Are there any other, more specific, ways to alter, control, and/or modify a UI's depth ? It would be great if there is some kind of numerical value to read/write somewhere... If the commands above *aren't* used,...is depth established by hierarchical position? Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Designer issues, WYS-is not-WYG
Thanks for the responses,... I'll send an example UI later today, but I do use Layouts...of all kinds.. I'll take a look at the tutorials, but I doubt it'll address what I'm seeing,.. which appears to me to be more of a versioning issue...or a difference between Python and C/C++ interpretation... Thanks again, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Designer issues, WYS-is not-WYG
Ahhh!I found the problem I was narrowing down my code to a send a more simpler example UI,.. I deleted a bunch of stuff, and voila it worked,going back and analyzing step-by-step,...setting the app style is the culprit... Specifically, -- app.setStyle(Plastique) I'm (unfortunately) on windows, and I had adopted the Plastique theme look,... If I take this out,...the simple slider example is now finea tall slider remains tall in the application... I kinda' figured it was something stupid I was doing, lolI was half right! ;-) Thanks for the responses! Happy Motoring, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Designer issues, WYS-is not-WYG
I like Designer and have been using it more and more... but I've been noticing that many times what you see in the Designer window ends up not matching when you run your program later. For example, small offsets in X and Y...look good in Designer, but don't end up in the same place in the program. Many times, it's not that consequential, but in a more complex UI, with very precise positioning, this can be very frustrating. One example,...create a MainWindow, drop a horizontal slider into it, and make it's height 60, so you get a kinda' tall main marker. Save it as a .ui file,...load it into your program, and the tall marker is now short. ( I dynamically load my UI's with uic.loadUiType(), but the same phenomena happens either way.) Using Designer's preview is consistent with what's in Designer, but something is lost in translation later when it goes into the program. I often get positon offset weirdness using QFrames, QGroupBoxes,etc... They look good in Designer, then off in main program, so I have to make them look off in Designer, so they'll end up in the right place when they're used. I'm using Python 2.6.6, Qt 4.5.3, and PyQt4 Does anybody else experience this? Does anybody know what causes it, and is there a workaround? Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Inter-office distribution/installation of packages/modules
Apologies if this is too off-topic,but I'd like to propose a discussion of how-to's and where-fore's regarding distributing python modules to a user-base. Recently, I've been using Mark Hammond's excellent pywin32 packages, along with NumPy and PyOpenGL,etc. I have a user-base of approx 40 or so, who will need these packages added to their base Python install. Rather than visit 40 separate desktops, I used pip (pip freeze) to get a short list of packages outside the base install, and wrote an app that each user can run to find what's missing, and initiate the appropriate install,etc. Then I realized that pip itself was a 3rd party package!..DOh! I can fall back and use help('modules') to generate a new list, but it lists *everything* in the install,...usable but not as succinct, for pywin32 for example, it lists about a dozen things with a form of win32 in them,...and doesn't appear to return the real package name that is associated with the binary installation file. Surely these issues are fairly common phenomena in many workplaces,etc... I'm wondering if anybody out there has any knowledge, tips, or experiences regarding this issue that they can share. I've found moduleFinder, and various ideas about searching sys.path, pkgutils, but nothing else that seems like a long term viable and/or elegant solution. Thoughts anyone? Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Getting image filename in QLabel-pixmap
Let's say you create a QLabel and make it an icon, by associating an image file to it,.. like.. thisPixmap = QtGui.QPixmap('server:/images/airplane.jpg') ) thisIcon = QtGui.QLabel(self) thisIcon.setPixmap(thisPixmap) Now let's say that later, in another function...you need to query thisIcon to obtain the name of the image file associated with it (airplane.png). How can one do this? I can't find any function in either the QLabel nor the QPixmap class that has a way to return the underlying image filename. QLabel does have pixmap()...as in: thisIcon.pixmap() but that doesn't return the image filename,...it returns the pixmap's address. Using QIcon might be an option,...but I need to use QLabel as it has move functions,...and QIcon doesn't appear to have that... Any info or suggestions are greatly appreciated, Cheers, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] SIP versions. possible crash issues
Howdy, I'm using PyQt mostly in conjunction with Maya, but also for standalone applications. I have a situation where from within Maya, I launch a PyQt app that uses sip's wrapinstance command. I'm creating a Maya-derived graphical entity and parenting it into the PyQt window. I've done this before, and this technique is current conventional practice amongst many in the uh, Maya/PyQt community shall we say. It's worked many times for me before, but now it's crashing. The *only* difference is that when it crashes now, it's when a really large object has been loaded into Maya. After Maya launch, run the tool, everything's fine. Load really large database, run the tool, it crashes...always at the sip line... So, I tried an experiment, I did everything as normal, but I didn't call sip, and it didn't crash. So my first thought was can I install a new version of SIP, or is the version I'm using locked into compatibility with the versions of Python and PyQt I'm on... Or would downloading a newer version possibly fix the problem? My environ is: Python 2.6.4 PyQt 4.5.3 (or 4.5.5, I forget) SIP (how to get the version?) What kind of conflicts could occur with large memory usage? I'm running XP Pro 64-bit with 8G memory,..the large database is about 1.4G on the drive Also open to any other thoughts, suggestions, or advice,... Cheers, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QTreeView / QFileSystemModel : auto-expand to designated directory
Howdy, Anybody have any experiences or words of wisdom to share concerning how to have a QTreeView/QFileSystemModel automatically expand from entirely closed (on startup) to a certain specified directory ? Was hoping for a single command,...but preliminary research looks like a recursive technique/function is called for... Thoughts, suggestions, words of advice...are all greatly appreciated, Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] App Color/Style Themes
Anyone have any experience working with,tweeking, and/or creating new app color schemes?...the one's specificed with app.setStyle()... Of the released ones: Plastique, CDE, motif, SGI, Windows, CleanLooks, Mac is there a way to tweek the colors in these? Where are they found? Can one create a new one from scratch? or a derivative of the above? Are these themes related to or the same as styleSheets ? Thanks, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question on QTreeView, interactive expanding/collapsing
Greetings All, In a typical QTreeView,...the default behaviour of clicking on a plus box, i.e. the branch boxes of the tree, yields a single box open, or in the case of collapsing, a single box closed event. Is there any way to use a keyboard modifier, like SHIFT, CTRL, and/or ALT, to expand or collapse the *whole* tree? Many other similiar tree structures in other software have this feature. For example, holding down CTRL and ALT and clicking on any box will unfold/expand (or collapse) all nodes/branches from that node and all below. Is there something I'm overlooking? Is this (re-)implementable ? Many Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Question on QTreeView, interactive expanding/collapsing
Whoops,...just found the *-hotkey,nevermind, lol... --- On Tue, 4/19/11, James Polk jpolk5...@yahoo.com wrote: From: James Polk jpolk5...@yahoo.com Subject: Question on QTreeView, interactive expanding/collapsing To: pyqt@riverbankcomputing.com Date: Tuesday, April 19, 2011, 2:09 PM Greetings All, In a typical QTreeView,...the default behaviour of clicking on a plus box, i.e. the branch boxes of the tree, yields a single box open, or in the case of collapsing, a single box closed event. Is there any way to use a keyboard modifier, like SHIFT, CTRL, and/or ALT, to expand or collapse the *whole* tree? Many other similiar tree structures in other software have this feature. For example, holding down CTRL and ALT and clicking on any box will unfold/expand (or collapse) all nodes/branches from that node and all below. Is there something I'm overlooking? Is this (re-)implementable ? Many Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Question on QTreeView, interactive expanding/collapsing
That's Cool!...Thanks Paul! --- On Tue, 4/19/11, Paul Du Bois dub...@doublefine.com wrote: From: Paul Du Bois dub...@doublefine.com Subject: RE: [PyQt] Question on QTreeView, interactive expanding/collapsing To: James Polk jpolk5...@yahoo.com, pyqt@riverbankcomputing.com Date: Tuesday, April 19, 2011, 3:25 PM If you need hotkey+click then this is the best way I've found to do it # Implement shift-click to expand/contract @pyqtSlot(QModelIndex) def _on_expanded(self, index): if self._in_shift_press: self._in_shift_press = False _recursive_set_expanded(self, index, True) @pyqtSlot(QModelIndex) def _on_collapsed(self, index): if self._in_shift_press: self._in_shift_press = False _recursive_set_expanded(self, index, False) def mousePressEvent(self, evt): # Make shift-click expand/collapse all if int(evt.modifiers() Qt.ShiftModifier) != 0: self._in_shift_press = True try: QTreeView.mousePressEvent(self, evt) finally: self._in_shift_press = False def _recursive_set_expanded(view, root, desired): from collections import deque root = root.sibling(root.row(), 0) q = deque([root]) model = view.model() while q: idx = q.popleft() view.setExpanded(idx, desired) for i in range(model.rowCount(idx)): q.append(model.index(i,0, idx)) From: pyqt-boun...@riverbankcomputing.com [mailto:pyqt-boun...@riverbankcomputing.com] On Behalf Of James Polk Sent: Tuesday, April 19, 2011 2:28 PM To: pyqt@riverbankcomputing.com Subject: Re: [PyQt] Question on QTreeView, interactive expanding/collapsing Whoops,...just found the *-hotkey,nevermind, lol... --- On Tue, 4/19/11, James Polk jpolk5...@yahoo.com wrote: From: James Polk jpolk5...@yahoo.com Subject: Question on QTreeView, interactive expanding/collapsing To: pyqt@riverbankcomputing.com Date: Tuesday, April 19, 2011, 2:09 PM Greetings All, In a typical QTreeView,...the default behaviour of clicking on a plus box, i.e. the branch boxes of the tree, yields a single box open, or in the case of collapsing, a single box closed event. Is there any way to use a keyboard modifier, like SHIFT, CTRL, and/or ALT, to expand or collapse the *whole* tree? Many other similiar tree structures in other software have this feature. For example, holding down CTRL and ALT and clicking on any box will unfold/expand (or collapse) all nodes/branches from that node and all below. Is there something I'm overlooking? Is this (re-)implementable ? Many Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Editing multiple items in QTreeView delegate
...and just to cleanup and clarify, in ms.py, I had to go back and edit it to be: global MyTreeView instead of just simply MyTreeView which I wrote before... ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QabstractItemModel.match()
hmmm, I'm not finding a match() function for either QTreeView nor QAbstractItemView... For many good code examples, try www.nullege.com ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Editing multiple items in QTreeView delegate
Well I found a solution and thought I would share it... Probably not the most elegant, but it does work.. Works by using an import global variable (told you it wasn't elegant ;-) I created a file named ms.py and inside is a single line: MyTreeView and that's all. In my main.py,...I import ms at the top. Later, I set the variable by... ms.MyTreeView = self.treeView Then in my delegate file, delegate.py, I also add import ms at the top. And then later, in the setModelData() function, after checking selectionMode() to make sure it's in multiSelect,...and after handling the main selection,I do a indices = ms.MyTreeView.selectedIndexes() and loop thru them setting their value to the value of the main selection... A side note,...when a treeView's selectionMode is set to 3 (Extended Selection), one can pull a vertical pick from top to bottom, highlighting multiple items in a single column. Then, while holding down CTRL, you can double-click selection one item out of this group. This will pass this CTRL-selection to the delegate and remove its index from the indices returned above. Which is good, so you don't double-set it's value. When you hit enter, the code will take the value of the CTRL-selection and apply it to all the others who are still highlighted, making a nice clean sweep and saving lots of keystrokes if you need to change a lot of items. Cheers, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Editing multiple items in QTreeView delegate
I have a curious dilemma I can't seem to find any information about in the docs... I have a QTreeView and a delegate... The items in the QTreeView have columns of similar data. When I set the selection behaviour to multiSelect (actually called ExtendedSelect) I can pick a single column of numbers that all have either a 1 in them. I can then CTRL-click and change one of them from 1 to 0...while all of them are still highlighted/selected. What I want to do is to simultaneously change all of them from 1 to 0 in one fell swoop. In the delegate though...if I try to use indices = treeView.selectedIndexes() it of course doesn't know anything about treeViewhow can I pass to the delegate some variable that contains an address/pointer/reference to the QTreeView, so that I can query all the selected items. I'm trying to make this work in the setModelData of the delegate. Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QTreeWidget/View: reimplementing drawTree()
Hi Phil,...thanks for your email.. mmm,..how'bout drawBranch()...is that re-implementable? To explain a bit more,...the problem I'm having is that the tree lines/branches that display in the Tree view are taking the color of the background and so appear to be invisible. By default, Maya uses a certain color scheme,... if I launch with a different color scheme (which is possible with Maya but my user base won't change) then the lines show up (as black lines on a very light-to-white background). While I have familiarity with using a delegate for handling model/view items, (Kudos to Pete ;-) it doesn't appear such a delegate is able to handle the actual line tree/branches Any thoughts? Thanks! -Jim --- On Fri, 4/1/11, Phil Thompson p...@riverbankcomputing.com wrote: From: Phil Thompson p...@riverbankcomputing.com Subject: Re: [PyQt] QTreeWidget/View: reimplementing drawTree() To: James Polk jpolk5...@yahoo.com Cc: pyqt@riverbankcomputing.com Date: Friday, April 1, 2011, 1:28 AM On Thu, 31 Mar 2011 16:09:16 -0700 (PDT), James Polk jpolk5...@yahoo.com wrote: I need to change/assign a unique color to the tree and branches of a QTreeWidget. It appears I need to reimplement the drawTree() function. While I've implemented a treeview delegate before, this is unique enough (at least to me) to have me a but stumped on syntax. I've searched high and low for documentation and examples and can't find anything definitive. Does anybody out there have any experience or knowledge that you can share on this? Many Thanks, -JP You can't reimplement drawTree() as it isn't virtual. drawRow() is however. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QTreeWidget/View: reimplementing drawTree()
I need to change/assign a unique color to the tree and branches of a QTreeWidget. It appears I need to reimplement the drawTree() function. While I've implemented a treeview delegate before, this is unique enough (at least to me) to have me a but stumped on syntax. I've searched high and low for documentation and examples and can't find anything definitive. Does anybody out there have any experience or knowledge that you can share on this? Many Thanks, -JP ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QLineEdit and AutoCompletion
Anybody have any experiences or insights they'd like to share regarding QLineEdit and programming an auto-completion function? Many Thanks, -JP ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Passing text from MainWindow to popup Dialog
Thank you very much, ER!...that worked... --- On Tue, 3/22/11, Entity Reborn entityreb...@gmail.com wrote: From: Entity Reborn entityreb...@gmail.com Subject: Re: [PyQt] Passing text from MainWindow to popup Dialog To: James Polk jpolk5...@yahoo.com Cc: pyqt@riverbankcomputing.com pyqt@riverbankcomputing.com Date: Tuesday, March 22, 2011, 6:17 PM Store your popup as a variable in the main dialog class, (self.popup = MyPopup()), and then later you can access that dialog using self.popup from your main form. On Mar 22, 2011, at 2:39 PM, James Polk jpolk5...@yahoo.com wrote: I have a scenario where my MainWindow needs to call and display a popup Window...and while the window is open, processing continues in the main application, and during processing needs to send a string or two of text to the popup dialog. I know how to call and display the popup window/dialog,..and I know how to send the popup a line of text *before* it pops upand I know how to get text *back* when it closes...but I can't figure out how to intermittently send the popup text for it to display. I have two fileslet's call them main.py and popup.py In main.py, I do a import popup as dialog This works: dialog = popAdd.AddNewRecordDialog(stuff,None) dialog.exec_() What I'd like to do inside of main.py is call.. dialog.DoIt(Whatever will be, will be) popup.py has a plainTextEdit box,...and inside a function named DoIt which is currently looking like this: (though I've tried other permutations) def DoIt(message,self): QDialog.plainTextBox.setPlainText(message) I've also tried from inside main.py: dialog.plainEditText.setText(message) but that doesn't work either,... Anybody got any ideas how to make this work?... Or, if you have another suggestions, I'm all ears... Cheers, -Jim ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Passing text from MainWindow to popup Dialog
I have a scenario where my MainWindow needs to call and display a popup Window...and while the window is open, processing continues in the main application, and during processing needs to send a string or two of text to the popup dialog. I know how to call and display the popup window/dialog,..and I know how to send the popup a line of text *before* it pops upand I know how to get text *back* when it closes...but I can't figure out how to intermittently send the popup text for it to display. I have two fileslet's call them main.py and popup.py In main.py, I do a import popup as dialog This works: dialog = popAdd.AddNewRecordDialog(stuff,None) dialog.exec_() What I'd like to do inside of main.py is call.. dialog.DoIt(Whatever will be, will be) popup.py has a plainTextEdit box,...and inside a function named DoIt which is currently looking like this: (though I've tried other permutations) def DoIt(message,self): QDialog.plainTextBox.setPlainText(message) I've also tried from inside main.py: dialog.plainEditText.setText(message) but that doesn't work either,... Anybody got any ideas how to make this work?... Or, if you have another suggestions, I'm all ears... Cheers, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Trying to import and use externally generated python script
Greetings All, I have what appears to be an import phenomena that I can't seem to make work, and was hoping someone here can help solve and explain... The snippet below is output from Maya2011 as what's called a precomp script, but it is from top to bottom a Python script. It is output from Maya, and intended to be input into an image compositing program such as Nuke, and/or Maya's new Composite program. The details of the data aren't important, but essentially it deals with how image sequences should be handled,etc. The snippet below is just a sample of the actual script. It basically contains a a couple of Class definitions, and each Class has it's own set of dedicated functions, most of them to return certain information about the database. Below the class and function definitions are actual data, that is laid out in such a way (it seems to me) to be loaded/input into the class and functions...etc... I'm actually attempting to use the data/class/functions in this file in a custom PyQt application that performs other operations on the data. I'm parsing this file to get what's called renderLayer information. But rather than simply parsing, it occurs to me that I should be able to just import this file as a .py file and run/exec/etc... My problem is,...if I just import it as is, nothing seems to happen so to speak, lol.. The data that is defined doesn't appear to have been defined at all, so I can't use the functions,etc. What's missing? How can I import this into python and utilize/access the data? Do I just need a main...and/or an exec_() ? Any and all suggestions and advice is most greatly appreciated, Cheers, -Jim #-- snip - #!/usr/bin/env python # -*- coding: iso-8859-1 -*- #--- # class RenderLayer: def getName(self): return self.name def getVersion(self): return self.version def getDescription(self): return self.description etc,etc . . . #--- # Render Layers LayerNumberOneCameraNumOne = RenderLayer() LayerNumberOneCameraNumOne.name = uLayerNumberOne LayerNumberOneCameraNumOne.anchor = uLayerNumberOne LayerNumberOneCameraNumOne.version = int(1) LayerNumberOneCameraNumOne.description = u LayerNumberOneCameraNumOne.note = u'' LayerNumberOneCameraNumOne.compositingOrder = int(5) LayerNumberOneCameraNumOne.blendMode = RenderLayer.BlendMode.Normal LayerNumberOneCameraNumOne.renderWidth = int(3000) LayerNumberOneCameraNumOne.renderHeight = int(1688) LayerNumberOneCameraNumOne.renderPixelRatio = float(1) LayerNumberOneCameraNumOne.templateFilePath = u LayerNumberOneCameraNumOne.selectedForImport = bool(1) LayerNumberOneCameraNumOne.renderPasses = [ BeautyPass, DiffusePass, SpecularPass, EtcPass, EtcPass] LayerNumberTwoCameraNumTwo = RenderLayer() etc,etc . # - snip - ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Trying to import and use externally generated python script
...am having some success in doing a from thisfile import * whereas before I was just doing... import thisfile ...the first method actually returns valid data when the functions are called... but when I try to get/print some array/list values...I get test_file.RenderPass instance at 0x0214D108 ...which I doesn't convert to ascii or whatever when I use str()... Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Trying to import and use externally generated python script
ok...just to wrap this up, lol... I've found that passing that odd instance memory address to the appropriate function, it'll return the data I need...strikes me as odd, but it works... Cheers, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Big Trouble in Little QListWidget
Somebody please put me out of my misery!... Just a simple little QListWidget... temp1 = self.ScenesListView.currentItem() print temp1 returns PyQt4.QtGui.QListWidgetItem object at 0x025089C8 and print temp1.text() returns AttributeError: 'NoneType' object has no attribute 'text' sheesh...is it me?...or is this plain nuts?...shouldn't be this hard to simply query a list I would most graciously appreciate it if someone could clue me in,... Thanks, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [Re] Big Trouble in Little QListView
...lol,...seems like every time I send an email to you guys, about 5 minutes later, I find the answer,...lol sigh What's working for me... row = self.ScenesListView.currentRow() item = self.ScenesListView.item(row) if item is not None: print unicode(item.text()) Dankashein ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] File Filtering using QFileSystemModel QTreeView
hey guys, I've read all the documentation and for the life of me, I can't find the solution to initiate simple file filtering (by extension) in QFileSystemModel, and/or using QDirModel / QDir... I just want a Treeview of files and directory, but excluding certain files by their extensionseems pretty simple, right?sigh... Thanks for any help,... Here's my code: # -- #!/usr/bin/python from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import (QDate, QFile, QFileInfo, QIODevice, QString, QStringList, QDir, QTextStream, Qt, SIGNAL) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) startDir = QString() startDir = C:/library/stuff filter = QStringList() filter = (JPG (*.jpg)); #model = QtGui.QDirModel() model = QtGui.QFileSystemModel() model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot | QDir.AllEntries) model.setNameFilters(filter) model.setNameFilterDisables(0) model.setRootPath(startDir) tree = QtGui.QTreeView() tree.setModel(model) #setDir = QtCore.QDir(startDir) #setDir.setNameFilters(filter) #tree.setRootIndex(model.index(QtCore.QDir.path(setDir), 0 )) tree.setAnimated(False) tree.setIndentation(20) tree.setSortingEnabled(True) tree.setWindowTitle(Dir View) tree.resize(640, 480) tree.show() sys.exit(app.exec_()) # --- ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] TreeView delegate operations
Having a real problem figuring this one out, am hoping you guys can shed some light on this... In my treeview, I have decoration turned off, so it looks like a table or spreadsheet,...I have a delegate (that's been working fine) that handles the display of items in the treeview, right... Across the columns of the view, there are a several different item types, an icon, text, date, time, more text,etc...have all been working fine,etc... There is a cell (let's call it cell-4) that is edited by a comboxBox in the delegate. When the user changes it by selection, I've added code in the delegate that will also change it's next door neighbor cell (let's call this cell-5) (This next-door-neighbor was originally a DateEdit cell, that presents a calendarPopup when it's edited,etc.) The problem is...I double-click on cell-4, and I change it's contents, it in turn changes cell-5's contents. However, now when I double-click on cell-5, it resets the datelosing the original date that was displaying correctly. Now the code that's run when cell-4 is edited makes sure to change cell-5 by using the same formating that happens when the program is first run,,..namely QtCore.QDate.fromString( dataString , DATE_FORMAT) ) the whole line is actually model.setData(index, QtCore.QDate.fromString( dataString , DATE_FORMAT) ) My delegate has these functions: def paint(self, painter, option, index): def sizeHint(self, option, index): def createEditor(self, parent, option, index): def commitAndCloseEditor(self): def setEditorData(self, editor, index): def setModelData(self, editor, model, index): Now I emphasize,...that run the program from startup... without modifying cell-4,..I can double-click on cell-5 all day, and it responds correctly. I would have thought that the *format* of a cell...or the data that's in it,...would stick, until changed... but that doesn't appear to be the case,...as far as my understanding of the phenomena goes, lol... Any help or advice would be greatly appreciated... Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] TreeView delegate operations
Doh!please ignore that last emailI found the problem...and it is me! For those who are using Maya and PyQt, may I offer this hard-earned pearl of wisdom?(who knows maybe somebody else will have the answer, lol) Unlike MEL,...where you can re-source the code and re-run the code to get your latest changesthis behaviour does not hold true for python and PyQt scripts *reliably*...yes, I know there is a reload() function,...but it apparently doesn't *reliably* reload underlying code from files,...uh, like your delegate files for example. Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question TreeView, delegates, and functions
Okay,..I gotta' good one for ya'll...lol I have a TreeView displaying data,..it's supported by a QStyleItemDelegate that's controlling the editing/display of various cells in the TreeView. There is a plainTextEdit window also in the main window. When a user makes a selection in the TreeView, the selectionChanged function retrieves some data and displays it in the plainTextEdit. So far so good, right? Okay, so when I double-click on a cell, the delegate properly shows me a comboBox,I pick an item and hit return, and while the cell properly updates,...the delegate doesn't trigger selectionChanged in the TreeView, and in turn, doesn't trigger the text in the plainTextEdit box to be updated either. In the delegate, in setModelData, I can intercept the proper row,column,cell,etc...but I can't find the right syntax to call the selectionChanged function because I can't determine the parent in main.py, self.selectionModel.selectionChanged.connect(self.treeViewSelectionChanged) and the function: def treeViewSelectionChanged(self): statement statement etc all normal enough,...but in the main_delegate.py...self does not mean the MainWindow in main.py... The createEditor function in the delegate file does have a parent argument, but the setModelData function does not. I'm assuming that if it did,..I could call parent.treeViewSelectionChanged() As an alternative, I thought I could just update the plainTextEdit box manually from setModelData in the delegate, but again, same problem Could I make the control self.plainTextEdit global ? so that I could call it from the delegate... Any help or advice would be most greatly appreciated, Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] modules, nameSpaces, and Wizards
Thanks Mike!, for taking time to respond... You've outlined several new ways that I had not seen, and had not occurred to me,...I want to read and go thru your examples in more detail and try them out, but just wanted to say Thanks! for sharing your knowledge and experience,.. -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Wizards and fields
I have a curiously frustrating problem concerning using fields in Wizards,...Their definition seems straightforward enough, and I had been using them in conjunction with isComplete functions,etc.. However,..here's my problem... I've created a new field based on the current setting of a ComboBox. This is created in Step 2. Later, in Step 3, I go to fetch the value of this field...wanting to get currentText, but instead I get a currentIndex value...How can I get the text and not the index? Many Thanks, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Wizards and fields
whoops...check that,...I found my problem... I was registering the comboBox field like this self.registerField(CategoryField , self.CategoryComboBox I finally found a example on Nullege, that added an extra argument, resulting in: self.registerField(CategoryField , self.CategoryComboBox, currentText ) and that did the trick! ;-) (..now I wonder if I need to include that extra argument if I do a setField later ? ) --- On Fri, 1/7/11, James Polk jpolk5...@yahoo.com wrote: From: James Polk jpolk5...@yahoo.com Subject: Wizards and fields To: pyqt@riverbankcomputing.com Date: Friday, January 7, 2011, 6:59 PM I have a curiously frustrating problem concerning using fields in Wizards,...Their definition seems straightforward enough, and I had been using them in conjunction with isComplete functions,etc.. However,..here's my problem... I've created a new field based on the current setting of a ComboBox. This is created in Step 2. Later, in Step 3, I go to fetch the value of this field...wanting to get currentText, but instead I get a currentIndex value...How can I get the text and not the index? Many Thanks, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] modules, nameSpaces, and Wizards
Good Day to All, I'd like to engage the heavy weight gurus out there, but anyone is welcome to respond,.. (Apologies for the long-winded email, but difficult to accurate explain) Though not new to software development, I'm still a bit of a green horn in PyQt, and in my usual habit of running before I learn to walk, I've began to code the fun things and glossed over a few foundation basics, one of which is modules and namespaces. I'm used to using these constructs from other languages and applications, and I had gleaned how to use these, albeit at a novice level. But now, I've got a need where I need to do something kinda' fancy, but not covered in any of the books I have, nor after web searching, so here is the dilemma... I had created 3 separate PyQt apps, each having the same development path... from Designer AAA.ui from pyuic.py ui_AAA.py then in my main program, I do the import import ui_AAA.py as AAX then write the rest,etc So, I was tasked to string these 3 apps togther into a continuing sequence,..so I looking at QWizard, and I've been successful at coding a very small, bare-bones PyQt program that puts in of the three UIs into the 1,2,3 nature of the wizard. Near the top of this program are import ui_AAA.py as AAX import ui_BBB.py as BBX import ui_CCC.py as CCX My Main Function looks like this: class MainWizard(QtGui.QWizard): def __init__(self, parent=None): QtGui.QWizard.__init__(self, parent) self.topWObject = parent self.setWizardStyle(1) self.setGeometry(400, 200, 650, 750) self.setPage(0,Step1_CreateAsset_Dialog(self)) self.setPage(1,Step2_UpdateData_dialog(self)) self.setPage(2,Step3_Publish_dialog(self)) and the Step 1 (Page0) functions is as follow: class Step1_CreateAsset_Dialog(QtGui.QWizardPage,Wizard_CreateAsset): def __init__(self, parent=None): QtGui.QWizardPage.__init__(self,parent) Wizard_CreateAsset.__init__(self) self.setupUi(self) and the other functions for steps 2 3 (Page1 Page2) are essentially identical...This all works,...and I am much relieved ;-) But here's my problem... Each of these underlying 3 apps, have their own main function, which I can copypaste in easy enough,...but also each of them have kinda' long supporting functions. After a test, I found I could brute force it, and copypaste the entire program into (and under) the stepX function above,...but rather than do that,...isn't there a way, where I can do another import statement and *link* the old-way program into the new-way (wizard) one? From other work,...I know that I could do import main_AAA.py as AAA_Main and in subsequent statements,...use the namespace like self.whatever(AAA_Main.whatever()) etc,etc...which works in the initial class definition function, but I can't find the right syntax or something to pull in all the other functions. I copied main_AAA.py to stripped_main_AAA.py and stripped out everything except the functions,...and tried to import it back into the wizard main as: import stripped_main_AAA.py as AAA_stm but calling the functions inside stripped_main_AAA.py using the nameSpace prefix AAA_stm doesn't work...the first thing it complains about are graphic elements. in stripped_main_AAA.py, there's self.WarningLabel but addressing that element back in the Wizard proram as AAA_stm.WarningLabel or AAA.WarningLabel neither works So, strategically thinking,...what's the best way to achieve this kind of program/module sharing/linking? Any thoughts, suggestions, advice, or words of wisdom, is mostly greatly appreciated, Thank you, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] modules, nameSpaces, and Wizards
well, being the hacker I am ;-) I found a convenient, but perhaps not elegant solution... I simply cat'd the stripped main file the ui_AAA.py file, so that all graphical elements get the same namespace... Still, I get the sense I'm not following good form, and would still like to hear from others on how they handle these things... Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QWizard, custom resizing windows
Doug suggested using QWizard for a multi-step process I have going, and it's working quite well, Thanks Doug! But, I'm having a small issue with tweeking the window size as I go thru each step...Unfortunately, the window contents for step 1 are much less than they are for steps 2 and 3, so the main window's height is say 400 for step1, but needs to be 750 for steps 2 and 3. I've tried all the usual ways of doing this...but there's something tricky with this one...I can make the window the proper size on startup,...but when it goes to WizardPage2,etc..I can't find a way to modify the window...subsequent resize commands have no effect. Anybody got any ideas 'bout this one?... Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] animating, rotating UI layouts,elements,etc
Happy New Year to All!,... About to start searching PyQt docs,...thought I'd ask here too... I have to create a sorta' 1-2-3 menu process for users... Thought about doing something fancy, like rotating entire layouts in and out of main window...or maybe animating (probably translation) them, etc...It appears that PyQt supports animating gifs, but what about animating entire layouts? or groups?,etc... Does anybody have any previous experience attempting such? Any thoughts or suggestions would be greatly appreciated... Cheers! -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] animating, rotating UI layouts,elements,etc
Hmmm,...I got an error when trying to run those examples in AnimationFrameworkafter some digging, it looks like that's due to QGraphicsObject being introduced in 4.6, and I'm in 4.5.3. I have to use that version in order to be compatible with Maya 2011. Will check out the Wizard class,...wasn't aware of that one, THanks! Btw,..was also looking at the embedded dialog example under Demonstrations (am looking at the C++ version demos)... ..where the layouts are skewed rectangles...might look at that code more too... Thanks guys! ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Designer settings after ui2py
Happy Holidays All, In Designer, top menuBar, Edit-Send to Back... Works as expected in Designer, but when I use ui2py to convert into regular PyQt, it seems that this gets lost in translation. Examining the .ui file, I see an XML attribute named zorder, but in the post-conversion .py file, I can see no hint of similar attribute. Is there something I'm overlooking? or is this feature just not supported? Is there any workaround? I just want to send one graphic element behind many others...a sub-background, if you will, will a unique color,etc.. Thanks! -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Designer settings after ui2py
...well I've found a workaround, lol...found a stylesheet area of attributes in Designer,...so I can continue forward,.. I'd be interested to hear or know anything about the zorder thing,... Seems like that might come up again down the road,.. Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] using HTML in a QLabel
Greetings All,.. I used PyQt's Designer to create a .ui file... In this file, I created a simple QLabel, but I wanted/needed to change the font, size, and color. In Maya, there is a custom command (loadUI) that will automatically interpret and display the UI correctly. Separately, I used pyuic to convert the .ui file into a normal .py file.. When I run this from command line (outside of Maya) everything displays properly except the QLabel. Upon examining the pyuic-generated py commands, i see that the font, size and color changes are achieved thru HTML ...like: self.thisLabel.setText( bunch of HTML ) I guess my question is...do I need to create a custom HTML delegate to handle the rendering/painting of the HTML ? Or is there an easier way ? Finally,...in the delegate examples I've seen that handle HTML, most seem to be used in conjunction with Tables, Trees,etc... I tried to setItemDelegate on the QLabel, but it complains that it's not a property,etc...so how does one associate a delegate (if that's the solution) to a single graphical item ? Any help or advice is very greatly appreciated.. Cheers, James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] using HTML in a QLabel
...Whoops,...please disregard my question... I found the problem,...was a stupid typo on my part ;-) We now rejoin your regularly scheduled program in progress ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] image utilities in Qt
I've found hints that Qt supports some image handling basics.. Is there any kind of functionality for image conversion? And/or basic image resizing, cropping,etc? Something along the lines of the ImageMagick suite of programs? All I'm looking to do (at least in the short term) is generate small thumbnail images from larger ones. Any ideas or suggestions are greatly appreciated.. Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] image utilities in Qt
Thanks Eric!...I think I found what you're referring to... http://doc.qt.nokia.com/4.5/qimage.html ...looks like scaletoWidth() etc should work! Thanks!! --- On Sat, 12/4/10, James Polk jpolk5...@yahoo.com wrote: From: James Polk jpolk5...@yahoo.com Subject: image utilities in Qt To: pyqt@riverbankcomputing.com Date: Saturday, December 4, 2010, 12:52 PM I've found hints that Qt supports some image handling basics.. Is there any kind of functionality for image conversion? And/or basic image resizing, cropping,etc? Something along the lines of the ImageMagick suite of programs? All I'm looking to do (at least in the short term) is generate small thumbnail images from larger ones. Any ideas or suggestions are greatly appreciated.. Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Sip usage problem
...very interesting,... Thank you for taking time to explain that, Pete! Greatly appreciated! ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Question about Sort/Filter behaviour
Schawt!the Date sort works vey nice now! Thanks Pete!...awesome work! ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Sip usage problem
I read the Wikipedia page that explains what SIP is and does, though I can't say I understood everything it explained ;-) I'm getting a SIP usage error and I was hoping someone here could help me understand the phenomena... In my program (which borrows heavily from the BasicSortFilter example) near the top, I have the line sip.setapi('QVariant', 2) My limited understanding is that this is doing some kind of type mapping,...or type casting (pardon the pun)... Apparently, this statement has bearing on the filterRegExpChanged function. Now the code I'm writing gets import into Maya, which as probably many know, is now fully Python/Qt/PyQt compliant (well sorta', lol) So when I launch my script, I get an error which I'm assuming indicates that somewhere during Maya's own launch, it does a sip.setapi('QVariant', 1) ...but that's speculationMaya's error message is: # Error: API 'QVariant' has already been set to version 1 Now, I've kinda' found a hack around this to get it to actually work in Maya, but I'm worried I might be adversely affecting other PyQt scripts,etc...and I'd to understand what's going on more... I'd be very grateful if someone could explain what this little statement is doing behind the scenes... Thank you very much, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question about Sort/Filter behaviour
Hi All, Before asking this question, I did side-by-side testing and confirmation of the sorting results in both the Basic and Custom examples... Even compared the C++ vs Python generated code, same results... I also checked this on Pete's newly posted custom example.. The observation is this...it appears that typing text into the pattern line generates a behaviour that is *always* regExp behaviour... For example,...supposed I set filterColumn to Date filterSyntax to Wildcard and finally, in filterPattern, I type 1/* (with no quotes) I would expect to get a view returned with with all the January dates...but I get nothing... If I remove the slash (/), leaving 1*, I get everything, or better said I get the behaviour of regExp,if you switch filterSyntax to regular expression, you'll get the same results... Another example...set filterColumn to Date Type 12: (no quote) into filterPattern. Now keep switching filterSyntax from regExp, Wildcard, and Fixed String, and every time you get the same output... There are other examples I can provide too There appears to be something odd going on here...at the very least, it doesn't appear to conform to Unix-like standard conventions of regularExpression and/or Wildcard interpretation... Is it just that the Date data is set up odd? I tried a similar example on the Sender column, but get same kind of results... Lastly,...I set filterColumn to Subject filterPattern to Sports (again , no quotes) sequencing thru filterSyntax,going from regExp, to Wildcard, to Fixed String, I always get the same output... At least on Fixed String, I would expect to get 1 returned record, but it's behaving like it's a regExp,...ignoring the RE: etc and the AW: etc non-matching cases... Does this strike anyone else as odd? or am I just going crazy?..lol Thanks, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Installing PyOpenGL
Since it took me such a long while to get just the proper versions of Python/Qt/PyQt installed (to sync with Maya 2011), I thought it might be wise to ask beforehand,... Apparently I need to install PyOpenGL,would doing so conflict with, or disable, or modify,etcmy existing installation of Python, Qt, and/or PyQt ? Any words of wisdom most greatly appreciated... Many Thanks, Btw,...does Qt have any graphics/framebuffer capture ability ? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] embedding iconic pushButton in TableView and/or TreeView
'nuther wh!...I got a button!, lol... A button in the first column of a TreeView on startup.. Unfortunately, it's not a PushButton, so it's not pushing, lol... but surely that's something I'm overlookingbut apparently QStyleOption has no PushButton,but maybe I need to pass an argument type when declaring,... class DabDelegate(QStyledItemDelegate): def __init__(self, parent=None): super(DabDelegate, self).__init__(parent) def paint(self, painter, option, index): if index.column() == 0: # Thumbnail parent = self.parent() button = QStyleOptionButton() button.rect = option.rect QApplication.style().drawControl(QStyle.CE_PushButton, button, painter) else: QStyledItemDelegate.paint(self, painter, option, index) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] embedding iconic pushButton in TableView and/or TreeView
Just remember, that small self contained examples of such issues are the ultimate weapon to engage them... Pete lol, totally,...I went back to Mark Summerfield's book again (and other examples)... I'm soo close...but still a step or two go... Finally figured out how to use my delegate's sizeHint to adjust the row height in a QTreeView.. def sizeHint(self, option, index): fm = option.fontMetrics if index.column() == 2: # LongName, but could be any column # text = index.model().data(index) document = QTextDocument() document.setDefaultFont(option.font) return QSize(document.idealWidth() + 5, 50) return QStyledItemDelegate.sizeHint(self, option, index) ...the 50 being the height I needed for a 50x50 icon image in the first column So,...it finally occurred to me that when MarkS says a delegate can have total control...then that must mean everything must pass thru the paint function...which strikes me as more of a filter than a function,..but anyways... Right now, I have def paint(self, painter, option, index): if index.column() == 0: # Thumbnail parent = self.parent() iconFile = index.model().data(index, Qt.DisplayRole) button = QPushButton(Icon, parent) icon = QIcon(iconFile) pixmap = icon.pixmap(QSize(50, 50) ) button.setIcon(icon) painter.save() painter.drawPixmap(0, 0, 50, 50, pixmap ) painter.restore() else: QStyledItemDelegate.paint(self, painter, option, index) So, even though there's a PushButton definition in there, I still can't get it to display at startup. I have been able though to define an Icon and Pixmap, (passing the image filename from data() ) but painter only wants (it appears) to draw a pixmap, and not a pushbutton...so I'm kinda' stuck there at the moment... But I do have these pixmaps showing at startup...so I'm think I'm tantalizing close to a solution... Now it might be,...that I may not absolutely need a pushbutton type.. I just need to enable the user that once they click on pixmap/button that it would execute a function. Even that could be argued away with,...by proving a RMB (rightmousebutton) pulldown menu in the main view...Even so, I'd still like to understand and know how to do the former,etc.. Anyways,...Any suggestions greatly appreciated...and Thanks again, Pete, for your help and interest, Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [QtDesigner] Docs in Python ?
When I run QtDesigner (the one that lives in ../PyQt4/bin/)... When I run Help from the menuBar, all of the examples (as far as I can tell) are in C++... Is there a version of this help in Python? Cheers, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] embedding iconic pushButton in TableView and/or TreeView
I've transcoded the stardelegate example a few weeks ago, which uses a custom widget in a QTableView, but due to the model/view/delegate pattern, that should be easy to map onto your problem. Pete Thanks for your reply, Pete... I reread chap's 14,15, and 16 from Mark Summerfield's book overnight, and it made things a bit clearer...I need to create a custom delegate... I think I also need to do a sanity check about whether to use QTableView or QTreeView. Since the heart of my application is to be able to sort various categories based on various criteria, I chose to use the example program BasicSortFilter as a starting point,...the SortFilter process gives me just what I need, and it used QTreeView with decoration(false) to make it appear tabular. It also looks like custom delegates are easier to implement in TableView, rather than TreeView, but that difference may be more superficial than real. I'll do a search for your stardelegate code and see what I can learn from it. Many Thanks for offering that ;-) Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] embedding iconic pushButton in TableView and/or TreeView
WhoI got a custom delegate installedat least partially, lol... Using the basic QItemDelegate I've first tried a comboBox, which seems a little more straightforward,.. When using QTableView,...the index.column() calls want text matching the column headings,...but in QTreeView, the same call wants an integer index#...so my code looks like... def createEditor(self, parent, option, index): if index.column() == 0: # Thumbnail button = QPushButton(parent) return button if index.column() == 4: # Format comboBox = QComboBox(parent) comboBox.addItem(ma) comboBox.addItem(mb) comboBox.addItem(obj) comboBox.setEditable(True) return comboBox return QItemDelegate.createEditor(self, parent, option, index) I was all in celebration mode,...until I began to add the initial pushbutton/icon in the first column.Right now, I'm just using QPushButton and will add the image/pixmap later... Well..the danged curious thing isthat when I run the code, and double-click on the cells of the first column, the custom delegate dutifully returns a nice PushButtonbut my conundrum is that I still can't figure out how to add the PushButton to the QTreeView on startup!...sigh You may recall the data layout I'm going for is something like... 1 [icon1] data data data etc 2 [icon2] data data data etc 3 etc 4 etc ...and later,...when a user binks on the icon, it will need to execute a command... So,...some progress, but still more jungle ahead,lol...sigh Maybe I'll go reread your stardelegate code again ;-) Cheers, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] embedding iconic pushButton in TableView and/or TreeView
Hans, I'm sure you're right, but I'm still a little dense about this, lol... All the examples of spinDelegates that I've seen are using integers, and are present in every cell...usually in QTableView... I'm using QTreeView, and I only want a pushButton/Icon in the first column,...I've spent about six hours trying different things... I have a simple example using a TreeWidget just by itself...but I can't seem to incorporate that into the larger program (QTreeView, and QSortFilterProxyModel). I guess I'll back to my SummerField book and start reading about delegates again... Any help or advice would be very greatly appreciated,.. Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] using pickle to save contents of QSortFilterProxyModel
Hi,..I'm trying to save the contents of a QSortFilterProxyModel (self.proxyModel) as a pickle format file. The code below appears to work, but unfortunately, there's nothing in the filezero size file.. def saveAsPickle(self): fname = C:/tmp/pick.dat file = open(unicode(fname), w) newModel = self.proxyModel pickle.dump(newModel, file) So, I decided to take step back and save the file as simple text, and that works fine...so I know the data in self.proxyModel is good and is there... After several hours of tinkering and research,...I'm a bit stumped. I read somewhere...that the statement newmodel = self.proxyModel was necessary,...or advised,..though I'm not totally clear why.. Would it have something to do with the presence of an item in the database stored as QtCore.QDateTime(QtCore.QDate(2010,11,2)), ...which is also printed/saved out as that in the simple text save function...All other data in the model are simple strings...at least as of yet,...plan is to add an image/icon in there somewhere.. Although there seem to be a lot of examples out there that deal with basic use of pickle,..I haven't found any dealing with QSortFilterProxyModeland/or QTable-, QTree-, QListView... Is there another preferred way of saving data from these three elements? This is the class/init part at the top class Window(QtGui.QWidget): def __init__(self): super(Window, self).__init__() self.proxyModel = QtGui.QSortFilterProxyModel() etc etc Any help or advice would be greatly appreciated,.. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] refreshing QTreeView
Good Day to All, Been writing code for years, but still a bit green when it comes to PyQt, so please forgive my syntactically lacking question(s) ;-) I'm hacking a derivative of the (famous?) packaged example that comes with PyQt4 (and Qt), namely basicsortfiltermodel.pyw from ../examples/itemviews in PyQt4... I've added a little popup menu (let's call this B.py) that one can launch from the BasicSort-derivative (let's call this A.py). I believe I'm correcting adding new data (a new record) to the QSortFilterProxyModel(). (I think this because I'm not getting any errors now, after some effort) But I seem to be unable to get the QTreeView to refresh. I've scoured the Qt class docs and Google'd the heck out of it (seems like a common question from the looks of it, lol).. Now I know this is an ugly hack, but just to try to get it to work (elegance can come later is my theory)... At the bottom of A.py, I declared a global wX, global wX; [...] window = Window() wX = Window() window.setSourceModel(createMailModel(window)) so that when I hit a button later, I could more easily get a hold of the parent value found in the runtime createMailModel. From which I get the model handle.. model = QtGui.QStandardItemModel(0, 17, WinX) addMail(model, image, tabl00, etc etc) Anyways,..I think this is working But after adding a new record via addMail(), I can't seem to get self.proxyModel to refresh itself.. I'm pretty sure this a stupid newbie issue, lolbut could anyone help shed some light on how to make this work? Many Thanks, -Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] refreshing QTreeView
test ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] refreshing QTreeView
...well in a burst of inspiration, or was that the caffeine,...I hit upon something that worksessentially bypassing the middleman, so to speak...instead of calling addMail(),...I just do what addMail does/ did before... So, now,..my code snippet looks like this def addNewRecord(self): print(adding new record) dialog = popup.AddNewRecordDialog(self.record,self) if dialog.exec_(): self.record = dialog.DoIt() print(self.record) recPart = self.record.split(,) self.proxyModel.insertRow(0) self.proxyModel.setData(self.proxyModel.index(0, 0), recPart[0]) self.proxyModel.setData(self.proxyModel.index(0, 1), recPart[1]) self.proxyModel.setData(self.proxyModel.index(0, 2), recPart[2]) etc etc ...so this works, but ideally so,It appears to overwrite some data in the model,...but when I change filter settings and the model refreshes, I can see all the data nowso, still some work to do...sigh ...and I'm still a little fuzzy about how Python handles modules, namespaces, and passing data around to functions... ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] embedding iconic pushButton in TableView and/or TreeView
Hello, I'm trying to figure out how embed a pushButton (with iconic image preferrably) in the first column of a TableView (or TreeView in QSortFilterProxyModel). This is something that is pretty easy to do in MEL (Maya's command language) but apparently seems pretty tricky to do in PyQt. I've searched high and low and can't find any examples of, or posts discussing, using such a technique. Is this possible? and if so, I would greatly appreciate any light someone could shed on this... Simply put,...in a table- or treeView.. 1 2 3 etc 1 iconButton1 text text 2 iconButton2 text text 3 iconButton3 text text etc ...where each iconButton is unique and associated with its accompanying data. Each row represents a unique record, so icon1 (when clicked) initiates an action using data from record1, and so on,etc. Essentially, the image in each icon is a picture representation of the data in each associated record. Any help or info is most greatly appreciated, Cheers, Coleslaw ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt