I'm building a toolbar in PyGTK and attaching a combo box to it. The result that I got is that the combo box stretches to fill all the vertical space available:
I have been trying every trick in the book that I can think of in order to avoid it, but I'm starting to admit that maybe it's just GTK style and I won't be able to get rid of it.
I can post some code but this should be quite simple to recreate. Any idea?
Wrap the combobox in a gtk.Alignment. You can create the latter with 0.5 vertical alignment to have the combobox centered vertically.
Related
I would like to write a very simple text editor with a custom widget for drawing the text. I use GTK3. So far, I've come up with something like this:
Window -> Vertical Box -> Scrolled Window -> Drawing Area
The scrolled window fits the main window, as it is inside a vertical box. Depending on the size of the drawing area, the scrolled window shows the scroll bar. So far so good.
Now, there are several things I don't understand:
When the text doesn't fit the drawing area, how do I go about resizing the drawing area?
What is the best way of approaching the resizing when the text changes? One way I can think of is to simply handle key presses and count lines, but that doesn't seem right and probably won't work when lines wrap.
What events do I have to handle (and possibly propagate) for this to work?
I've tried searching the GTK docs, but they are very unhelpful in this regard. gtk3-demo doesn't really help, too. I know that there is https://developer.gnome.org/gtk3/stable/ch01s05.html, which describes the custom drawing a bit, but doesn't solve what I'm trying to do.
Update:
I figured out a lot by reading gedit, gtksourceview and gtk sources, which I wanted to avoid, but there seems to be no way around it.
all.
I am writing an app in C with GTK3 and using Glade to build the UI.
What I am trying to do is making a container that will stay on the bottom of the frame, filling the horizontal space but not vertical. I will place a few buttons there and don't want them loose in the frame. Right now I just have enough code to show the window to see how it looks in runtime, focusing just on UI.
What I have tried so far:
GtkBox: would be perfect if I could adjust its height so I have free space above it, for another container. But it seems to take whatever free space is left (that is, the whole screen).
GtkPaned: would be perfect if I could prevent it from being resized in runtime and hide the handle. But, well, this is the purpose of this widget, so it doesn't seem to be possible.
GtkGrid: same thing as GtkBox.
For those who already worked with Borland C++ Builder or Delphi, it is the functionality of a "Panel" I'm trying to repeat. That is, you drop the container in the frame, align it to bottom (which makes it fill the horizontal space) and then you adjust the height in design time.
Any ideas? If you need more information, just let me know.
*EDIT: Alexander, this is when I try to expand on your comment, that is, using more than 1 button and container inside a container (see top right of Glade for the hierarchy).
When all buttons have Expand "Off", which works for 1 button, and when it is "On" (then I don't get to adjust the height anymore).
"No" to all buttons
"Yes" to all buttons
The simpliest solution: take GtkBox and use gtk_box_pack_end.
Another way is to control container align and expand behaviour (use gtk_widget_set_halign/gtk_widget_set_valign and gtk_widget_set_hexpand/gtk_widget_set_vexpand on the container itself)
Edit: didn't notice you are using glade. Create a gtkbox, add a child and change child's pack type
Also notice: if you want to add container near another container, you should pack both containers in another container.
I am trying to make a custom scrollbar for my gwt project, same as the one in the attached picture. It behaves like when the container overflow horizontally, an icon with the arrow will be shown on the right side, instead of showing the horizontal scroll bar, and on clicking on this arrow, it will act the same way as the scrollbar would.
I tired to search for similar components, but got no result [may be i am not searching for it with the right key words :( ]
Could any one help me in building/finding such a component using GWT/SmartGWT
Scroll Bar marked in red on right side
I am using the gwt visualization API. I use the Table widget and would like to specify the height using the setHeight() method.
When I put enough records, the vertical scroll bar shown up. The width of the table no longer fit the data after the scroll bar show up. The column labels are long records are forced to split to two lines:
How can I avoid it ?
(I don't want to fix the width of the table as the data is dynamic and I will add arbitrary columns also).
Ok, I'm not particularly familiar with the "gwt visualization API" but the the first solution which comes to mind, is that you always show the scroll bars and make the field a little bit bigger.
Her a little code example:
ScrollPanel sp = new ScrollPanel();
sp.setAlwaysShowScrollBars(true);
or if you are using UiBinder:
<g:ScrollPanel ui:field="scrollPanel" alwaysShowScrollBars="true">
You can also let a scroll panel appear in the bottom so your lines still appear in the bottom, but I don't thin that's what you want...
Regards,
Stefan
I want to create a custom panel/layout and it's seeming pretty impossible at this point. I need the components to start in the upper left corner and stack downward until they fill the panel vertically, then wrap to the top of the next column and so on until they eventually fill the screen and create a horizontal scrollbar. After an entire day of trying I've decided it's only possible by abusing GWT (and I assume the whole web browser) adding crippling complexity and terrible performance. Please let me know if I'm missing something and layout like this is possible. Thank you!
Lame solution: Have a small (almost invisible) AbsolutePanel where every string is displayed within a div and measured (getClientWidth/height()). Then each panel can calculate it's size based on the strinsg, borders, padding, etc. it contains. Once each panel knows it's size, they can be layed out relative to the sizes of the other panels in the contianer.
Check out FlexTable, which allows you to specify the row,column for the widget to be added