How can I run a python script from within Kodi? - python

If I want to make a button in Kodi's menu and run a local python script upon clicking it, what's the best way to go about it?

file_path = xbmc.translatePath(os.path.join('insert path here to file you want to run'))
xbmc.executebuiltin("XBMC.RunScript("+file_path+")")
Very late reply but saw no one else had answered so though i'd put in just in case

Related

Question about using selenium+pyautogui to upload file

Recently I need to upload my dataset on a website, the first part works fine on selenium.
However, after I click the 'upload' button, a windows file broswer pops-up.
And after searching online, I finally make it work by using pyautogui, code:
pyautogui.write('K:\Github\###\data\global\Global_PM_corT.csv') # enter file with path
pyautogui.press('enter') # click ok
My question is, I want to use above process on Github Action.
So, i changed:
'K:\Github\###\data\global\Global_PM_corT.csv'
to:
'./data/global/Global_PM_corT.csv'
and it's not working.
I think there is some error when using relative path with pyautogui.
So, i was wondering if someone could help me achieve this? Thanks in advance:)
P.S.
its working right now.
I first read the dataset by
pd.read_csv('path')
then write it on github action
to_csv('C:\\Global_PM_corT.csv')
then I can use absolute path with pyautogui:)
However, I still want to know if a better way to achieve this
Please try this:
'./data/global/Global_PM_corT.csv'

What does it mean to "restart" a program (in my case IDLE)?

This answer on Stack Overflow offers a solution I am trying to implement. In particular, see the sections "Installation Instructions" and "How to Use".
Can anyone tell me the steps required to "restart" IDLE?
New Information:
Just as people have suggested I thought this simply meant closing the program and opening it back up again...but I already tried that.
The other twist to my situation is that I'm working on a virtual machine so I was unable to do the installation of IDLE2HTML.py myself. My work's Help Desk had to do it so I cannot speak for the accuracy of their work. For now I'm assuming they did it correctly, but when I go to the "Options" menu there is no option to "Save as HTML".
My only guess at this point is that I still need to "restart IDLE".
Just wanted to double check if there was something else I could do before going back to my Help Desk department.
IDLE reads the idlelib/config-xyz.def files, including config-extensions.def, just once, when it starts. So any changes to config-extensions.def only takes effect the next time you start IDLE.
If you do not see 'Save as HTML' after starting IDLE, the extension is not installed properly.
It means you need to close the IDLE so that any changes made by the script can affect the IDLE
Simply close the IDLE either via the X, Ctrl+Q or File>Exit, then open the IDLE again.
If you are using idlelib module from a Python program then close your program and run it again.

Make a full terminal window application like Vim/Mutt/Cmus

I'm not sure quite how to word this, which is probably why I'm having trouble finding an answer.
I have a command line script that runs a rummy game, I want it to take over the terminal kind of like how Vim or Mutt does, so that each round is refreshed in the full terminal window rather than just printing out row after row of text.
Can someone tell me what that is called, so I can research it and find out how to do it?
Repo: https://github.com/sarcoma/Cards
You're looking for a console user interface. One of the best libraries for python would be http://urwid.org/
As mentioned in a comment "pythons curses module does what you require".
This is what you need to take over the terminal: https://docs.python.org/3.9/howto/curses.html

Trouble adding Python to Path

I've followed the tutorial and I still can't get Python to run in the command prompt and hence can't get it to run in Sublime Text 3.
I seem to have the right address.
How can I fix this? Thank you.
Each directory should have its own entry. Instead, you have them all in one string. To create a new entry, press the new button and put in one directory.
It should look similar to this:

Eric4 Python IDE - autosave and quick script/project start, run

I've got 2 problems with Eric4 IDE.
Can't find an option in preferences to autosave my changed files before running script. It's very annoying that I have to save my file and then run script.
Second problem is running a script. I can't find any button to run a script/project instantly. 'Run Script' button always opens a setting window.
One way to get around this, as it seems there is no built in way is to bind a key to save the file (ctrl+s), then run the script (F2), and finally hit enter (to close the settings window and run the code).
This bothered me a lot too, and I know this is 2 years late but it might help some else who comes here looking for this very solution, like I did. Here are the actual answers, ERIC v4.4:
Press F4 instead of F2.
The first time you have to use F2 to 'Start' the script, so dismiss the settings window. After that you can use F4 'Restart' and it will run with the settings you chose initially.
The Autosave option is well hidden unfortunately:
Settings-->Preferences-->Debugger-->General-->!Scroll down to!-->Start Debugging-->Autosave changed scripts
And you were spot on - these two things do have a huge impact on productivity.

Categories