Skip to content

aeimi/nim-easygui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyGUI - Simple Nim GUI Library

An extremely simple GUI library for Nim with English-like syntax. Under 400 lines of code!

Features

Super Simple Syntax - English-like commands

Windows Native - Uses Windows API directly

Under 400 LOC - Minimal and lightweight

Real GUI Controls - Clickable buttons, text inputs

Event Handling - Button clicks and callbacks

Installation

  1. Clone or download this library
  2. Install dependencies:
nimble install winim

Quick Start

import easygui # Create a window discard createWindow("My App", 400, 300) # Add widgets addLabel("Hello World!") addButton("Click Me") do: showMessage("Button clicked!") addInput("Enter name:", "John Doe") # Show the window showWindow()

API Reference

Window Functions

  • createWindow(title, width, height) - Creates a new window
  • showWindow() - Shows the window and starts message loop
  • closeWindow() - Closes the current window

Widget Functions

  • addLabel(text) - Adds a text label
  • addButton(text, onClick) - Adds a clickable button
  • addInput(placeholder, defaultValue) - Adds a text input field

Layout Functions

  • addSpace(pixels) - Adds vertical spacing
  • addRow() - Starts a new row (adds small space)
  • addColumn() - Placeholder for future column layout

Event Functions

  • showMessage(message) - Shows a message (console for now)

Examples

Hello World

import easygui discard createWindow("Hello", 300, 200) addLabel("Hello World!") showWindow()

Calculator

import easygui discard createWindow("Calculator", 300, 400) addLabel("Simple Calculator") addButton("1") do: showMessage("1 clicked") addButton("2") do: showMessage("2 clicked") addButton("+") do: showMessage("Plus clicked") showWindow()

Form

import easygui discard createWindow("Form", 400, 300) addLabel("User Registration") addLabel("Name:") addInput("Enter name", "") addLabel("Email:") addInput("Enter email", "") addButton("Submit") do: showMessage("Form submitted!") showWindow()

File Structure

easygui/ ├── src/ │ ├── easygui.nim # Main library (exports everything) │ ├── window.nim # Window management & Windows API │ ├── widgets.nim # Widget functions (label, button, input) │ └── events.nim # Event handling & callbacks ├── examples/ │ ├── hello_world.nim # Basic example │ ├── calculator.nim # Button example │ └── form.nim # Input example ├── tests/ │ └── test_basic.nim # Basic functionality tests ├── easygui.nimble # Package configuration └── README.md # This file 

Requirements

  • Windows (currently Windows-only)
  • Nim 1.6.0 or higher
  • winim package (nimble install winim)

Design Principles

  1. English-like syntax : addButton("Save") not newButton().setText("Save")
  2. Implicit context : Widgets automatically added to current window
  3. Callback style : Use do: blocks for event handling
  4. Sensible defaults : Minimize required parameters
  5. Progressive disclosure : Start simple, add complexity as needed

Library Stats

  • Total Lines : ~350 lines of code
  • Files : 4 source files + examples
  • Dependencies : Only winim for Windows API
  • Hello World : 5 lines of code

License

MIT License

Contributing

This is a minimal library by design. For feature requests, please consider if they align with the "extremely simple" goal.

About

Extremely simple GUI library for Nim with English-like syntax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages