PyQt - QGridLayout without changing Qwidget Geometry? - widget

I'm working with PyQt and I was wondering if there is any way to set a grid layout in a window so that, for example, one button's geometry wouldn't be affected by the configuration of the layout - because I'm trying to have my button in a square shape and, with the grid layout, it always becomes a long rectangle.
Also, I have multiple rows and columns, and to edit each minimum size would be horrifying. So, is there is any way to establish the geometry of a widget in a grid layout?
UPDATE: my grid
self.Grid = QtGui.QGridLayout()
self.Grid.addWidget(self.Button1,0,0)
self.Grid.addWidget(self.Box1,2,1)
self.Grid.addWidget(self.Box2,2,3)
self.Grid.addWidget(self.Button2,0,4,Qt.AlignRight)
self.Grid.setRowMinimumHeight(1,50)
self.Grid.setRowMinimumHeight(1,50)
self.Grid.setRowMinimumHeight(3,250)
self.Grid.setColumnMinimumWidth(0,100)
self.Grid.setColumnMinimumWidth(2,50)
self.Grid.setColumnMinimumWidth(4,100)
self.setLayout(self.Grid)

Given the example code in your question, just add something like the following:
self.Button1.setMinimumSize(50, 50)
self.Button1.setMaximumSize(50, 50)
or:
self.Button1.setFixedSize(50, 50)

Related

KDE widget - problem with icon size and the parent item

I would like to modify the KDE widget User Switcher to let the user decide the size of the icons to be shown in the fullRepresentation view. The user set a value in a combobox in the settings, and the view should automatically update.
To achieve this, I've added the code iconSize: getIconSize(combo_currentIndex) in each ListDelegate instance. Here, getIconSize is a simple javascript function that returns the specified value from units.iconSizes.
Then, I tried two approaches:
Approach 1: In ListDelegate.qml I have created the property alias iconSize: icon.Layout.minimumWidth. It doesn't work, the widget load and shout out this error: ListDelegate.qml:41:30: Invalid alias target location: Layout.
Approach 2: In ListDelegate.qml I have created the property int iconSize: units.iconSize.medium (I chose medium because that's the default option in the user settings). Then I changed the Layouts properties of the PlasmaCore.IconItem as follows:
Layout.minimumWidth: iconSize
Layout.maximumWidth: iconSize
Layout.minimumHeight: iconSize
Layout.maximumHeight: iconSize
At this point, the size of the icons changes accordingly to the user settings. But the ListDelegate item height remain fixed (as it were still using units.iconSize.medium), therefore the icons overlaps when the user chooses an icon size greater than medium.
What can I do to solve this problem?
After reading the docs, I have fully understand how Layout works.
The solution of Approach 2 is quite simple. I also needed to set the correct values to the Layout properties minimumHeight, maximumHeight and preferredHeight of the parent element (which is the RowLayout row):
Layout.minimumHeight: units.iconSizes.tiny
Layout.maximumHeight: units.iconSizes.enormous
Layout.preferredHeight: iconSize
The code should be self explanatory. In doing so, the parent RowLayout element is able to correctly change it's height to accomodate the icon.

Is it possible to have 2 tasks on the same date in angular-gantt?

I'm trying to make in a webapp a gantt-chart to display some data in a nicer way, using angular-gantt.
Some tasks are overlapping in certain rows, but the bars are displayed.
Is it possible to have the two thinner bars in the same row one under the other (not overlapping) ? or should i better create a separate row ?
ps. i'm not exactly a developer so maybe the explanation / question is not clear enough
Yes, it's possible.
You can do it by setting the property daily = 'false' in the place where you define your gantt chart (<div gantt data=...>).
div ng-app="appGanttChart" ng-controller="controllerGanttChart">
<div gantt data="data"
daily="false">
<gantt-tree enabled="true"></gantt-tree>
<gantt-groups enabled="true"
<gantt-tooltips enabled="true"></gantt-tooltips>
<gantt-resize-sensor></gantt-resize-sensor>
</div>
/div>
You don't need to set all the properties I have set, I was just giving an example.
Setting up daily="false" should solve your problem.

UiApp Merge 2 Cells in a Grid

In Google Apps Script UiApp, is there any way to merge 2 adjacent cells in a Grid?
Quick link to Grid doc
Looking through it, I see nothing about merge capability. Take the following example:
What I want to do is merge the cells # [0,5] and # [1,5] So that the TextArea for Description is a bit better-centered.
Is there any possible way to do this at the current time? I don't want to have to revert to using Flex Table for this... is that my only option? Are there any other workarounds like embedding the encircled elements in another panel or something similar?
Solution: CSS margin properties on the Grid or Widgets (through setStyleAttributes()). Apparently this is the behavior of Widgets in a Grid: CSS styles almost bypass Grid constraints; i.e., if you set a bizarre bottomMargin on a Widget, it can almost move out of the Grid, which acts as a "centering" between two cells. So I just did the following:
textArea.setStyleAttribute("marginBottom", "-75px"); which gave the following result:
I'd try using 2 grids, one with the textArea (and the 5 widgets of the first row) and the other with the other elements...
This latter should have a negative top margin to allow you to get the right vertical distribution on the 5 first left widgets.
I didn't try the negative margin but it should work.
Let me know if you try it :-)

Bootstrap span, row, column elements need to line them up

I'm new here and to Bootstrap so apologies for any stupidity.
In Bootstrap I'm trying to display .span4 in a row over 2 columns, this is because of page width, which should eventually nest into each other and leave no space. However with all I have tried at the moment I can still only manage to get each .span4 to lineup with the bottom-line of the longest span4 I have created. The site will eventually be dynamic and the size of the list could change frequently.
Looked at many different questions on here but no joy yet.
I have an example of my tryings here http://jsfiddle.net/joebarr/YJunh/
I think you're looking for jQuery Masonry. See for example: How can I float elements with different size in a tile or How to Create Grid/Tile View with CSS?
In case it must be CSS only, the accepted answer for the first link above ( https://stackoverflow.com/a/15320187/1449799 ) shows a good approximation.

How to create a custom GControl

I'm trying to create a gray "frame" (see pic below) around a google map, to try to convey the concept of an area of focus, as oppose to a point (which is usually represented with a marker). Note that this is not an overlay, that is, the gray "frame" should not move when you drag the map.
Edited: image link added
It appears that only option is to "subclass" GControl to create a custom control. I have 3 questions
1) First of all, is GControl subclassing the best course of action?
2) In my example, the canvas (div) where map renders can change its size (i.e is not fixed width). Do I have to delete and add custom control when canvas changes size? See docs http://code.google.com/apis/maps/documentation/controls.html#Custom_Controls on how to create a custom map control.
3) Now, how to do it. Naively, I thought I could create a table with 3 columns and 3 rows, and set display: none for the cell in the middle. But that doesn't work. I've also experimented with clipping, that didn't work either. My css skills are quite lacking, so there must be way to do this more elegantly than adding four rectangular gray divs. If I wanted to add an inner border, with divs, I would need to paint 8 then. In a nutshell, what's the best way to create a "hollow" rectangle?
Thanks
P.S. This is my first entry to StackOverflow. Just discovered it. It's impressive how well SO is put together.