Fake mouse scroll using XTest lib - mouse

How to fake mouse scroll with XTest lib?

Check the xte program and its source code. You might want to use xte itself instead of your code.
http://hoopajoo.net/projects/xautomation.html
http://linux.die.net/man/1/xte
http://cgit.freedesktop.org/xorg/lib/libXtst/
Also, read #n.m. 's comment to your question.

Related

Placing cursor in the document for a given position using PyUNO

I am having Libreoffice7 installed with custom python 3.8.6 in Windows.
I want to use PyUNO to navigate the view cursor to a specific position based on the X, Y coordinates(of instance com.sun.star.awt.Point) in a writer document.
Is there a way by which this can be achieved? I am unable to find any resource or documentation that helps.
Please let me know if any other info or clarifications needed.
Thank you in advance.
Precise positioning using points and pixels is difficult or impossible with the UNO API. The numbers seem to be unpredictable, for example https://ask.libreoffice.org/t/what-is-the-base-for-cursor-x-position-in-basic/71827.
Instead, move the cursor to a character or paragraph or object, for example with goRight().
To investigate point positioning further, take a look at this discussion on positioning a dialog in Calc: https://ask.libreoffice.org/t/dynamically-position-a-dialog/67289/39

How to add scroll down feature to the GUI when necessary

I'm trying to print my all inputs on the figure of the GUI. To be clear, when I have inputs like inputA, inputB, inputC, ... I want it to get shape like below.
inputA
inputB
inputC
inputD
inputE
...
...
However, what if it is much longer than y-length of the GUI? Resizing fonts is not a solution for me. Only thing comes to my mind is to have a scroll up and down feature. How can I have this? Any other solution is welcome.
Regards..

How to add a "tutorial message div" to figures?

After installing R2018b, the first figure I opened contained an interesting message (shown in blue):
The reason it's interesting is because it contains features like text wrapping, transparency, the fact that the image maintains a constant width even though the text resizes (this reminded me of CSS3 flexbox, hence the tag), etc.
The last part of the animation is in slow motion, to better show how the div's size follows that of the figure.
In case it matters, I'm using Win 10 v1803.
Question:
I'd like to know how we can draw similar, custom, divs (for a lack of a better word) in our figures. (It's important to stress that this is not a UIFigure!)
What I found so far:
The Learn More link opens the page:
web(fullfile(docroot, 'matlab/creating_plots/interactively-explore-plotted-data.html'))
yet breakpoints in the entry points of either web or docroot (or even doc) aren't hit.
Assuming that this element is a Child of the figure, I attempted to locate a handle to it:
>> set(gcf,'MenuBar','none'); findall(gcf)
ans =
22×1 graphics array:
Figure (1)
ContextMenu
AnnotationPane
Axes
AxesToolbar
Text
Text
Text
ToolbarStateButton (Brush/Select Data)
ToolbarStateButton (Data Tips)
ToolbarStateButton (Rotate 3-D)
ToolbarStateButton (Pan)
ToolbarStateButton (Zoom In)
ToolbarStateButton (Zoom Out)
ToolbarPushButton (Restore View)
Button
Button
Button
Button
Button
Button
Button
however, making these controls invisible using set(h(2:end), 'Visible', false) didn't make the div disappear.
Saving the figure as .fig or generating code for it, doesn't leave any trace of this div.
When uiinspect-ing the figure, this div doesn't show (or at least, I couldn't find it).
I don't know what exactly I did to make it reappear once more, but since it's set to appear on the very first time you boot R2018b, I suspect deleting prefdir (obviously, after backing it up) and restarting MATLAB could bring it back.
The only thing I didn't try yet, is to attach a java debugger to MATLAB and attempt to trace the caller to com.mathworks.mlservices.MLHelpServices.setCurrentLocation (from mlservices.jar), which opens the help browser.
After some digging in the Java side of things (starting from findjobj, followed by a lot of .getComponent(0).getComponent(0)...), I've finally managed to locate the component in question. Here's what I learned:
This component is called InfoPanel, and is part of MATLAB's Java API. The class definition itself is found in:
MATLAB/R2018b/java/jar/hg.jar!/com/mathworks/hg/util/InfoPanel.class
To make it appear, we need to call the static method addBannerPanel, passing in a figure handle:
com.mathworks.hg.util.InfoPanel.addBannerPanel( figure(randi(1E4)) );
Or another signature that also accepts a custom panel:
jIP = com.mathworks.hg.util.InfoPanel;
jIP.setBackground(java.awt.Color(0.8, 0.7, 0.1));
com.mathworks.hg.util.InfoPanel.addBannerPanel( figure(randi(1E4)), jIP );
The MATLAB setting that controls whether this should appear is showinteractioninfobar inside the <prefdir>/matlab.settings XML.
It appears that the "interesting parts" of InfoPanel are private, which means it allows barely any customization (mostly some colors; not the string or the icon), but it should be fairly easy to make a copy of this class and expose all elements we need.

Alternative to simulink transparent subsystem

I need to organize a set of elements in simulink. The first method is to create a subsystem. The problem with subsystem is that the elements inside it are no longer visible. An alternative method is to create a colorized box and put it behind a set of elements as a background. It makes a lot of troubles during selection of elements.
The ideal method is to have a subsystem which is transparent but you can see the elements inside it. So you can make it large and see inside it without opening it.
What is the feasible alternative method?
Knowing that there is no support by simulink doing this, the only possibility would be to use a mask icon which shows the content. The following is a very rough prototype for the mask code:
model='s1/Subsystem';
loc=fullfile(pwd,[model,'.png']);
print(['-s' model], ['-dpng'], '-r300', loc);
image(loc);
port_label('input',1,'In1');
port_label('output',1,'Out1');
Obviously this prototype has multiple issues which must be addressed when really using the code:
Remove the hard-coded directory.
Set in- and outports automatically.
create required folder structure. (folder s1 must be created once manually)
Scale the subsystem block to make the image look good
work properly if pwd is not the directory the model is stored in
You can make use of the 'Icon Drawing Commands' of the mask parameter's tab 'Icon and Ports' :-
Take a screenshot of the logic gates you want to be visible on the subsystem (the ones with a blue background color shown in your question)
Save the picture e.g 'mylogic.png'
Write this command in the 'Icon Drawing Command' field of Icon and Ports image(imread('Pause_Icon.png'));
You're done. But yes, make sure you have the picture file in the same folder as your model or simply add the folder containing the picture on your path.
Of course, if you update the blocks inside the subsystem, you'll have to update the mask icon with the new screenshot.

How to layout controlArea and mainArea horizontally

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())