simplify example

This commit is contained in:
Will McGugan
2021-07-10 21:05:59 +01:00
parent fc61069a82
commit eb3432dee2
2 changed files with 8 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ from rich.text import Text
from textual.app import App from textual.app import App
from textual import events from textual import events
from textual.view import View from textual.view import View
from textual.widgets import Button, Placeholder, Static from textual.widgets import Button, Static
from textual.layouts.grid import GridLayout from textual.layouts.grid import GridLayout
try: try:
@@ -47,14 +47,10 @@ class GridTest(App):
for name in "AC,+/-,%,/,7,8,9,X,4,5,6,-,1,2,3,+,.,=".split(",") for name in "AC,+/-,%,/,7,8,9,X,4,5,6,-,1,2,3,+,.,=".split(",")
} }
buttons["AC"].style = "#000000 on rgb(165,165,165)" for name in ("AC", "+/-", "%"):
buttons["+/-"].style = "#000000 on rgb(165,165,165)" buttons[name].style = "#000000 on rgb(165,165,165)"
buttons["%"].style = "#000000 on rgb(165,165,165)" for name in "/X-+=":
buttons["/"].style = "#ffffff on rgb(255,159,7)" buttons[name].style = "#ffffff on rgb(255,159,7)"
buttons["X"].style = "#ffffff on rgb(255,159,7)"
buttons["-"].style = "#ffffff on rgb(255,159,7)"
buttons["+"].style = "#ffffff on rgb(255,159,7)"
buttons["="].style = "#ffffff on rgb(255,159,7)"
zero_text = make_text("0") zero_text = make_text("0")
layout.place( layout.place(

View File

@@ -307,10 +307,9 @@ class GridLayout(Layout):
except (KeyError, IndexError): except (KeyError, IndexError):
continue continue
free_slots -= { free_slots.difference_update(
(col, row) product(range(col1, col2 + 1), range(row1, row2 + 1))
for col, row in product(range(col1, col2 + 1), range(row1, row2 + 1)) )
}
region = self._align( region = self._align(
from_corners(x1, y1, x2, y2), from_corners(x1, y1, x2, y2),