PyBox / Blog / Guides

Coding on a Primebook: a Python setup guide

Primebook is an Android laptop. That makes it a good, light machine for learning Python, if you pick tools made for it.

Coding on a Primebook: a Python setup guide: the PyBox screen this guide uses
PyBox is the Python IDE I build. Everything below works with it, and the steps are the same ideas you would use anywhere. Get it on Google Play.

What a Primebook is good for

A Primebook is a laptop that runs Android apps on a larger screen with a keyboard and a trackpad. That suits learning Python: you can read, type and run code for an hour without a phone's cramped screen. What you need is an app that treats the screen like a laptop's.

Pick tools that behave like a desktop

  • A real interpreter: CPython running on the device, offline.
  • Keyboard shortcuts: find in files, go to line, a shortcut list.
  • Windows: GUI toolkits need a display server. PyBox embeds an X11 server and window manager.
  • Git and notebooks: so the machine can do real work.

Set up in five steps

  1. Install PyBox from Google Play.
  2. Open it and let it unpack its runtime once.
  3. Allow storage access, so projects live in a normal folder.
  4. Tap New Project and pick Python Basics Tour.
  5. Press Run.

Use the keyboard and trackpad

  • Press Ctrl+Shift+F to find across the project and F1 to see shortcuts.
  • Hide the on-screen keyboard when a hardware keyboard is attached, in Editor settings.
  • Rest the pointer on a symbol to see its documentation when a language server such as Jedi or ty is on.
  • On the X11 desktop, set touch mode to Touchpad in Settings if you want a cursor you move with the trackpad.

Run a GUI app

import tkinter as tk

root = tk.Tk()
root.title("Hello Primebook")
root.geometry("420x240+120+100")
tk.Label(root, text="Python on Primebook", font=("Helvetica", 28)).pack(expand=True)
root.mainloop()

Press Run and the window opens on the PyBox desktop, with a panel and a taskbar. The same works for Kivy and pygame.

What to learn first

Follow the 30-day plan, which works as well on a laptop screen as on a phone. Then open the NumPy and pandas notebooks.

More on the Python on Primebook page.

Questions

Can you code Python on a Primebook?

Yes. Install an Android Python IDE such as PyBox from Google Play. It runs Python offline and works with the keyboard and trackpad.

Can a Primebook run Tkinter or pygame?

With PyBox, yes. It runs an X11 desktop inside the app, so Tkinter, Kivy and pygame windows open in real windows.

Anshuman MishraBuilds PyBox at Vytros, a Python IDE for Android. About the developer.

Code Python on your phone.