Compare commits
No commits in common. 'master' and '3-keyboard-control' have entirely different histories.
master
...
3-keyboard
@ -1,24 +0,0 @@
|
|||||||
from textual.command import DiscoveryHit, Provider, Hits, Hit
|
|
||||||
|
|
||||||
class AboutCommand(Provider):
|
|
||||||
'''Class to represent the About command in the menu'''
|
|
||||||
|
|
||||||
async def discover(self) -> Hits:
|
|
||||||
yield DiscoveryHit(
|
|
||||||
display='About',
|
|
||||||
command=self.app.action_toggle_sidebar,
|
|
||||||
help='Link to repo etc.'
|
|
||||||
)
|
|
||||||
|
|
||||||
async def search(self, query: str) -> Hits:
|
|
||||||
'''Called when the search functionality is used'''
|
|
||||||
matcher = self.matcher(query)
|
|
||||||
command = "About"
|
|
||||||
score = matcher.match(command)
|
|
||||||
if score > 0:
|
|
||||||
yield Hit(
|
|
||||||
score,
|
|
||||||
matcher.highlight(command),
|
|
||||||
self.app.action_toggle_sidebar,
|
|
||||||
'Link to repo etc.'
|
|
||||||
)
|
|
@ -1,54 +0,0 @@
|
|||||||
from textual.widgets import Input, Static, Button
|
|
||||||
from textual.containers import Horizontal
|
|
||||||
from textual.validation import Number
|
|
||||||
from textual.app import ComposeResult
|
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from BingoBoard import BingoBoard
|
|
||||||
|
|
||||||
class BingoDisplay(Static):
|
|
||||||
'''
|
|
||||||
A Widget to represent the bingo UI.
|
|
||||||
|
|
||||||
Contains the board, input field and re-roll button.
|
|
||||||
|
|
||||||
Attributes
|
|
||||||
----------
|
|
||||||
board : BingoBoard
|
|
||||||
The BingoBoard object
|
|
||||||
input_field : Input
|
|
||||||
User input for game seed
|
|
||||||
'''
|
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
|
||||||
'''Create child widgets for the app.'''
|
|
||||||
self.board = BingoBoard()
|
|
||||||
yield self.board
|
|
||||||
self.input_field = Input(
|
|
||||||
str(self.board.seed),
|
|
||||||
type='integer',
|
|
||||||
placeholder='UNIX timestamp',
|
|
||||||
max_length=10,
|
|
||||||
classes='seed_input',
|
|
||||||
validators=[
|
|
||||||
Number(minimum=1000000000, maximum = 2000000000)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
self.input_field.border_title = 'Seed'
|
|
||||||
yield Horizontal(
|
|
||||||
self.input_field,
|
|
||||||
Button.error(':game_die: re-roll', classes='roll_btn'),
|
|
||||||
classes='bottom_line'
|
|
||||||
)
|
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
||||||
'''Re-roll the board state with current time as seed'''
|
|
||||||
self.board.roll_board(int(datetime.now().timestamp()))
|
|
||||||
self.input_field.value = str(self.board.seed)
|
|
||||||
|
|
||||||
def on_input_submitted(self, event: Input.Submitted) -> None:
|
|
||||||
'''Re-roll the board state with the seed from the input'''
|
|
||||||
if event.validation_result.is_valid:
|
|
||||||
self.board.roll_board(int(event.value))
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
# bingo-cli - Play bingo in your terminal (or browser)
|
|
||||||
|
|
||||||
bingo-cli is a TUI to play Bingo, built using [Textual](https://textual.textualize.io/).
|
|
||||||
|
|
||||||
![bingo screenshot](img/bingo.png)
|
|
||||||
|
|
||||||
## Features
|
|
||||||
- Mouse and keyboard controls
|
|
||||||
- Reproducible board states (by supplying UNIX timestamps)
|
|
||||||
- Playable directly in your terminal, remotely via SSH or web browser
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Install in python3 venv
|
|
||||||
|
|
||||||
```
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
# test to see if it works:
|
|
||||||
python3 bingo.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Serve as a webpage
|
|
||||||
|
|
||||||
- Install requirements as above.
|
|
||||||
- Download the latest build of `ttyd`: https://github.com/tsl0922/ttyd/releases
|
|
||||||
```
|
|
||||||
chmod +x ttyd
|
|
||||||
# if not already in venv:
|
|
||||||
source venv/bin/activate
|
|
||||||
./ttyd -W ./bingo.py
|
|
||||||
```
|
|
||||||
- Bingo is now served on `http://localhost:7681`.
|
|
||||||
- Check `ttyd --help` for more options and consider building a reverse proxy and `systemd` service.
|
|
||||||
|
|
||||||
### Serve via SSH
|
|
||||||
|
|
||||||
TBA
|
|
@ -1,31 +0,0 @@
|
|||||||
from textual.containers import Container
|
|
||||||
from textual.app import ComposeResult
|
|
||||||
from textual.widgets import Static, Button
|
|
||||||
|
|
||||||
MESSAGE = '''
|
|
||||||
Be excellent to each other!
|
|
||||||
|
|
||||||
Made with :red_heart: by Panki
|
|
||||||
|
|
||||||
[@click="app.open_link('https://tty0.social/@panki')"]Mastodon:[/] tty0.social/@panki
|
|
||||||
[@click="app.open_link('https://git.theresno.cloud/panki/bingo-cli')"]Source:[/] git.theresno.cloud/panki/bingo-cli
|
|
||||||
|
|
||||||
Built using [@click="app.open_link('https://textual.textualize.io/')"]Textual[/]
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
class Sidebar(Container):
|
|
||||||
'''Class to represent the sidebar'''
|
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
|
||||||
'''Create the widgets that make up the sidebar'''
|
|
||||||
yield Static('CCC Bingo', classes='title')
|
|
||||||
yield Static(MESSAGE, classes='message')
|
|
||||||
self.button = Button('< Back', variant='primary', classes='btn_sidebar')
|
|
||||||
self.button.disabled = True
|
|
||||||
yield self.button
|
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
||||||
'''Closes the sidebar'''
|
|
||||||
self.app.action_toggle_sidebar()
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue