mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
ui: use urwid constants
This commit is contained in:
@@ -17,13 +17,13 @@ class CustomButton(urwid.Button):
|
|||||||
self._w = urwid.AttrMap(
|
self._w = urwid.AttrMap(
|
||||||
urwid.Columns(
|
urwid.Columns(
|
||||||
[
|
[
|
||||||
("pack", urwid.Text("< ")),
|
(urwid.PACK, urwid.Text("< ")),
|
||||||
urwid.SelectableIcon([label], _MAGIC),
|
urwid.SelectableIcon([label], _MAGIC),
|
||||||
(
|
(
|
||||||
"pack",
|
urwid.PACK,
|
||||||
urwid.Text(f"[{hint}]" if hint else "", align="right"),
|
urwid.Text(f"[{hint}]" if hint else "", align="right"),
|
||||||
),
|
),
|
||||||
("pack", urwid.Text(" >")),
|
(urwid.PACK, urwid.Text(" >")),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
"button",
|
"button",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class DataTable(urwid.Pile):
|
|||||||
urwid.Columns(
|
urwid.Columns(
|
||||||
list((*x, y) for x, y in zip(self._columns, widgets))
|
list((*x, y) for x, y in zip(self._columns, widgets))
|
||||||
),
|
),
|
||||||
("pack", 1),
|
(urwid.PACK, 1),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._rows.append(widgets)
|
self._rows.append(widgets)
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ class DoubleLineBox(urwid.AttrMap):
|
|||||||
)
|
)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
urwid.Pile([self.top_line_box, ("pack", self.bottom_line_box)]),
|
urwid.Pile(
|
||||||
|
[self.top_line_box, (urwid.PACK, self.bottom_line_box)]
|
||||||
|
),
|
||||||
"linebox",
|
"linebox",
|
||||||
"linebox-focus",
|
"linebox-focus",
|
||||||
)
|
)
|
||||||
|
|||||||
+10
-10
@@ -30,7 +30,7 @@ class CharacterSheetView(DoubleLineBox):
|
|||||||
self.stat_texts = {stat: urwid.Text("") for stat in list(StatType)}
|
self.stat_texts = {stat: urwid.Text("") for stat in list(StatType)}
|
||||||
self.exp_bar = CustomProgressBar()
|
self.exp_bar = CustomProgressBar()
|
||||||
|
|
||||||
data_table = DataTable(columns=[("weight", 1), ("weight", 1)])
|
data_table = DataTable(columns=[(urwid.WEIGHT, 1), (urwid.WEIGHT, 1)])
|
||||||
data_table.add_row(urwid.Text("Name"), urwid.Text(player.name))
|
data_table.add_row(urwid.Text("Name"), urwid.Text(player.name))
|
||||||
data_table.add_row(urwid.Text("Race"), urwid.Text(player.race.name))
|
data_table.add_row(urwid.Text("Race"), urwid.Text(player.race.name))
|
||||||
data_table.add_row(urwid.Text("Class"), urwid.Text(player.class_.name))
|
data_table.add_row(urwid.Text("Class"), urwid.Text(player.class_.name))
|
||||||
@@ -75,7 +75,7 @@ class SpellBookView(CustomLineBox):
|
|||||||
def __init__(self, player: Player) -> None:
|
def __init__(self, player: Player) -> None:
|
||||||
self.player = player
|
self.player = player
|
||||||
|
|
||||||
self.data_table = DataTable(columns=[("weight", 3), ("pack",)])
|
self.data_table = DataTable(columns=[(urwid.WEIGHT, 3), (urwid.PACK,)])
|
||||||
self.scrollable = Scrollable(self.data_table)
|
self.scrollable = Scrollable(self.data_table)
|
||||||
|
|
||||||
self.player.spell_book.connect("add", self.sync_spell_add)
|
self.player.spell_book.connect("add", self.sync_spell_add)
|
||||||
@@ -110,7 +110,7 @@ class EquipmentView(CustomLineBox):
|
|||||||
self.value_texts = {
|
self.value_texts = {
|
||||||
equipment_type: urwid.Text("") for equipment_type in EquipmentType
|
equipment_type: urwid.Text("") for equipment_type in EquipmentType
|
||||||
}
|
}
|
||||||
data_table = DataTable(columns=[("weight", 1), ("weight", 3)])
|
data_table = DataTable(columns=[(urwid.WEIGHT, 1), (urwid.WEIGHT, 3)])
|
||||||
for equipment_type in EquipmentType:
|
for equipment_type in EquipmentType:
|
||||||
data_table.add_row(
|
data_table.add_row(
|
||||||
urwid.Text(equipment_type.value),
|
urwid.Text(equipment_type.value),
|
||||||
@@ -139,7 +139,7 @@ class InventoryView(DoubleLineBox):
|
|||||||
self.player = player
|
self.player = player
|
||||||
|
|
||||||
self.gold_text = urwid.Text("")
|
self.gold_text = urwid.Text("")
|
||||||
self.data_table = DataTable(columns=[("weight", 3), ("pack",)])
|
self.data_table = DataTable(columns=[(urwid.WEIGHT, 3), (urwid.PACK,)])
|
||||||
self.data_table.add_row(urwid.Text("Gold"), self.gold_text)
|
self.data_table.add_row(urwid.Text("Gold"), self.gold_text)
|
||||||
self.scrollable = Scrollable(self.data_table)
|
self.scrollable = Scrollable(self.data_table)
|
||||||
self.encumbrance_bar = CustomProgressBar()
|
self.encumbrance_bar = CustomProgressBar()
|
||||||
@@ -215,7 +215,7 @@ class PlotView(DoubleLineBox):
|
|||||||
def __init__(self, player: Player) -> None:
|
def __init__(self, player: Player) -> None:
|
||||||
self.player = player
|
self.player = player
|
||||||
|
|
||||||
self.data_table = DataTable(columns=[("weight", 1)])
|
self.data_table = DataTable(columns=[(urwid.WEIGHT, 1)])
|
||||||
self.scrollable = Scrollable(self.data_table)
|
self.scrollable = Scrollable(self.data_table)
|
||||||
self.plot_bar = CustomProgressBar()
|
self.plot_bar = CustomProgressBar()
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ class QuestBookView(DoubleLineBox):
|
|||||||
def __init__(self, player: Player) -> None:
|
def __init__(self, player: Player) -> None:
|
||||||
self.player = player
|
self.player = player
|
||||||
|
|
||||||
self.data_table = DataTable(columns=[("weight", 1)])
|
self.data_table = DataTable(columns=[(urwid.WEIGHT, 1)])
|
||||||
self.quest_bar = CustomProgressBar()
|
self.quest_bar = CustomProgressBar()
|
||||||
self.scrollable = Scrollable(self.data_table)
|
self.scrollable = Scrollable(self.data_table)
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ class GameView(urwid.Pile):
|
|||||||
urwid.Columns(
|
urwid.Columns(
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"weight",
|
urwid.WEIGHT,
|
||||||
1,
|
1,
|
||||||
urwid.Pile(
|
urwid.Pile(
|
||||||
[
|
[
|
||||||
@@ -366,7 +366,7 @@ class GameView(urwid.Pile):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"weight",
|
urwid.WEIGHT,
|
||||||
2,
|
2,
|
||||||
urwid.Pile(
|
urwid.Pile(
|
||||||
[
|
[
|
||||||
@@ -376,7 +376,7 @@ class GameView(urwid.Pile):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"weight",
|
urwid.WEIGHT,
|
||||||
2,
|
2,
|
||||||
urwid.Pile(
|
urwid.Pile(
|
||||||
[(15, self.plot_view), self.quest_book_view]
|
[(15, self.plot_view), self.quest_book_view]
|
||||||
@@ -384,7 +384,7 @@ class GameView(urwid.Pile):
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
("pack", self.task_view),
|
(urwid.PACK, self.task_view),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ class NewGameView(urwid.Pile):
|
|||||||
),
|
),
|
||||||
urwid.Columns(
|
urwid.Columns(
|
||||||
[
|
[
|
||||||
("weight", 2, self.race_box),
|
(urwid.WEIGHT, 2, self.race_box),
|
||||||
("weight", 2, self.class_box),
|
(urwid.WEIGHT, 2, self.class_box),
|
||||||
urwid.Pile([(13, self.stats_box), buttons_box]),
|
urwid.Pile([(13, self.stats_box), buttons_box]),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user