1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.ConfigList import ConfigList
4 from Components.config import config
5 from Components.config import getConfigListEntry
6 from Components.Network import iNetwork
7 from Components.Label import Label
9 class NetworkSetup(Screen):
10 def __init__(self, session):
11 Screen.__init__(self, session)
13 self["actions"] = NumberActionMap(["SetupActions"],
16 "cancel": self.keyCancel,
18 "right": self.keyRight,
19 "1": self.keyNumberGlobal,
20 "2": self.keyNumberGlobal,
21 "3": self.keyNumberGlobal,
22 "4": self.keyNumberGlobal,
23 "5": self.keyNumberGlobal,
24 "6": self.keyNumberGlobal,
25 "7": self.keyNumberGlobal,
26 "8": self.keyNumberGlobal,
27 "9": self.keyNumberGlobal,
28 "0": self.keyNumberGlobal
32 self["config"] = ConfigList(self.list)
35 self["introduction"] = Label(_("Press OK to activate the settings."))
37 def createSetup(self):
40 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), config.network.dhcp)
41 self.list.append(self.dhcpEntry)
42 self.list.append(getConfigListEntry(_('IP Address'), config.network.ip))
43 if (config.network.dhcp.value == 0):
44 self.list.append(getConfigListEntry(_('Netmask'), config.network.netmask))
45 self.list.append(getConfigListEntry(_('Gateway'), config.network.gateway))
46 self.list.append(getConfigListEntry(_('Nameserver'), config.network.dns))
48 self["config"].list = self.list
49 self["config"].l.setList(self.list)
52 print self["config"].getCurrent()
53 if self["config"].getCurrent() == self.dhcpEntry:
57 self["config"].handleKey(config.key["prevElement"])
61 self["config"].handleKey(config.key["nextElement"])
64 def keyNumberGlobal(self, number):
65 print "You pressed number " + str(number)
66 if (self["config"].getCurrent()[1].parent.enabled == True):
67 self["config"].handleKey(config.key[str(number)])
70 #for x in self["config"].list:
73 iNetwork.writeNetworkConfig()
74 iNetwork.activateNetworkConfig()
78 for x in self["config"].list:
80 iNetwork.loadNetworkConfig()