mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-19 16:33:00 +00:00
fix(stock_news): Resolve UnboundLocalError for width/height
This commit is contained in:
@@ -190,13 +190,14 @@ class StockNewsManager:
|
|||||||
if not all_news:
|
if not all_news:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Define width and height here, so they are always available
|
||||||
|
width = self.display_manager.matrix.width
|
||||||
|
height = self.display_manager.matrix.height
|
||||||
|
|
||||||
# Create a continuous scrolling image if needed
|
# Create a continuous scrolling image if needed
|
||||||
if self.cached_text_image is None:
|
if self.cached_text_image is None:
|
||||||
random.shuffle(all_news)
|
random.shuffle(all_news)
|
||||||
|
|
||||||
width = self.display_manager.matrix.width
|
|
||||||
height = self.display_manager.matrix.height
|
|
||||||
|
|
||||||
# Estimate total width needed (adjust multiplier if needed)
|
# Estimate total width needed (adjust multiplier if needed)
|
||||||
# Average headline length guess + symbol + screen width gap
|
# Average headline length guess + symbol + screen width gap
|
||||||
estimated_item_width = width * 3 # Estimate each item + gap needs ~3 screen widths
|
estimated_item_width = width * 3 # Estimate each item + gap needs ~3 screen widths
|
||||||
@@ -243,7 +244,7 @@ class StockNewsManager:
|
|||||||
# self.last_update = time.time()
|
# self.last_update = time.time()
|
||||||
|
|
||||||
# --- Scrolling logic remains the same ---
|
# --- Scrolling logic remains the same ---
|
||||||
width = self.display_manager.matrix.width
|
# width = self.display_manager.matrix.width # Moved up
|
||||||
# Check if cached image exists before accessing width
|
# Check if cached image exists before accessing width
|
||||||
if self.cached_text_image is None:
|
if self.cached_text_image is None:
|
||||||
logger.warning("[StockNews] Cached image is None, cannot scroll.")
|
logger.warning("[StockNews] Cached image is None, cannot scroll.")
|
||||||
|
|||||||
Reference in New Issue
Block a user