Posts: 13
Threads: 2
Joined: May 2018
May-31-2018, 02:40 PM
(This post was last modified: May-31-2018, 02:48 PM by trippyt.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
import sys
import time
import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption
from time import sleep
sys.path.append( '/home/pi/Pimoroni/displayotron/examples' )
from plugins.clock import Clock
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphSysReboot, GraphSysShutdown
from plugins.text import Text
from plugins.utils import Backlight, Contrast
print (
)
class Lightcontrol(MenuOption):
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
self .handle_On,
self .handle_Off,
]
MenuOption.__init__( self )
def handle_On( self ):
print ( 'Eeek! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off( self ):
print ( "Oook! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
def select_option( self ):
self .actions[ self .selected_option]()
def next_option( self ):
self .selected_option = ( self .selected_option + 1 ) % len ( self .options)
def prev_option( self ):
self .selected_option = ( self .selected_option - 1 ) % len ( self .options)
def up( self ):
self .prev_option()
def down( self ):
self .next_option()
def right( self ):
self .select_option()
def get_current_option( self ):
return self .options[ self .selected_option]
def get_next_option( self ):
return self .options[( self .selected_option + 1 ) % len ( self .options)]
def get_prev_option( self ):
return self .options[( self .selected_option - 1 ) % len ( self .options)]
def redraw( self , menu):
menu.write_option(
row = 0 ,
margin = 1 ,
icon = '',
text = self .get_prev_option()
)
menu.write_option(
row = 1 ,
margin = 1 ,
icon = '>' ,
text = self .get_current_option()
)
menu.write_option(
row = 2 ,
margin = 1 ,
icon = '',
text = self .get_next_option()
)
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : Lightcontrol(),
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
1 2 3 |
temp.py", line 36 , in Lightcontrol
self .handle_On,
NameError: name 'self' is not defined
|
also tried changing the indent around a few times
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
import sys
import time
import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption
from time import sleep
sys.path.append( '/home/pi/Pimoroni/displayotron/examples' )
from plugins.clock import Clock
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphSysReboot, GraphSysShutdown
from plugins.text import Text
from plugins.utils import Backlight, Contrast
print (
)
class Lightcontrol(MenuOption):
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
self .handle_On,
self .handle_Off,
]
MenuOption.__init__( self )
def handle_On( self ):
print ( 'Eeek! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off( self ):
print ( "Oook! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
def select_option( self ):
self .actions[ self .selected_option]()
def next_option( self ):
self .selected_option = ( self .selected_option + 1 ) % len ( self .options)
def prev_option( self ):
self .selected_option = ( self .selected_option - 1 ) % len ( self .options)
def up( self ):
self .prev_option()
def down( self ):
self .next_option()
def right( self ):
self .select_option()
def get_current_option( self ):
return self .options[ self .selected_option]
def get_next_option( self ):
return self .options[( self .selected_option + 1 ) % len ( self .options)]
def get_prev_option( self ):
return self .options[( self .selected_option - 1 ) % len ( self .options)]
def redraw( self , menu):
menu.write_option(
row = 0 ,
margin = 1 ,
icon = '',
text = self .get_prev_option()
)
menu.write_option(
row = 1 ,
margin = 1 ,
icon = '>' ,
text = self .get_current_option()
)
menu.write_option(
row = 2 ,
margin = 1 ,
icon = '',
text = self .get_next_option()
)
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : Lightcontrol(),
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
Posts: 2,953
Threads: 48
Joined: Sep 2016
May-31-2018, 03:19 PM
(This post was last modified: May-31-2018, 03:34 PM by wavic.)
Self is created when the instance of a class is created. So, there is no self outside the __init__ method. You can remove self. part or do it like this. Try it. I am not really sure of what I am talking about. This is how I understand all that classy classiness
1 2 3 4 5 6 7 8 9 10 |
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
self .handle_On,
self .handle_Off,
]
|
__init__ method is executed when an instance of a class is created. Self is a reference to that instance. self.object is called instance object and defining one outside of the __init__ method obviously is causing this error.
In the other side are the class objects. You just define them as regular objects inside the class definition
1 2 3 4 5 6 |
class Foo:
def __init__( self , obj_1, obj_2, obj_3):
self .one = obj_1
self .two = obj_2
three = obj_3
|
Because class objects are owned by the class they are shared between all instances of that class. While the instance objects are different for every instance of that class.
Posts: 13
Threads: 2
Joined: May 2018
May-31-2018, 03:35 PM
(This post was last modified: May-31-2018, 03:35 PM by trippyt.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
import sys
import time
import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption
from time import sleep
sys.path.append( '/home/pi/Pimoroni/displayotron/examples' )
from plugins.clock import Clock
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphSysReboot, GraphSysShutdown
from plugins.text import Text
from plugins.utils import Backlight, Contrast
print (
)
class Lightcontrol(MenuOption):
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
self .handle_On,
self .handle_Off,
]
def handle_On( self ):
print ( 'Eeek! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off( self ):
print ( "Oook! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
def select_option( self ):
self .actions[ self .selected_option]()
def next_option( self ):
self .selected_option = ( self .selected_option + 1 ) % len ( self .options)
def prev_option( self ):
self .selected_option = ( self .selected_option - 1 ) % len ( self .options)
def up( self ):
self .prev_option()
def down( self ):
self .next_option()
def right( self ):
self .select_option()
def get_current_option( self ):
return self .options[ self .selected_option]
def get_next_option( self ):
return self .options[( self .selected_option + 1 ) % len ( self .options)]
def get_prev_option( self ):
return self .options[( self .selected_option - 1 ) % len ( self .options)]
def redraw( self , menu):
menu.write_option(
row = 0 ,
margin = 1 ,
icon = '',
text = self .get_prev_option()
)
menu.write_option(
row = 1 ,
margin = 1 ,
icon = '>' ,
text = self .get_current_option()
)
menu.write_option(
row = 2 ,
margin = 1 ,
icon = '',
text = self .get_next_option()
)
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : Lightcontrol(),
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
1 2 3 4 5 |
line 146 , in <module>
menu.redraw()
File "/usr/local/lib/python3.5/dist-packages/dot3k/menu.py" , line 477 in redraw
if self .current_value().text_entry:
AttributeError: 'Lightcontrol' object has no attribute 'text_entry'
|
still trying to get my head around classes, just when i think ive cracked it i get another error haha
Posts: 2,953
Threads: 48
Joined: Sep 2016
I added some additional content to my previous post. Look at it. Remove the self. before handle_On and handle_Off.
Do you think to indent line 49 to 96? Are they part of the class definition?
Posts: 13
Threads: 2
Joined: May 2018
May-31-2018, 03:51 PM
(This post was last modified: May-31-2018, 03:59 PM by trippyt.)
We're nearly there, the code works and i can change which gpio is true or false via the doHAT only problem is when your faced with the on or off options the previous error appears in the shell,
however the on and off also dont scroll so you dont know which is selected it appears like:
Off
>On
Off
you also cant seem to go back once on this screen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
import sys
import time
import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption
from time import sleep
sys.path.append( '/home/pi/Pimoroni/displayotron/examples' )
from plugins.clock import Clock
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphSysReboot, GraphSysShutdown
from plugins.text import Text
from plugins.utils import Backlight, Contrast
import RPi.GPIO as GPIO
GPIO.setwarnings( False )
GPIO.setup( 13 ,GPIO.OUT)
GPIO.setup( 5 ,GPIO.OUT)
print (
)
class Lightcontrol(MenuOption):
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
self .handle_On,
self .handle_Off,
]
def handle_On( self ):
GPIO.output( 13 , 0 )
GPIO.output( 5 , 0 )
GPIO.output( 13 , 1 )
print ( 'ON! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off( self ):
GPIO.output( 5 , 0 )
GPIO.output( 13 , 0 )
GPIO.output( 5 , 1 )
print ( "OFF! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
def select_option( self ):
self .actions[ self .selected_option]()
def next_option( self ):
self .selected_option = ( self .selected_option + 1 ) % len ( self .options)
def prev_option( self ):
self .selected_option = ( self .selected_option - 1 ) % len ( self .options)
def up( self ):
self .prev_option()
def down( self ):
self .next_option()
def right( self ):
self .select_option()
def get_current_option( self ):
return self .options[ self .selected_option]
def get_next_option( self ):
return self .options[( self .selected_option + 1 ) % len ( self .options)]
def get_prev_option( self ):
return self .options[( self .selected_option - 1 ) % len ( self .options)]
def redraw( self , menu):
menu.write_option(
row = 0 ,
margin = 1 ,
icon = '',
text = self .get_prev_option()
)
menu.write_option(
row = 1 ,
margin = 1 ,
icon = '>' ,
text = self .get_current_option()
)
menu.write_option(
row = 2 ,
margin = 1 ,
icon = '',
text = self .get_next_option()
)
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : Lightcontrol(),
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
Just tried this think thats what you meant but now i get the name 'handle_on'is not defined again
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
import sys
import time
import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption
from time import sleep
sys.path.append( '/home/pi/Pimoroni/displayotron/examples' )
from plugins.clock import Clock
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphSysReboot, GraphSysShutdown
from plugins.text import Text
from plugins.utils import Backlight, Contrast
import RPi.GPIO as GPIO
GPIO.setwarnings( False )
GPIO.setup( 13 ,GPIO.OUT)
GPIO.setup( 5 ,GPIO.OUT)
print (
)
class Lightcontrol(MenuOption):
def __init__( self ):
self .selected_option = 0
self .options = [
'On' ,
'Off' ,
]
self .actions = [
handle_On,
handle_Off,
]
def handle_On( self ):
GPIO.output( 13 , 0 )
GPIO.output( 5 , 0 )
GPIO.output( 13 , 1 )
print ( 'ON! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off( self ):
GPIO.output( 5 , 0 )
GPIO.output( 13 , 0 )
GPIO.output( 5 , 1 )
print ( "OFF! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
def select_option( self ):
self .actions[ self .selected_option]()
def next_option( self ):
self .selected_option = ( self .selected_option + 1 ) % len ( self .options)
def prev_option( self ):
self .selected_option = ( self .selected_option - 1 ) % len ( self .options)
def up( self ):
self .prev_option()
def down( self ):
self .next_option()
def right( self ):
self .select_option()
def get_current_option( self ):
return self .options[ self .selected_option]
def get_next_option( self ):
return self .options[( self .selected_option + 1 ) % len ( self .options)]
def get_prev_option( self ):
return self .options[( self .selected_option - 1 ) % len ( self .options)]
def redraw( self , menu):
menu.write_option(
row = 0 ,
margin = 1 ,
icon = '',
text = self .get_prev_option()
)
menu.write_option(
row = 1 ,
margin = 1 ,
icon = '>' ,
text = self .get_current_option()
)
menu.write_option(
row = 2 ,
margin = 1 ,
icon = '',
text = self .get_next_option()
)
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : Lightcontrol(),
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
Posts: 2,953
Threads: 48
Joined: Sep 2016
The redraw method has this 'menu' parameter but I don't see it passed to the class definition.
Here is a simple example of instance method and why you had to remove self:
1 2 3 4 5 6 7 8 9 10 11 |
>>> class Foo:
... def say( self ):
... print ( 'hello' )
...
>>> Foo.say()
Traceback (most recent call last):
File "<stdin>" , line 1 , in <module>
TypeError: say() missing 1 required positional argument: 'self'
>>> foo_obj = Foo()
>>> foo_obj.say()
hello
|
Posts: 13
Threads: 2
Joined: May 2018
May-31-2018, 04:13 PM
(This post was last modified: May-31-2018, 04:30 PM by trippyt.)
there must be a simpler way, ignoring the icon and the def for right left etc.
im using a dothat.touch libary which scrolls through the rest of the menu just fine
any way of utilizing that for this script?
this is what im trying to reuse for my needs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
class GraphSysShutdown(MenuOption):
def __init__( self ):
self .last = self .millis()
MenuOption.__init__( self )
def redraw( self , menu):
shutdown = "sudo shutdown -h now"
now = self .millis()
if now - self .last < 1000 * 5 :
return False
a = run_cmd(shutdown)
menu.write_row( 0 , 'RPI Shutdown' )
menu.write_row( 1 , '')
menu.write_row( 2 , time.strftime( ' %a %H:%M:%S ' ))
|
think its roughly right
Posts: 2,953
Threads: 48
Joined: Sep 2016
In the examples of the dot3k the instance of the main class is passed as an argument to the Menu:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
my_invader = SpaceInvader()
menu = Menu({
'Space Invader' : my_invader,
'Clock' : Clock(),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(),
'Temp' : GraphTemp()
},
'Settings' : {
'Volume' : Volume(),
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd,
my_invader,
30 )
|
Posts: 13
Threads: 2
Joined: May 2018
May-31-2018, 04:53 PM
(This post was last modified: May-31-2018, 05:02 PM by trippyt.)
i think i understand, could you help me with the code?
youve been a great help so far
really is appreciated
just tried this, i dont get errors but cant turn the gpio to true
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
class Lightcontrol(MenuOption):
def __init__( self ):
self .last = self .millis()
MenuOption.__init__( self )
def redraw( self , menu):
menu.write_row( 1 , "Turn Lights On?" )
if nav.BUTTON - self .last < 1000 * 5 :
return False
a = handle_on( self )
def handle_On( self ):
GPIO.output( 13 , 0 )
GPIO.output( 5 , 0 )
GPIO.output( 13 , 1 )
return
print ( 'ON! Doing monkey stuff!' )
time.sleep( 2 )
print ( 'Done monkey stuff!' )
def handle_Off():
GPIO.output( 5 , 0 )
GPIO.output( 13 , 0 )
GPIO.output( 5 , 1 )
print ( "OFF! Doing donkey stuff!" )
time.sleep( 2 )
print ( "Done donkey stuff!" )
LC = Lightcontrol()
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : {
'On' : LC,
}
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_handler = Lightcontrol,
idle_timeout = 30 ,
input_handler = Text())
nav.bind_defaults(menu)
while 1 :
menu.redraw()
time.sleep( 0.05 )
|
Posts: 2,953
Threads: 48
Joined: Sep 2016
The examples of the module are not very comprehensive. I see that an instance of the main class is passed to Menu as a parameter.
I see that you are trying something that I was in about to propose before I hit accidentally Back button of my browser and lost the whole post
Pass the instance to the Menu, not the class itself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
menu = Menu(
structure = {
'Power Options' : {
'Reboot' :GraphSysReboot(),
'Shutdown' :GraphSysShutdown(),
},
'Aquarium' : {
'Lighting' : {
'Control' : {
'On' : LC,
}
}
},
'Clock' : Clock(backlight),
'Status' : {
'IP' : IPAddress(),
'CPU' : GraphCPU(backlight),
'Temp' : GraphTemp()
},
'Settings' : {
'Display' : {
'Contrast' : Contrast(lcd),
'Backlight' : Backlight(backlight)
}
}
},
lcd = lcd,
idle_handler = LC,
idle_timeout = 30 ,
input_handler = Text())
|
|