mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-31 11:44:17 -04:00
Fixed multiple urwid screen init calls
This commit is contained in:
parent
0889d4e5e3
commit
b022631382
1 changed files with 8 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
import RNS
|
||||
import time
|
||||
import nomadnet
|
||||
from math import log10, pow
|
||||
|
||||
from nomadnet.vendor.additional_urwid_widgets.FormWidgets import *
|
||||
|
@ -70,6 +71,9 @@ def format_bytes(bytes_value):
|
|||
else:
|
||||
return f"{size:.1f} {units[unit_index]}"
|
||||
|
||||
def _get_cols_rows():
|
||||
return nomadnet.NomadNetworkApp.get_shared_instance().ui.screen.get_cols_rows()
|
||||
|
||||
|
||||
### PORT FUNCTIONS ###
|
||||
PYSERIAL_AVAILABLE = False # If NomadNet is installed on environments with rnspure instead of rns, pyserial won't be available
|
||||
|
@ -2215,6 +2219,7 @@ class ShowInterface(urwid.WidgetWrap):
|
|||
self.config_rows = []
|
||||
|
||||
self.history_length=60
|
||||
RNS.log(f"Col/rows: {_get_cols_rows()}")
|
||||
|
||||
# get interface stats
|
||||
interface_stats = self.parent.app.rns.get_interface_stats()
|
||||
|
@ -2339,8 +2344,7 @@ class ShowInterface(urwid.WidgetWrap):
|
|||
self.charts_widget = self.vertical_charts
|
||||
self.is_horizontal = False
|
||||
|
||||
screen = urwid.raw_display.Screen()
|
||||
screen_cols, _ = screen.get_cols_rows()
|
||||
screen_cols, _ = _get_cols_rows()
|
||||
# RNS.log(screen_cols)
|
||||
if screen_cols >= 145:
|
||||
self.charts_widget = self.horizontal_charts
|
||||
|
@ -2819,7 +2823,7 @@ class InterfaceDisplay:
|
|||
self.glyphset = self.app.config["textui"]["glyphs"]
|
||||
self.g = self.app.ui.glyphs
|
||||
|
||||
self.terminal_cols, self.terminal_rows = urwid.raw_display.Screen().get_cols_rows()
|
||||
self.terminal_cols, self.terminal_rows = _get_cols_rows()
|
||||
self.iface_row_offset = 4
|
||||
self.list_rows = self.terminal_rows - self.iface_row_offset
|
||||
|
||||
|
@ -2926,7 +2930,7 @@ class InterfaceDisplay:
|
|||
self.switch_to_edit_interface(interface_name)
|
||||
|
||||
def check_terminal_size(self, loop, user_data):
|
||||
new_cols, new_rows = loop.screen.get_cols_rows()
|
||||
new_cols, new_rows = _get_cols_rows()
|
||||
|
||||
if new_rows != self.terminal_rows or new_cols != self.terminal_cols:
|
||||
self.terminal_cols, self.terminal_rows = new_cols, new_rows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue