This repository was archived by the owner on Feb 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpscreen.py
More file actions
98 lines (70 loc) · 2.61 KB
/
helpscreen.py
File metadata and controls
98 lines (70 loc) · 2.61 KB
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
from kivy.uix.tabbedpanel import TabbedPanelHeader
from kivy.uix.tabbedpanel import TabbedPanelItem
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.graphics import Rectangle, Color
from kivy.uix.screenmanager import Screen
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.lang import Builder
import configparser
import json
from Navigation import NavigationBar
from Navigation import NavigationButton
Builder.load_file('helpscreen.kv')
class HelpPanelsHeader(TabbedPanelHeader):
pass
class HelpPanels(TabbedPanel):
pass
def createInfoTab(stringDict, tabName):
tab = TabbedPanelItem()
tab.name = tabName
tab.text = stringDict[tabName]["Title"]
titleText = Label(text=stringDict[tabName]["Title"])
bodyText = Label(text=stringDict[tabName]["Body"])
tab.add_widget(titleText)
tab.add_widget(bodyText)
return tab
def createHelpPanels(language):
infoPanels = HelpPanels()
infoPanels.name = "infoPanel"
helpStrings = json.load( open("LangStrings.json") )
tabsToAdd = []
tabsToAdd.append( createInfoTab(helpStrings[language], "helpWhat") )
tabsToAdd.append( createInfoTab(helpStrings[language], "helpHow") )
tabsToAdd.append( createInfoTab(helpStrings[language], "helpWho") )
# Add in each new tab to the main panels
for tab in tabsToAdd:
infoPanels.add_widget(tab)
return infoPanels
# Main class for the help menu to build on top of
class HelpScreen(Screen):
def __init__(self, config, **kwargs):
self.config = config
super().__init__(**kwargs)
layout = StackLayout()
layout.name = "Layout"
infoPanels = createHelpPanels(config["DISPLAY"]["language"])
navBar = NavigationBar()
returnButton = NavigationButton(name="Return", text="Return to home")
returnButton.bind(on_press=self.returnHome)
navBar.add_widget(returnButton)
layout.add_widget(infoPanels)
layout.add_widget(navBar)
self.add_widget(layout)
def on_pre_enter(self):
self.updateScreenLanguage(self.config["DISPLAY"]["language"])
def updateScreenLanguage(self, language):
helpStrings = json.load( open("LangStrings.json") )
stringsOfLanguage = helpStrings[language]
# Magic numbers get the layout of the screen, then the tabbed panel object,
# then the tabs within it.
for tab in (self.children[0].children[1].tab_list):
print(tab.name)
tab.text = stringsOfLanguage[tab.name]["Title"]
tab.content.text = stringsOfLanguage[tab.name]["Body"]
def returnHome(self, instance):
self.manager.transition.direction = 'up'
self.manager.current = 'Menu'