I want to make a list of custom widget vertically aligned, where I dynamically add the custom widget inside a scroll Area.
If I click on "add image", a custom widget is added to the scroll area with vertical layout.
like this :
Note that I didn't succeed to make the scroll Area expand as I add widget inside, I had to put a big minimum height to make a scrollbar appear.
The second issue is, when i add like this my widget they are spaced to much, and not added under each other. To prevent this I tried to add a vertical spacer. However, with the vertical spacer, the widget added by clicking on "add image" does not appear anymore (I use insertWidget(Vlayout.count()-1, mycustomwidget)
I organised everything like this :
the pushbutton is an example, I add my custom widget here.
Why the scroll Area doesn't expand as I had widget ? I tried :
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scroll.setWidgetResizable(True)
Why, when I had a spacer, the widget does not appear anymore ?
Related
I am still new to this and I need some help in inserting a scrollbar to scroll the circled area just in case the list gets long in future. Thanks in advance.
The image is included here.(the circled area is actually an individual frame so is there any method to add scrollbar to that?
The usual way to do this is to create a canvas with scrollbars and then place the frame which contains the checkbox widgets on the canvas with create_window.
I have a QStackedWidget with a QLineEdit and a couple other widgets inside of it. This QStackedWidget is fairly dynamic - you can move it within its layout by clicking/dragging, change its current widget by right clicking it, etc.
I'd like to draw a simple, gray rectangle or a gray rounded rectangle around the QStackedWidget to let people know that the QLineEdit they're looking at is important. This drawn rectangle has to be able to follow the QStackedWidget so that it follows properly with the widget when I move it to other locations on-screen.
I've tried several approaches so far but they've all fallen short in some regard or another or it just wouldn't move with the widget. Can anyone show me how?
Depending on how your clicking/dragging is implemented, you should just be able to place the QStackedWidget inside another QFrame, or put a QFrame inside your QStackedWidget and put all the other controls inside the QFrame. QFrame's support drawing borders around them.
frame = QFrame()
frame.setFrameStyle(QFrame.StyledPanel)
frame.setLineWidth(2)
I want to auto resize the above picture at the size shown below when user resize the main window.
Is there any function to do this in pyqt4?
I was searching for an answer to this problem... but i can't find something related.
I've tried to set fixed minimum size but this doesn't work.
How to auto resize a window in pyqt4 (python)?
pictures is got in qtdesigner.
If you are using the QtDesigner, then its really easy. Have a look at layouts like vertical layout, horizontal layout
Follow step:
1. Add layout to your main window.
2. Right click main window and click 'layout vertically' as you want button below
the text area
3. Then add(drag-n-drop) your text area inside vertical area.
4. Add button and what not....
5. Have a look at 'http://doc.qt.io/qt-4.8/designer-layouts.html' google for
properties of layout like alignment of element. size, orientation.
Experimenting with Gtk+3 in python.
Trying to add a "Gtk.TreeView" inside a scroll window container to a grid window along with an entry box. The problem is that the scroll area is tiny and as a result you can barely see any of the scroll window/TreeView. Here is an image of the output:
The relevant code is:
scroll = Gtk.ScrolledWindow() # Create scroll window
scroll.add(self.MatchTree) # Adds the TreeView to the scroll container
grid = Gtk.Grid() # Create grid container
self.add(Grid) # Add grid to window (self)
Grid.add(scroll) # Add scroll window to grid
Grid.attach_next_to(self.Entry, scroll, Gtk.PositionType.BOTTOM, 1, 1) # Attach entry to bottom of grid.
So how do you control the size of the scroll area?
Cheers,
Phil
What you need to do is to set the hexpand and vexpand attributes of the GtkScrolledWindow to True. You can do this on object creation like this:
scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
If you are up to it, I recommend you use Glade to work your program's interface, it makes a lot simpler to work out this kind of problems, since you have easy access to all the widgets properties.
I am creating a Solitaire clone using Python's Tkinter window toolkit. My window contains a main canvas, and within the main canvas a series of widgets that inherit from Canvas that hold the cards. I have implemented a "Drag to Move" system where a user can click the mouse down to select a card in one of the inner canvases, drag it to a new canvas, and let go to place the card into the receiving canvas.
The Problem: I want to draw the cards in motion between the canvas on which they are drawn, and the canvas they are moving to, so the user can see them moving across the screen during the click and drag motion. When I try to draw cards in-between the canvases that I already have, they are always drawn behind, meaning I can only see cards through the padding around the inner canvases.
Here is an example where I drew several of them so the effect could be seen clearly, and the inner canvases are also clearly visible.
What I've Tried: I've tried to move the canvases back using Misc.lower(aCanvas), but i wasn't able to create the desired effect. I've also tried to design a custom overridden cursor, but it seems my cursor size is limited to 32px*32px, which is insufficient for the size of the card images I want to move.
My Question: How can I draw on top of a canvas that is inside of another canvas? If I can't, how would you solve this problem?
You cannot do what you want. Embedded widgets are always above the canvas items.
Why is it that you are embedding canvases insidebcanvases? Why not just use a single canvas?