Skip to main content

A small module allowing to link the kandinsky module, from the Numworks, to a window.

Project description

Visitor Badge Downloads pip GitHub Clones

Kandinsky-Numworks

This module depend to PySDL2 module and sdl2 libraries, PySDL2 is just an sdl2 wrapper with ctype and it just call methods in sdl2 library. To install both modules, click here and follow steps.

This module allowing to link the kandinsky module, from the Numworks, to a window. Useful if you want to test your program without putting it on the calculator.
In addition, this module also emulates the drawing speed, and has many other features.

Installation

You now have the option to install this module on pypi.org. For that, follow the steps here.
Or if you want, you can build it yourself, just run the command ./setup.

More

I also recreated the ion module of the Numworks, check it out here: Ion module of Numworks
If you have a question, check out the FAQ. And if you have a suggestion or your question is not answered, open an Issue.

Usable content

Numworks, aka basic, methods

get_pixel():

  • Parameters: x, y
  • Description: Return pixel (x, y) color

set_pixel():

  • Parameters: x, y, color
  • Description: Color pixel (x, y)

color():

  • Parameters: r, g, b
  • Description: Define a rgb color

draw_string():

  • Parameters: text, x, y, color [default: (0,0,0)], background [default: (248,252,248)], (Omega & Upsilon only: font [default: False])
  • Description: Display a text from pixel (x, y)
  • Note: parameter font is only for Omega and Upsilon and it's to chose between small and large font.

fill_rect():

  • Parameters: x, y, width, height, color
  • Description: Fill a rectangle at pixel (x, y)

New method for this library, only on Computer

quit():

  • Parameters: No parameters
  • Description: Close manualy the window without notifying the user
  • Note: after that you cannot reopen the window, so a re-import of kandinsky will be required to get a new window

display():

  • Parameters: No parameters
  • Description: Refresh manually the window and display changes
  • Note: ⚠️Method added only for MacOS, because library cannot refresh automatically the window in another Thread.
    It will be necessary to call this method from time to time to keep it alive.⚠️

New methods added by Omega (previous methods are also added)

draw_line()

  • Parameters: x1, y1, x2, y2, color
  • Description: Draw a line at (x1, y1) to (x2, y2)

wait_vblank()

  • Parameters: No parameters
  • Description: Wait for screen refresh

get_keys()

  • Parameters: No parameters
  • Description: Get name of pressed keys

New methods added by Upsilon (previous methods are also added except get_keys())

draw_circle()

  • Parameters: x, y, r, color
  • Description: Draw circle at (x, y) of radius r

fill_circle()

  • Parameters: x, y, r, color
  • Description: Fill circle at (x, y) of radius r

fill_polygon()

  • Parameters: points, color
  • Description: Fill polygon at points [(x1, y1), ...]

get_palette()

  • Parameters: No parameters
  • Description: Get theme palette

Additional features

A GUI to control emulator

  • Pause/resume: You can pause/resume your script
    Note: This will just pause the calls of kandinsky. So for the script to pause, it must be called one of the functions of the library

  • Screenshot: You can also take a screenshot of window
    Note: This take just the numworks interface and drawable area, not the GUI

  • Change OS: Change the speed of execution. You have chose of Numworks, Omega, Upsilon, and PC mode
    Note: Only work for kandinsky methods

  • Change model: Change the model of numworks. You have chose of n0100, n0110, and the new model n0120
    Note: This change the speed python execution emulation of numworks Note2: n0100 and n0120 models are not available for moment.

  • Shorcut command: All the features mentioned have a shortcut command. More info in "Help > Shortcuts" menu of window.

Environ options

/!\ You must make its additions before importing kandinsky otherwise the changes will not take effect! /!\

You can also change some default option of library, like the OS or model on which to start kandinsky, etc.
To do this, first import os module and add a compatibility check, like this:

try:
  import os
  if hasattr(os, "environ"):
    "<environ options here>"
except: pass
  • Enable debug mode:
os.environ['KANDINSKY_ENABLE_DEBUG'] = '' 
  • Change starting OS (methods according to the selected os will be created):
# '0': PC speed + all methods
# '1': Numworks speed + Basic methods
# '2': Omega speed + draw_line,wait_vblank,get_keys method
# '3': Upsilon speed + draw_circle,fill_circle,fill_polygon,get_palette methods - get_keys
os.environ['KANDINSKY_OS_MODE'] = '<number>'
  • Change starting Model:
# '0': n0100 model speed (not available for moment)
# '1': n0110 model speed
# '2': n0120 model speed (not available for moment)
os.environ['KANDINSKY_MODEL_MODE'] = '<number>'
  • Remove the user interface of window (GUI):
# Note: Shortcut commands are not disabled
os.environ['KANDINSKY_NO_GUI'] = ''
  • Change size of screen:
os.environ['KANDINSKY_SCREEN_SIZE'] = "<width>x<height>"
  • Zoom the window:
# from 1 to 4
os.environ['KANDINSKY_ZOOM_RATIO'] = "<number>"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kandinsky-2.7.1.tar.gz (222.1 kB view hashes)

Uploaded Source

Built Distribution

kandinsky-2.7.1-py3-none-any.whl (224.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page