kopia lustrzana https://github.com/peterhinch/micropython-micro-gui
Fix window with one active widget closing on pressing button.
rodzic
5ed42f918d
commit
a3dc83f357
|
@ -261,6 +261,8 @@ class Screen:
|
|||
if isinstance(cs_old, Window):
|
||||
raise ValueError('Windows are modal.')
|
||||
new_screen = cls_new_screen(*args, **kwargs)
|
||||
if not len(new_screen.lstactive):
|
||||
raise ValueError("Screen has no active widgets.")
|
||||
else:
|
||||
raise ValueError('Must pass Screen class or subclass (not instance)')
|
||||
new_screen.parent = cs_old
|
||||
|
@ -411,10 +413,10 @@ class Screen:
|
|||
lo.show() # Re-display with new status
|
||||
co.enter() # Tell object it has currency
|
||||
co.show()
|
||||
elif isinstance(self, Window):
|
||||
#elif isinstance(self, Window):
|
||||
# Special case of Window with one object: leave
|
||||
# without making changes (Dropdown in particular)
|
||||
Screen.back()
|
||||
#Screen.back()
|
||||
done = True
|
||||
|
||||
# Move currency to a specific control.
|
||||
|
@ -488,7 +490,8 @@ class Window(Screen):
|
|||
cls._value = val
|
||||
return cls._value
|
||||
|
||||
def __init__(self, row, col, height, width, *, draw_border=True, bgcolor=None, fgcolor=None):
|
||||
def __init__(self, row, col, height, width, *, draw_border=True,
|
||||
bgcolor=None, fgcolor=None):
|
||||
Screen.__init__(self)
|
||||
self.row = row
|
||||
self.col = col
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# listbox.py Extension to ugui providing the Listbox class
|
||||
|
||||
# Released under the MIT License (MIT). See LICENSE.
|
||||
# Copyright (c) 2021 Peter Hinch
|
||||
# Copyright (c) 2021-2022 Peter Hinch
|
||||
|
||||
# 12 Sep 21 Support for scrolling.
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Listbox(Widget):
|
|||
ON_MOVE = 1 # Also run whenever the currency moves.
|
||||
ON_LEAVE = 2 # Also run on exit from the control.
|
||||
|
||||
# This is used by dropdown.py
|
||||
# This is used by dropdown.py and menu.py
|
||||
@staticmethod
|
||||
def dimensions(writer, elements, dlines):
|
||||
# Height of a single entry in list.
|
||||
|
|
|
@ -26,7 +26,7 @@ class SubMenu(Window):
|
|||
# depends on number and length of elements.
|
||||
te = [x[0] for x in elements] # Text part
|
||||
self.elements = elements
|
||||
entry_height, lb_height, textwidth = Listbox.dimensions(wri, te)
|
||||
entry_height, lb_height, _, textwidth = Listbox.dimensions(wri, te, None)
|
||||
lb_width = textwidth + 2
|
||||
# Calculate Window dimensions
|
||||
ap_height = lb_height + 6 # Allow for listbox border
|
||||
|
|
|
@ -51,4 +51,4 @@ sel = Pin(16, Pin.IN, Pin.PULL_UP) # Operate current control
|
|||
prev = Pin(18, Pin.IN, Pin.PULL_UP) # Move to previous control
|
||||
increase = Pin(20, Pin.IN, Pin.PULL_UP) # Increase control's value
|
||||
decrease = Pin(17, Pin.IN, Pin.PULL_UP) # Decrease control's value
|
||||
display = Display(ssd, nxt, sel, prev, increase, decrease, 5)
|
||||
display = Display(ssd, nxt, sel, prev, increase, decrease) #, 5)
|
||||
|
|
Ładowanie…
Reference in New Issue