mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
ui/urwid: split to files
This commit is contained in:
@@ -9,10 +9,7 @@ import xdg
|
|||||||
from pqcli import lingo, random
|
from pqcli import lingo, random
|
||||||
from pqcli.mechanic import Player
|
from pqcli.mechanic import Player
|
||||||
from pqcli.roster import Roster
|
from pqcli.roster import Roster
|
||||||
from pqcli.ui.urwid.confirm_dialog import ConfirmDialog
|
from pqcli.ui.urwid.views import ConfirmView, GameView, NewGameView, RosterView
|
||||||
from pqcli.ui.urwid.game_view import GameView
|
|
||||||
from pqcli.ui.urwid.new_game_view import NewGameView
|
|
||||||
from pqcli.ui.urwid.roster_view import RosterView
|
|
||||||
|
|
||||||
from ..base import BaseUserInterface
|
from ..base import BaseUserInterface
|
||||||
|
|
||||||
@@ -50,7 +47,7 @@ def save_palette() -> None:
|
|||||||
PALETTE_PATH.write_text(json.dumps(PALETTE, indent=4))
|
PALETTE_PATH.write_text(json.dumps(PALETTE, indent=4))
|
||||||
|
|
||||||
|
|
||||||
class ConfirmExitDialog(ConfirmDialog):
|
class ConfirmExitDialog(ConfirmView):
|
||||||
def __init__(self, old_view: urwid.Widget) -> None:
|
def __init__(self, old_view: urwid.Widget) -> None:
|
||||||
super().__init__("Really quit?", old_view)
|
super().__init__("Really quit?", old_view)
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ class UrwidUserInterface(BaseUserInterface):
|
|||||||
player_name = self.roster.players[player_idx].name
|
player_name = self.roster.players[player_idx].name
|
||||||
|
|
||||||
self.old_views.append(self.loop.widget)
|
self.old_views.append(self.loop.widget)
|
||||||
self.loop.widget = ConfirmDialog(
|
self.loop.widget = ConfirmView(
|
||||||
lingo.terminate_message(player_name), self.old_views[-1]
|
lingo.terminate_message(player_name), self.old_views[-1]
|
||||||
)
|
)
|
||||||
self._connect("confirm", lambda: self.delete_player(player_idx))
|
self._connect("confirm", lambda: self.delete_player(player_idx))
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .confirm_view import ConfirmView
|
||||||
|
from .game_view import GameView
|
||||||
|
from .new_game_view import NewGameView
|
||||||
|
from .roster_view import RosterView
|
||||||
@@ -2,12 +2,10 @@ import typing as T
|
|||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from pqcli.ui.urwid.custom_button import CustomButton
|
from pqcli.ui.urwid.widgets import CustomButton, CustomLineBox, NPile
|
||||||
from pqcli.ui.urwid.custom_line_box import CustomLineBox
|
|
||||||
from pqcli.ui.urwid.layout import NPile
|
|
||||||
|
|
||||||
|
|
||||||
class ConfirmDialog(urwid.Overlay):
|
class ConfirmView(urwid.Overlay):
|
||||||
signals = ["confirm", "cancel"]
|
signals = ["confirm", "cancel"]
|
||||||
|
|
||||||
def __init__(self, label: str, parent: urwid.Widget) -> None:
|
def __init__(self, label: str, parent: urwid.Widget) -> None:
|
||||||
@@ -15,13 +15,17 @@ from pqcli.mechanic import (
|
|||||||
Spell,
|
Spell,
|
||||||
)
|
)
|
||||||
from pqcli.roster import Roster
|
from pqcli.roster import Roster
|
||||||
from pqcli.ui.urwid.custom_line_box import CustomLineBox
|
from pqcli.ui.urwid.widgets import (
|
||||||
from pqcli.ui.urwid.custom_progress_bar import CustomProgressBar
|
CustomLineBox,
|
||||||
from pqcli.ui.urwid.data_table import DataTable
|
CustomProgressBar,
|
||||||
from pqcli.ui.urwid.double_line_box import DoubleLineBox
|
DataTable,
|
||||||
from pqcli.ui.urwid.layout import NColumns, NPile
|
DoubleLineBox,
|
||||||
from pqcli.ui.urwid.read_only_check_box import ReadOnlyCheckBox
|
NColumns,
|
||||||
from pqcli.ui.urwid.scrollable import Scrollable, ScrollBar
|
NPile,
|
||||||
|
ReadOnlyCheckBox,
|
||||||
|
Scrollable,
|
||||||
|
ScrollBar,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CharacterSheetView(DoubleLineBox):
|
class CharacterSheetView(DoubleLineBox):
|
||||||
@@ -6,9 +6,7 @@ import urwid_readline
|
|||||||
|
|
||||||
from pqcli.config import CLASSES, PRIME_STATS, RACES
|
from pqcli.config import CLASSES, PRIME_STATS, RACES
|
||||||
from pqcli.mechanic import StatsBuilder, create_player, generate_name
|
from pqcli.mechanic import StatsBuilder, create_player, generate_name
|
||||||
from pqcli.ui.urwid.custom_button import CustomButton
|
from pqcli.ui.urwid.widgets import CustomButton, CustomLineBox, NColumns, NPile
|
||||||
from pqcli.ui.urwid.custom_line_box import CustomLineBox
|
|
||||||
from pqcli.ui.urwid.layout import NColumns, NPile
|
|
||||||
|
|
||||||
|
|
||||||
class StatsBox(CustomLineBox):
|
class StatsBox(CustomLineBox):
|
||||||
@@ -4,8 +4,7 @@ import urwid
|
|||||||
|
|
||||||
from pqcli.lingo import act_name, to_roman
|
from pqcli.lingo import act_name, to_roman
|
||||||
from pqcli.roster import Roster
|
from pqcli.roster import Roster
|
||||||
from pqcli.ui.urwid.custom_button import CustomButton
|
from pqcli.ui.urwid.widgets import CustomButton, NColumns, NPile
|
||||||
from pqcli.ui.urwid.layout import NColumns, NPile
|
|
||||||
|
|
||||||
|
|
||||||
class RosterView(urwid.Filler):
|
class RosterView(urwid.Filler):
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from .custom_button import CustomButton
|
||||||
|
from .custom_line_box import CustomLineBox
|
||||||
|
from .custom_progress_bar import CustomProgressBar
|
||||||
|
from .data_table import DataTable
|
||||||
|
from .double_line_box import DoubleLineBox
|
||||||
|
from .layout import NColumns, NPile
|
||||||
|
from .read_only_check_box import ReadOnlyCheckBox
|
||||||
|
from .scrollable import ScrollBar, Scrollable
|
||||||
@@ -2,7 +2,7 @@ import typing as T
|
|||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from pqcli.ui.urwid.layout import NColumns, NPile
|
from pqcli.ui.urwid.widgets.layout import NColumns, NPile
|
||||||
|
|
||||||
|
|
||||||
class DataTable(NPile):
|
class DataTable(NPile):
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from pqcli.ui.urwid.layout import NPile
|
from pqcli.ui.urwid.widgets.layout import NPile
|
||||||
|
|
||||||
|
|
||||||
class DoubleLineBox(urwid.AttrMap):
|
class DoubleLineBox(urwid.AttrMap):
|
||||||
Reference in New Issue
Block a user