Creating executable file with R: How to keep GUI open running Rscript - r

I made a GUI using R, and I wanted to make an executable file for it, so other people can double click and launch the GUI without seeing any R code. I made a .bat file and have Rscript run my R code, but what happened is that the GUI is created and then closed, so I cannot interact with the GUI at all. So I want
to ask for any suggestion on how to make the GUI stay open until I close it? Or any other ways to make an executable file? Thanks!
BTW, I am using windows 7.

Related

Start a background process on Qt and load responsive shell environment

I am playing around with Qt to create a simple GUI for some more advanced analysis with the software called OpenFOAM. Right now, I want to start an application of the toolbox OpenFOAM usingQProcess::execute. It is working but for the application I need to load the environment in the shell.
Commonly, if I work in the terminal I first do have to source the environment file that loads all libraries and solvers one can use. However, in Qt, I am not aware how to achieve that.
Example. In the terminal I need to do the following:
source /path/to/environementFile
simpleFoam > logFile << application
I want to start the application simpleFoam in the background of my GUI after clicking on a button. Right now, I do have the following:
QProcess::execute(QString("/home/shorty/OpenFOAM/platforms/bin/simpleFoam"));
This works but the shared library that are needed by the application are not loaded (missing source of the environment file). Is there a way how to process more commands within one execution call?

How to run a shiny app in IntelliJ (PyCharm)

I have a basic shiny app (ui.r and server.r) that I am able to run in RStudio.
But seems like I can't run it in IntelliJ.
I have installed the R language support plug-in and I can run r scripts.
But when I try to run ui.r, the only thing I get is html output in the console.
Does anyone recognise this? I probably forgot to configure something?
I do have experience running java (web) apps with IntelliJ. With tomcat setup e.g.
In the run configurations, I didn't see anything specific for a shiny server or something R related. So I guess that is not where I should search ...
Any idea? Is more information needed?
Thx in adavance.
edit:
The answer is here: https://youtrack.jetbrains.com/issue/R-895
To run a shiny App (R framework) on PyCharm you must enable R first and indicate where is the R interpreter located:
R options appears on the bar status. One of them is R Console. Click on it. Write getwd() command to see if you are in the root directory of the project. If not, set it with setwd() command:
Next, write runApp() and DO NOT press enter yet. You must press alt+enter and then click on load Shiny:

QTCreator Memcheck performing analysis without letting me run the actual program?

I am attempting to use QTCreator's Memcheck tool to analyze the memory of a QT project, which is a dynamic library. It uses a QT Gui (QMainWindow) to allow the user to select a file, which is then processed, and then eventually returns to the mainwindow.
However, I cannot seem to use Memcheck properly.
When I select "Memcheck" and hit run, it instantly goes to "Analyzing memory" without ever letting the Gui pop up.
This is problematic. How can I get memcheck to work with this program?
I had two main issues:
1: Valgrind does not seem to play nice with QT Gui applications. It generates logs that are thousands of entries long for all the work QT is doing before it even gets to my application.
I had to make a separate, small non-GUI C++ program that would drive instead of the GUI application.
2: When trying to run from the command line, I needed to set an environment variable by using export. This needs to be the same as LD_LIBRARY_PATHS in QT Creator.
So I ran:
export LD_LIBRARY_PATH=X where X was the exact value I copied from LD_LIBRARY_PATHS in the variable from the QT Project.
Note: Running from the command line may have not be neccesary now that it isn't a GUI Application, memcheck might have passed just fine. Haven't tested since.

How to make Rscript stay open until gWidgets gui is closed

I have a script which launches various gWidgets windows with buttons that have functions attached. I'd like to be able to launch this with rscript.exe so others can use it without seeing R. My problem is that when I launch the script using rscript.exe myscript.r an rscript instance shows up in task manager, it loads all the packages, the widget pops up for a second, and then it's gone (including the rscript process from task manager) before the user can even do anything. How can I make the instance of rscript stay active until all the gWidgets windows are closed? If I launch the script from either Rstudio or Rgui it stays open until done. As a similar question, is there also a way to prevent the dialog box showing the various commands from coming up too? I'm using Windows 7 by the way.

Running qcollectiongenerator during application compile process

I've been working on a program called RoboJournal for a long time. The next release has full documentation included; Whenever the user presses F1 or clicks the Help item in the RoboJournal program, the help file is displayed in Qt Assistant (way classier than simply opening a browser window to some online documentation).
In its base form, the documentation consists of lots of loose HTML and image files included in the source package. These loose files are supposed to be compiled into a QCH compiled help file and QHC collection file during build time so Qt Assistant can display the documentation properly. On Windows, this was fairly easy because I was able to write a batch script to automate the entire build process (including compiling the documentation and moving the output files to the right place).
On Linux, it's a bit more complicated. True, I could write a Bash or Perl script that compiles the documentation along with the rest of the program but I have no guarantee that the people who will eventually create my app's Debian packages from the source package I give them will use the script. The source package is used to create all the Debian packages so everything has to work flawlessly with the standard build procedure (or the source package is worthless). Therefore, I need the compile process to produce the same results whether the user runs the script or not. As it is now, the user has to build and install the documentation manually. Surely there's some way to automate this.
Is it possible to have Qmake add instructions to run qcollectiongenerator to the makefile (in order to build my application's help files) so it gets handled properly during the "make" step? That way, the QHC and QCH files will be ready to install to their proper locations (in my case, /usr/share/doc/robojournal-0.4.1) along with everything else when the user runs "make install". I've considered compiling the QCH and QHC files in advance and providing them in the source package but the whole point of building from source is to be able to re-create the entire app from its base components.
I know I probably have to add additional instructions to my .PRO file but I’m not sure what or how. I've found something that looks promising (http://www.qtcentre.org/archive/index.php/t-49484.html) and gives me hope that it's possible for Qmake to do what I need but I’m not sure how applicable those instructions are to my situation. Do I have to create a PRI file just for this or can I add the instructions directly to the main project file?
You can try to use the QMAKE_POST_LINK variable:
QMAKE_POST_LINK += build_help.sh
P.S.
I have no guarantee that the people who will eventually create my
app's Debian packages from the source package I give them will use the
script.
I think this is really not your problem :) It's up to them to properly build the package.

Resources