I m trying to create a code that it can get a selected text, but I can't get text from QT windows. I'm using linux mint 19.3 and my little code that I m using to test. Can some one help me ?
import os
var = os.popen('xsel').read()
print var
Related
I'm using the qiskit textbook, and it creates a QuantumCircuit and then draws the circuit, and it looks like this:
I see the same result when running the textbook as a jupyter notebook in IBM's quantum lab.
However, when I download the textbook as a jupyter notebook and run it myself locally, it looks like this:
I don't like this very much, and I think I am missing something simple. The code that is running is exactly the same. I am using MacOS 11.4 (Big Sur). The following code is sufficient to show a difference when I run it online vs. locally:
from qiskit import QuantumCircuit
qc = QuantumCircuit(1) # Create a quantum circuit with one qubit
initial_state = [0,1] # Define initial_state as |1>
qc.initialize(initial_state, 0) # Apply initialisation operation to the 0th qubit
qc.draw() # Let's view our circuit
Because Qiskit has multiple drawers. Those are:
text
mpl
latex
latex_source.
The drawer you see in the IBM Quantum Lab is the one based on Matplotlib. You can get the same output by qc.draw('mpl').
To set a default, you can change (or create if does not exist) the file ~/.qiskit/settings.conf) with the entry circuit_drawer = mpl.
I have a problem in using the shortcut 'shift tab' in order to get more informations of the package or command I am typing in in a cell. I installed Jupyter notebook via anaconda very recently, I am using python 3.7 and Ubuntu 18.04.
Do you know how to fix this problem ? I googled a lot but could not find a solution.
Many thanks.
Let's say you wrote the below code and trying to get the signature/documentation of function read_csv() with Shift+Tab (It may not work some times)
Code:
import pandas as pd
pd.read_csv()
-> First type only below code
pd.read_csv? ## Execute this code with Shift+Enter
-> Now when you type pd.read_csv and type Shift+Tab, this will show u signature/documentation... This is just a workaround...
Follow two steps:
Step 1: Run that cell first (shift + enter)
Step 2: After running the cell, press the shift + tab.
It worked for me. I hope it will work for you too :)
In the Google Colab environment, if fixed it as follows:
Tools | Settings | Editor |uncheck Automatically trigger code inspection.
Then, Tab and Shift-Tab worked as expected.
I also faced a similar problem but can you confirm that you imported the library in the jupyter notebook and then were calling one of the methods of the library?
What I observed is that if the library wasn't imported into the notebook then the documentation wasn't also showing using Shift+Tab. Once I imported it, then the shortcut was working to show the documentation.
Scenario 1:
import numpy as np #Pressed Enter for next line
a=np.random.randint #Shift + Tab not working
Scenario 2:
import numpy as np #Shift + Enter
a=np.random.randint #Shift + Tab working
Just Run the tab of your code
Then bring your curser in the parenthesis and press shift + tab
press shift + tab + tab for more info
On Google colab:
clicking on the function after running,
move the cursor away and then
bring the mouse and hover it over causes it to pop up.
Note: colab Tools | Settings | Editor | check Automatically trigger code inspection (first setting)
Run again your line of importing the libraries. Now, having loaded your modules you should be able to see the command documentation.
Using scilab for the first time and I do not know how to fix it. I want to convert RGB image to grayscale. What to do?
The imread() function doesn't exist natively in Scilab (are you trying to port a Matlab code?). It does exist, however, as part of the SIP (Scilab Image Processing) toolbox which can be downloaded and installed using ATOMS (Scilab's Toolbox Manager). You can find ATOMS under the "Applications>ATOMS" menu in the Scilab console.
SIP also comes with the im2gray() function which essentially does what you want. After having installed and loaded SIP in Atoms, try:
// import RGB jpeg pic
RGBpic = imread("rgb.jpg");
// convert to grayscale
GSpic = im2gray(RGBpic);
// create new figure window and display grayscale pic
scf(0);clf();
imshow(GSpic);
I am new to R and want to use the Eclipse plugin StatEt with Oxygen.2 Release (4.7.2) on Windows 7.
I tried to create an example plot with the R Graph Builder. I click the "play button" and get following output on the R Code tab. Furthermore, I hear a "ping" sound.
library(ggplot2)
p <- ggplot(data = mtcars, aes(x = mpg, y = cyl))
p <- p + labs(title = "test")
print(p)
However, I can not see any graph.
=> Is the purpose of the "play action" only to produce the console output?
=> Where can I find documentation about the Graph Builder?
=> What data can I enter to get a first example graph?
Furthermore, when I plot a graph in StatEt, I would expect its output to be in the view "R Graphics". However, a new window is opened by R. I have the option "Set R Graphic view by StatET as default graphic device for new plots in R" enabled on the tab "R Console" in my console run configuration.
=> What is the purpose of the "R Graphics" view?
Example plots:
x<-c(1:10)
y<-sin(x)
plot(x=x,y=y)
-
library(ggplot2)
ggplot(data = mtcars,aes(x=wt))+geom_bar()
Related questions:
How does one install 'rj' in StatET plugin for Eclipse?
ClassNotFoundException for StatEt Eclipse plugin / RJ. Compatibility issue with Java9?
Why doesn't my ecplise console start with StatET
How to index R library for Help view of StatEt Eclipse plugin?
In order to use those features of StatEt you need to select RJ (default) instead of Rterm in the Console run configuration. (Rterm might be useful for trouble shooting and initial setup but RJ is required for normal usage. The R package RJ needs to be installed from within R. Apply Rterm once for doing so or use R.exe directly. Also see ClassNotFoundException for StatEt Eclipse plugin / RJ. Compatibility issue with Java9?)
RJ 2.1 is not compatible to Java 9. Currently you need to install Java8 and select it in the JRE settings of the run configuration.
Make sure that the box Set R Graphic view by StatET as default graphic device for new plots in R is checked in Run configuration>R console. (It is checked by default.)
Once you have created your graph, the example code is written in code. This is normally sent to the R console. You should now be able to see the graphical result in the R Graphics view.
I want to create a GUI in R using RGtk2 and the Glade GUI builder as user interface designer.
How can I use the XML file created by Glade in my R code (using e. g. RGtk2)?
Has anybody a "hello world" example with a simple window or a link to a a good tutorial
THX!
PS: There is a code example in the documentation of RGtk2 but it does not work since the function "gladeXMLNew" is no longer available (see this post).
> GUI <- gladeXMLNew("applicationwindow1")
Error: could not find function "gladeXMLNew"
User #nico pointed me to the solution:
library(RGtk2)
demo(builder)
# the variable "filename" points to a Glade XML file
# (which seems to be for Gtk2, not Gtk3 though)
Still an open question: Is there a good tutorial for Glade with RGtk2?