How to pause a Jupyter notebook script until a button is pressed? - python

I'm using the widget notebook_login that looks like this when run in a notebook:
notebook_login()
The problem is that it's in the middle of my notebook and if I click "run all", the next cells will run as well before I can press login. Is there a way to pause the notebook at this cell (where the widget is) until after I click "login"?
I found these several SO questions (this, this), but they seem to be very specific to their own unique buttons and I couldn't figure out a general way to do that (or more specifically to apply it to my situation)

Related

Jupyter notebook won't let me edit a cell and becomes unresponsive after opening documentation string using shift tab. Mac M1 user

So basically every time I hit shift + tab to open documentation string and I expand it in an external window, my entire notebook becomes unresponsive to any keyboard button I select after. This just started happening recently and if i keep on pressing tab it just goes through different items on the page with a blue box. Then it opens "Window Chooser" which i've never used before. If I try to select a cell and edit it, nothing I type appears in the cell. I usually have to hit escape and close the notebook. Has anyone experienced this before on mac and is there a fix?
window chooser opening up
I tried to redownload anaconda navigator and chrome but this did not fix the issue.

How can I click buttons in a windows GUI program using python?

I am writing a python script that automates running a program and performing different tasks within the program. My main problem is figuring out how to click buttons and interact with the GUI of the program to be controlled.
I am currently using the pyautogui library and using pyautogui.click(X,Y) to advance through prompts and click on different menus and menu items. The problem with this approach is that I am relying on a separate script to inform me of the coordinates of interest in my environment by telling me the coordinates of where my cursor is hovering. This probably will not work on other machines and just seems like a one case solution.
My question is how can I automate using a program in windows (clicking around) without having to hard code the exact position of the items I need to click?
For example, If I need to click a "ok" box to accept some setting, how can I make Windows grab the program window, read through the options and click what I need without any prior knowledge of the position of the dialog box and where the "Ok" button is located?
Code:
import pyautogui as gui
gui.click(x,y)
The way you can do this using pyautogui is with their locating methods. You will need a picture (for example of the OK box) and then you can have pyautogui find it on the screen and give you its coordinates. Check out the official documentation on this.

How to add button to hide cell inputs in python jupyter notebook without nbextensions

I'm new to python and dont understand tag and cell metadata. I want to add button to hide cell input code in jupyter notebook itself, as shown in: https://jupyterbook.org/interactive/hiding.html > Hide cell inputs. Can someone direct me please.
If you want to add a button on the notebook you must have an extension fir that.
You can use an existing one like https://github.com/osscar-org/jupyterlab-hide-code or do it yourself.
Otherwise you can use the 'Collapse' commands in the 'view' menu.

How to make down arrow on VSCode to go to end of line in Jupyter Notebooks?

I'm starting to use VSCode to work with Jupyter Notebooks (I've been using Google Colab before), and the thing that most annoys me is that when I'm at the last line of a cell and press the down arrow, nothing happens. In Google Colab, when you press the down button in the last line, it goes to the end of the line, and it makes me code much faster.
I know that VSCode has a lot of possibilities for customization and configuration, but I don´t have the knowledge for it. Is there a way to change that behaviour?
Pressing Ctrl+Down goes to the end of the line, and Ctrl+Up is for the start.
For more detailed keyboard shortcuts in VS Code, go to the article Visual Studio Code Key Bindings
For cursor to go from the beginning of the last line to the end of it when pressing arrow down (↓) instead of jumping to the next cell you should open Keyboard Shortcuts (File > Preferences > Keyboard Shortcuts [Ctrl+K Ctrl+S]) and remove or change bindings for "Notebook: Focus Next Cell Editor". Similarly you should change bindings for "Notebook: Focus Previous Cell Editor" if you want the same functionality for the up arrow (↑).

Python (tkinter) - Auto-left click when right clicking

I'm building a GUI using python with the tkinter library. I've created a table that imports data without issue and I'm able to select (highlight) individual cells and right click on them to bring up a menu for that cell. The problem is I first have to left-click on the cell to highlight/select it before right-clicking on it to bring up it's menu. If I left-click one cell and then right click a different cell, it brings up a menu for that highlighted cell, not that one that I right-clicked on.
My code is a bit too large to post but I'm hoping I can get some general ideas or sample code on how when I right-click on a cell, it selects it as well.
Thank you

Categories