Re: [PyQt] PyQt4 question about type-to-select in numeric drop-down lists

2013-08-29 Thread Sarah Mount
On Tue, Aug 27, 2013 at 9:44 PM, David Boddie da...@boddie.org.uk wrote:

 On Tue Aug 27 15:53:59 BST 2013, Sarah Mount wrote:

  sorry if this is a bit of a n00b question, but hopefully someone can
  clarify a misunderstanding for me. I am working with some colleagues on a
  Python2.x PyQt4 project and the GUI for this software has several
 drop-down
  lists where each entry in the list is an integer, in numerical order. We
  have had a (reproducible) bug report about these.

 No problem. Sometimes what seems to be the simplest things can have
 surprising behaviour.


Indeed :)


  When a user clicks on the drop-down and types a number, the drop-down
  scrolls to select that number. So, [contrived example] if the drop-down
  contains entries 0-1000 and the user types 23, the drop-down scrolls to
  reveal 23 (if necessary) and selects that entry on the list. So far, so
  standard.
 
  If the user selects a number with repeated digits, i.e. any multiple of
 11
  (in reality only tested on numbers 100) the wrong number is selected.
 For
  example, if I open a drop-down and type 77 70 gets selected. Is this
  some obvious bug in the way we have configured our GUI or have I
  misunderstood something really basic?

 No, I think it's a bug in Qt, and probably in QAbstractItemView because
 that's what is providing the underlying list logic in the drop-down menu.
 The behaviour seems to be that the string used to search the data is
 checked
 to see if it is simply the same first character repeated throughout the
 string (e.g., aaa or 333) and handled specially. This seems to
 completely
 break the regular behaviour: if you try 77, it won't work, but 776 will
 cause it to navigate to the correct item.


That makes sense. Is there an issue tracker I can submit this to?



 If anyone wants to sanity check my reasoning, I think the problem is in
 QAbstractItemView::keyboardSearch().

 I can't immediately suggest a workaround. My instinct would be to use a
 completer to influence the way QComboBox finds items but I don't know if
 that will help, especially when the drop-down is open.


I think in reality it is not a huge issue for users, although it's not
ideal. I would guess that most integer input is probably not appropriately
done with drop-downs!

Thanks,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] PyQt4 question about type-to-select in numeric drop-down lists

2013-08-27 Thread Sarah Mount
Hi everyone,

sorry if this is a bit of a n00b question, but hopefully someone can
clarify a misunderstanding for me. I am working with some colleagues on a
Python2.x PyQt4 project and the GUI for this software has several drop-down
lists where each entry in the list is an integer, in numerical order. We
have had a (reproducible) bug report about these.

When a user clicks on the drop-down and types a number, the drop-down
scrolls to select that number. So, [contrived example] if the drop-down
contains entries 0-1000 and the user types 23, the drop-down scrolls to
reveal 23 (if necessary) and selects that entry on the list. So far, so
standard.

If the user selects a number with repeated digits, i.e. any multiple of 11
(in reality only tested on numbers 100) the wrong number is selected. For
example, if I open a drop-down and type 77 70 gets selected. Is this
some obvious bug in the way we have configured our GUI or have I
misunderstood something really basic?

Thanks,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Possible bug in QScinitlla annotations

2011-04-27 Thread Sarah Mount
Hi everyone,

I have a GUI (PyQt4, Qt4.7.2, Python2.7, QtDesigner 4.7.2, Ubuntu
Natty) with two QScintilla panes. I have a SLOT that adds annotations
to certain lines, which I want to be styled. I've created the GUI in
Designer, and my own code styles both editor panes in the same way, so
I would expect there would be no difference between the two. When I
add an annotation to each editor for testing, one is styled in the
annotation style I have set and the other isn't. Oddly, it's always
the right hand pane which is wrong, if I swap them over like this:

self.leftEditor, self.rightEditor = self.rightEditor, self.leftEditor

then it's still the right hand pane which is incorrect.

I made a cut down version of the GUI just to show you what the bug
looks like: http://imgur.com/dcRbi In the image, both annotations
should look like the left hand one, with a yellow background and
smaller, italicized text. The code which generates this I've put here:
https://gist.github.com/944268 there's still quite a bit of
irrelevant code there, as I can't really be sure what's causing the
bug.

Is it me or is this a problem with QScintilla?

Thanks (yet again),

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie resizing dock widgets question

2011-04-26 Thread Sarah Mount
On Tue, Apr 26, 2011 at 21:45, David Boddie da...@boddie.org.uk wrote:
 On Mon Apr 25 21:50:43 BST 2011, Sarah Mount wrote:

 In designer-qt4 the object inspector, widget box and so on seem to be
 QDockWidgets. I'm making a GUI in Designer that I want to be similarly
 structured. In designer the edge of each QDockWidget can be grabbed
 with the mouse and resized, but in my GUI this isn't possible. I
 *think* I've set all of the dockWidget properties and the widgets can
 be closed and floated, but not resized. Have I misunderstood this? Is
 there some sort of splitter object that needs to be placed between the
 dockWidgets? Or some property set in the layout managers?

 Which version of Qt Designer are you using? Did you manually place the
 dock widget into a layout?

This is Designer 4.7.2 on Ubuntu Natty and the docks are going inside
a Main Window widget, with a grid layout applied to them.

 In older versions of Qt Designer, dropping a dock widget onto a main window
 form simply left it floating, unmanaged, unless the central area was
 managed by a layout. In newer versions, the dock window is automatically
 docked by default - at least, it seems that way.

 If you have a dock window embedded in a main window, and you can't move it
 when you preview the form, try breaking the layout of the window, selecting
 the dock widget, and setting its docked property to true. It should appear
 in one of the dock areas around the sides of the window and be handled
 separately to the widgets in the main window itself.

This seems to be the problem, and like you say, if I break the layout
and set the widgets to docked they become resizable, oddly.

However, I have three QDockWidgets, one that is intended to stretch
over the bottom of the main window, and the other two above it side by
side, like this:

[][]
[  ]

I've set all of the sizePolicy properties to Expanding; the lower
dockWidget expands correctly both horizontally and vertically. The top
two widgets will expand vertically but leave a large gap in the centre
of the main window when resizing the main window horizontally. This
worked just fine when I was applying a grid layout to the
centralWidget. Any ideas? It all seems a bit counter-intuitive to me!

Many thanks again,

Sarah



-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie resizing dock widgets question

2011-04-26 Thread Sarah Mount
On Wed, Apr 27, 2011 at 00:10, Andreas Pakulat ap...@gmx.de wrote:
 On 26.04.11 23:45:58, Sarah Mount wrote:
 However, I have three QDockWidgets, one that is intended to stretch
 over the bottom of the main window, and the other two above it side by
 side, like this:

 [][]
 [  ]

 I've set all of the sizePolicy properties to Expanding; the lower
 dockWidget expands correctly both horizontally and vertically. The top
 two widgets will expand vertically but leave a large gap in the centre
 of the main window when resizing the main window horizontally. This
 worked just fine when I was applying a grid layout to the
 centralWidget. Any ideas? It all seems a bit counter-intuitive to me!

 Sounds like you're using the wrong tool for the job. dock widgets are
 supposed to be moveable around the 4 areas above, below and next to the
 central area. The intent is to have a central widget or widgets and the
 dock-areas contain helper tools for working on the central widget. If
 all you want is one widget stretched alongside the bottom and two above
 that share the space, then use normal widgets and a grid-layout for
 that.


The two top widgets are QScintilla widgets, I wanted them to be
resizable and closable so you can choose to only edit one pane at a
time. As I understand it, QDockWidgets are the only widgets that have
those properties, or am I wrong?

Thanks,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie resizing dock widgets question

2011-04-26 Thread Sarah Mount
On Wed, Apr 27, 2011 at 00:17, David Boddie da...@boddie.org.uk wrote:
 On Wednesday 27 April 2011, Sarah Mount wrote:
 On Tue, Apr 26, 2011 at 21:45, David Boddie da...@boddie.org.uk wrote:
 

snip: long docking discussion

 The center widget or central area in the main window is a normal widget
 that you can place any other widgets in. This includes dock widgets, but
 they aren't designed to be used like that. They are supposed to be managed
 separately by the main window, outside the central area. Qt Designer does
 a reasonable job of letting you configure this, but it is constrained by its
 widgets-on-a-form approach to UI design.

 If it turns out that you aren't using all the features of dock widgets in
 your application, you can design the kind of UI you describe using splitters
 instead. If you want to do that, just ask and I can give more details.


Thanks, that diagram made a lot of sense, I've re-worked the GUI with
splitters, and, like you say, that's much more what I was looking for.
I didn't realise that splitters could be resized, and I can add some
actions for closing each pane.

Many thanks,

Sarah
-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Newbie resizing dock widgets question

2011-04-25 Thread Sarah Mount
In designer-qt4 the object inspector, widget box and so on seem to be
QDockWidgets. I'm making a GUI in Designer that I want to be similarly
structured. In designer the edge of each QDockWidget can be grabbed
with the mouse and resized, but in my GUI this isn't possible. I
*think* I've set all of the dockWidget properties and the widgets can
be closed and floated, but not resized. Have I misunderstood this? Is
there some sort of splitter object that needs to be placed between the
dockWidgets? Or some property set in the layout managers?

Thanks for your help,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Using layouts in a tab widget

2011-04-24 Thread Sarah Mount
Sorry if this is an obvious question, but I couldn't find an answer to
it on the using-containers page or on StackOverflow. I have a bunch of
tab widgets that need to have appropriate layouts applied to them and
to the tabs they contain. Working with the .ui files in Qt4 Designer,
I notice that if I click on an individual tab inside the tab widget,
then it is by default marked as break layout, like every other
widget. If I then try to apply a layout to the tab, the layout instead
gets applied to the whole tab widget. So, to get around this I could
put a GroupBox or Frame inside each tab and give that a layout, but
this seems long-winded. Is there something obvious I have missed or
does Qt assume that each tab will have a container widget placed
inside it?

Many thanks,

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Using layouts in a tab widget

2011-04-24 Thread Sarah Mount
On Sun, Apr 24, 2011 at 07:53, Vincent Vande Vyvre
vincent.vandevy...@swing.be wrote:
 Le 24/04/11 08:10, Sarah Mount a écrit :

 Sorry if this is an obvious question, but I couldn't find an answer to
 it on the using-containers page or on StackOverflow. I have a bunch of
 tab widgets that need to have appropriate layouts applied to them and
 to the tabs they contain. Working with the .ui files in Qt4 Designer,
 I notice that if I click on an individual tab inside the tab widget,
 then it is by default marked as break layout, like every other
 widget. If I then try to apply a layout to the tab, the layout instead
 gets applied to the whole tab widget. So, to get around this I could
 put a GroupBox or Frame inside each tab and give that a layout, but
 this seems long-winded. Is there something obvious I have missed or
 does Qt assume that each tab will have a container widget placed
 inside it?


 No, you don't need groupBox or frame for that.

 Place your widgets in first tab,
 choose an appropriate layout for these widgets,
 whith this layout selected, select the whole tabWidget and apply a vertical
 layout.

 Do the same for each tab.

 Now, select a tab in objects inspector and scroll the properties editor and
 you'll see the properties for each layout.


Ah... so you select *all* the objects and Designer inserts a Layout
object for you. Thanks, I had no idea that was possible!

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Styling an QMdiArea widget

2011-04-18 Thread Sarah Mount
On Mon, Apr 18, 2011 at 01:14, David Boddie da...@boddie.org.uk wrote:
 On Sun Apr 17 19:48:16 BST 2011, Sarah Mount wrote:

 Thanks, you and David were both right, the error was an incorrect path
 for the JPG. However, what I was after was to have one image appear in
 the background, and not to have the image tiled. This is possible
 using a style sheet, but I'm not sure a) if it's possible using a
 brush (your code comes out with the image tiled) or b) whether it's
 possible to use a style sheet, as my code for that didn't work!

 I think the answers are:

  a) You can't really use a brush for this because it only supports
    tiled textures.
  b) QMdiArea doesn't support style sheets:
    http://doc.qt.nokia.com/4.7/stylesheet-reference.html

 However, I looked at qtconfig, one of the tools shipped with Qt, and it
 seems that there's a trick you can use if you are able to create a QMdiArea
 subclass and use that instead of a regular QMdiArea widget:

 http://www.diotavelli.net/PyQtWiki/Adding_a_background_image_to_an_MDI_area


Thanks, that looks like just the thing!

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Styling an QMdiArea widget

2011-04-17 Thread Sarah Mount
On Sun, Apr 17, 2011 at 15:28, Vincent Vande Vyvre
vincent.vandevy...@swing.be wrote:
 Le 17/04/11 15:17, Sarah Mount a écrit :

 Hi everyone,

 I have a main application window that I want to style with a style
 sheet like this:


 #mywidget {
 background : white;
 background-image : url(:/images/images/EfDChancoComposite.jpg);
 background-repeat : no-repeat;
 }


 When the project is created, the widget that I want to apply the CSS
 to becomes an MDI area, so presumably the styling now needs to apply
 to the MDI area, not the original widget, like this:


 class MyMainWindow(QtGui.QMainWindow, Ui_MainWindow):
 def __init__(self, parent=None):
 QtGui.QMainWindow.__init__(self)
 self.setupUi(self)
 self.mdi = QtGui.QMdiArea()
 self.mdi.setStyleSheet(QMdiArea { background : white;
 background-image : url(:/images/images/EfDChancoComposite.jpg);
 background-repeat : no-repeat; })
 self.setCentralWidget(self.mdi)


 ...but that doesn't work! Is this because QMdiArea widgets can't be
 styled with CSS, and if so, is it possible to use a QBrush to do this
 (including the no-repeat directive)? Or, have I just misunderstood the
 API?


 Many thanks,

 Sarah

 Hi,

 You can use setBackground()

     self.brush = QtGui.QBrush(QtGui.QPixmap(view.jpg))
     self.mdi.setBackground(self.brush)

 but reimplement sizeEvent() for rescale the pixmap


Thanks, tried that code and the image doesn't appear :( There's no
traceback so it's difficult to figure out why...

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Styling an QMdiArea widget

2011-04-17 Thread Sarah Mount
On Sun, Apr 17, 2011 at 16:48, Vincent Vande Vyvre
vincent.vandevy...@swing.be wrote:
 Le 17/04/11 16:36, Sarah Mount a écrit :

 On Sun, Apr 17, 2011 at 15:28, Vincent Vande Vyvre
 vincent.vandevy...@swing.be wrote:

 Le 17/04/11 15:17, Sarah Mount a écrit :

 Hi everyone,

 I have a main application window that I want to style with a style
 sheet like this:


 #mywidget {
 background : white;
 background-image : url(:/images/images/EfDChancoComposite.jpg);
 background-repeat : no-repeat;
 }


 When the project is created, the widget that I want to apply the CSS
 to becomes an MDI area, so presumably the styling now needs to apply
 to the MDI area, not the original widget, like this:


 class MyMainWindow(QtGui.QMainWindow, Ui_MainWindow):
 def __init__(self, parent=None):
 QtGui.QMainWindow.__init__(self)
 self.setupUi(self)
 self.mdi = QtGui.QMdiArea()
 self.mdi.setStyleSheet(QMdiArea { background : white;
 background-image : url(:/images/images/EfDChancoComposite.jpg);
 background-repeat : no-repeat; })
 self.setCentralWidget(self.mdi)


 ...but that doesn't work! Is this because QMdiArea widgets can't be
 styled with CSS, and if so, is it possible to use a QBrush to do this
 (including the no-repeat directive)? Or, have I just misunderstood the
 API?


 Many thanks,

 Sarah

 Hi,

 You can use setBackground()

     self.brush = QtGui.QBrush(QtGui.QPixmap(view.jpg))
     self.mdi.setBackground(self.brush)

 but reimplement sizeEvent() for rescale the pixmap

 Thanks, tried that code and the image doesn't appear :( There's no
 traceback so it's difficult to figure out why...

 Sarah

 Strange, if I use this code that works:

 class MyMainWindow(QtGui.QMainWindow):
     def __init__(self, parent=None):
     QtGui.QMainWindow.__init__(self)
     self.mdi = QtGui.QMdiArea()
     self.setCentralWidget(self.mdi)
     pix = QtGui.QPixmap(img.jpg)
     self.brush = QtGui.QBrush(pix)
     self.mdi.setBackground(self.brush)


Thanks, you and David were both right, the error was an incorrect path
for the JPG. However, what I was after was to have one image appear in
the background, and not to have the image tiled. This is possible
using a style sheet, but I'm not sure a) if it's possible using a
brush (your code comes out with the image tiled) or b) whether it's
possible to use a style sheet, as my code for that didn't work!

Any advice greatly appreciated.

Sarah


-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt