How to layout controlArea and mainArea horizontally - orange

I am trying to create a new widget for Orange 3. I see that it provides some default areas (controlArea and mainArea) to which I can add my components. As far as I can tell, widget.py places both of these inside 'self.leftWidgetPart' which uses vertical orientation for its layout. From widget.py:
self.leftWidgetPart = gui.widgetBox(self.topWidgetPart,
orientation="vertical", margin=0)
if self.want_main_area:
...
self.mainArea = gui.widgetBox(self.topWidgetPart,
orientation="vertical",
sizePolicy=QSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding),
margin=0)
I would like to layout controlArea and mainArea horizontally instead. I believe this is possible because the OWBoxPlot widget appears to do it, but I can't work out what/where the relevant code snippet is (I guess my Python is weak).
Any help appreciated,
David

In PyQt in general, you can change the orientation by removing the existing layout and replacing it with another (hopefully before you populate it).
For self.controlArea in Orange, you can do something like this.
from PyQt4.QtGui import QHBoxLayout
import sip
sip.delete(self.controlArea.layout())
self.controlArea.setLayout(QHBoxLayout())

Related

Match tom select and bootstrap color?

I'm just switch from basic bootstrap 5 select to tom select, but I'm not able to match the colors of the buttons.
This is what it looks like, on the left side is the old bootstrap 5 drop, on the right side is tom select. Color for the select is "btn-outline-secondary".
Example image
Any help would be appreciated!
Was expecting the buttons to have the same border and text color
I found that if you remove the "form-select" class from the tom-select element it should render bootstrap css correctly:
document.getElementById("your_tom_element").classList.remove('form-select');
however, this is a fairly dirty solution in case you need something quick.
I would investigate whether this solution solves your problem, and then see whether some of the bootstrap classes collide with the tom-select classes.
Maybe try to provide also a bit more information regarding your block of code that is problematic.

VerticalLayout dynamically hiding visibility

I was wondering whats the best way around dynamically hiding some menu items. At the moment I have 6 items just in a matrix layout row. I want to have 3 items aligned left and 3 items alligned right. If one of the items is set to not visible I want it to move accross. I've done something similiar in a horizontal layout and setting the visibility to hidden. I was wondering if this would work with a vertical layout? Having trouble trying to figure out exactly how I would do it as I'm quite new to UI5 xml css and javscript. Any help would be great.
Also I'm having one other issue unrelated to this, I cant seem to bind my json model to my xml fragment, if I use the same code on my normal xml view it prints out the model data. But on my fragment it just prints it like {person>/fullName} any ideas ?
Belongs to your second question.
Maybe your binding was quoted on copy and paste? Check the native XML Code.
If no data are shown (not "{person>/fullName}"), add dependent to connect the models of your view
var oFragment = sap.ui.xmlfragment(sFragment, "fragmentName", this);
oView.addDependent(oFragment);

smartGWT override widget style

I want to override the background color of the TreeGrid object (and other default styles). But it doesn't let me change the default css.
TreeGrid grid = new TreeGrid();
grid.removeStyleName("listGrid");
OR
TreeGrid grid = new TreeGrid();
grid.removeStyleName(grid.getStyleName());
This code doesnt seem to work. The stylename remains the same.
I think I'm missing something but I cant seem to figure it out. Also if I set another stylename for the widget it keeps the default stylename.
Thanks in advance!
I found the answer myself.
Looks like there are various solutions. But this one was the easiest for me.
There are different methods for setting different parts of the style for this component. To set the body style name I simply used the following code and it worked. No need to create a new css rule here.
treeGrid.setBodyStyleName("#E0E0E0");

gtk (or gtkmm) 3 widen scrollbar for embedded (touchscreen) use

Since I'm using gtk3 and gtkmm3 on embedded I would like to have the scrollbar of a scrolledwindow wider.
I tried many ways but couldn't find a working solution.
Particularly I had a partial result with the following lines of code:
Gtk::Scrollbar *p_tableScrollbar = mp_scrolledwindowTable->get_vscrollbar();
p_tableScrollbar->set_size_request(50, -1);
but while the frame of the scrollbar becomes bigger, the slider remains narrow and part of the scrollbar area.
Then I tried the CSS way with the code:
Glib::RefPtr<Gtk::CssProvider> r_cssProvider = Gtk::CssProvider::create();
r_cssProvider->load_from_data("* {\n -GtkRange-slider-width: 50;\n }\n");
but still no result.
If anybody knows how to obtain the result please help.
It's gtk not gtkmm but here you go.
http://www.gtkforums.com/viewtopic.php?f=3&t=988&p=195381#p195381

GTK detecting window resize from the user

In GTK (or pygtk or gtkmm...)
How can I detect that an application window has been manually resized by the user, as is typically done by dragging the window's edge?
I need to find a way to differentiate manual resizes from resizes that originate from gtk, such as changes in window content.
Have you tried connecting to the GDK_CONFIGURE event?
Check out this example under the
"Moving window" section. The example shows a callback doing something when the window is moved, but the configure event is a catch-all for moving, resizing and stack order events.
I managed to pull this off by watching for size_allocate and size_request signals on the GtkWindow. If size_request ever got smaller, I called resize(1,1). If size_allocate was ever bigger than expected, I turned the system off.
One thing I made sure to handle was size_request returning big, then small, and having size_allocate be big and then small. I don't know if this is possible, but I fixed it by making sure to only decrease the expected values for size_allocate when I got a smaller size_allocate, not when I got a smaller size_request.
Make sure that your size_request handler comes after the base class' handler so that you get the right values. I did this by overriding the method and then calling the base class method first.
I've tried this in both 1 and 2 dimensions and it seems to work either way.
In my case I was trying to distinguish between a user resizing a Gtk.Paned from the user resizing the whole window. Both emitted the notify::position signal.
My solution was, since I can't know if the user is resizing the window from the widget, reverse what I wanted to know. Record if the user has re-positioned the widget and ignore updates if the user didn't initiate them on my widget.
That is to say, instead of testing "if window being resized" I recorded the button-press-event and button-release-event's locally so I could instead test "if widget being re-positioned"
from gi.repository import Gtk
class MyPaned(Gtk.Paned):
_user_activated = False
def on_position(self, _, gparamspec):
if self._user_activated:
# widget touched
else:
# window resized (probably)
def on_button_press(self, *_):
self._user_activated = True
def on_button_release(self, *_):
self._user_activated = False
dev __init__(self, *args):
super(MyPaned, self).__init__(*args)
self.connect('notify::position', self.on_position)
self.connect('button-press-event', self.on_button_press)
self.connect('button-release-event', self.on_button_release)
Effectively by recorded when the user started and ended interacting with my widget directly, I could assume the rest of the time was due to the window being resized. (Until I find more cases)
In PyGTK, I've always watched for the expose_event for a window resize, then use the get_allocation method to get the new size.
You may be able to throw something together by using gdk_window_get_root_origin to get the top left corner of the window and gdk_window_get_geometry to get the width and height. Then you could hook a callback into the GDK_BUTTON_PRESS_MASK and check to see if the button press occurs near/on one of the edges of the window.
Of course, this seems quite hackish and it really bothers me that I couldn't find some simple way in the documentation for GdkWindow to do this. There is a gdk_window_begin_resize_drag function which really makes me think there's a cleaner way to do this, but I didn't see anything more obvious than my answer.