Tk Interface¶
The Tkinter (Tk) interface provides a graphical IDE for MBASIC programming.
Starting the Tk UI¶
Or:
Window Layout¶
The Tk UI has three main sections:
┌─ MBASIC ────────────────────────────────┐
│ File Edit Run Help │
├──────────────────────────────────────────┤
│ Editor │
│ 10 PRINT "Hello, World!" │
│ 20 END │
│ _ │
│ │
├──────────────────────────────────────────┤
│ Output │
│ Hello, World! │
│ │
└──────────────────────────────────────────┘
Menu Bar¶
File Menu¶
- New ({{kbd:file_new:tk}}) - Clear program
- Open ({{kbd:file_open:tk}}) - Load program file
- Save ({{kbd:file_save:tk}}) - Save current program
- Save As - Save with new name
- Exit - Quit MBASIC
Edit Menu¶
- Cut ({{kbd:cut:tk}}) - Cut selected text
- Copy ({{kbd:copy:tk}}) - Copy selected text
- Paste ({{kbd:paste:tk}}) - Paste clipboard
- Select All ({{kbd:select_all:tk}}) - Select all text
- Find ({{kbd:find:tk}}) - Search in program
Run Menu¶
- Run ({{kbd:run_program:tk}}) - Execute program
- Stop - Interrupt execution (menu only)
- Clear Output - Clear output pane
Help Menu¶
- Help Topics (F1) - Open help browser
- About - About MBASIC
Editor Pane¶
The top pane is where you write your BASIC program.
Features: - Syntax highlighting (optional) - Line numbers - Auto-indentation - Find and replace
Output Pane¶
The bottom pane shows program output: - PRINT statements - Error messages - INPUT prompts
Writing Programs¶
- Click in the editor pane
- Type your program with line numbers
- Lines automatically sort by number
Example:
Running Programs¶
Click Run → Run or press {{kbd:run_program:tk}}.
Output appears in the output pane.
Input Handling¶
When your program uses INPUT:
A dialog box appears for you to type your response.
Immediate Mode Panel¶
Some Tk configurations include an immediate mode panel for quick calculations:
Type expressions without line numbers for immediate execution.
Keyboard Shortcuts¶
| Shortcut | Action |
|---|---|
| {{kbd:file_new:tk}} | New program |
| {{kbd:file_open:tk}} | Open file |
| {{kbd:file_save:tk}} | Save file |
| {{kbd:run_program:tk}} | Run program |
| {{kbd:find:tk}} | Find |
| F1 | Help |
File Operations¶
Save your program: 1. Click File → Save (or {{kbd:file_save:tk}}) 2. Choose filename and location 3. Click Save
Load a program: 1. Click File → Open (or {{kbd:file_open:tk}}) 2. Select the .bas file 3. Click Open
Help Browser¶
Press F1 or click Help → Help Topics to open the built-in help browser.
Features: - Search across all documentation - Clickable links - Three-tier help system (Language, MBASIC, UI) - Right-click to copy or open in new window
Error Messages¶
Errors appear in the output pane:
Click on line 20 in the editor to fix it.
Tips¶
- Use {{kbd:file_save:tk}} often - Save your work frequently
- Clear output - Use Run → Clear Output between runs
- Use Find - {{kbd:find:tk}} to search for variables/statements
- Right-click in help - Copy examples or open new windows
- Check output pane - Errors and PRINT output go here
Common Issues¶
Output not appearing: - Check that OUTPUT pane is visible - Some programs may need UPDATE or FLUSH
INPUT not working: - Wait for dialog box to appear - Type your response and press OK
Program won't stop: - Use Run → Stop menu - Add END statement to your program
Advantages of Tk UI¶
- Mouse support - Click and select text
- Multiple windows - Help in separate window
- File dialogs - Easy file management
- Copy/paste - Standard clipboard operations
- Visual - See editor and output simultaneously