[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 3/9] Updated definenetwork.py to use the new screen grid helper.



From: "Darryl L. Pierce" <dpierce redhat com>

---
 src/virtManagerTui/definenet.py |   80 +++++++++++++++++---------------------
 1 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/src/virtManagerTui/definenet.py b/src/virtManagerTui/definenet.py
index 890874c..55951e4 100644
--- a/src/virtManagerTui/definenet.py
+++ b/src/virtManagerTui/definenet.py
@@ -16,7 +16,11 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
-from snack import Checkbox, Entry, Grid, Label
+from snack import Checkbox
+from snack import Entry
+from snack import Label
+from snack import RadioBar
+
 from IPy import IP
 import logging
 import re
@@ -160,41 +164,31 @@ class DefineNetworkConfigScreen(VmmTuiConfigScreen):
     def get_network_name_page(self, screen):
         ignore = screen
         self.__name = Entry(50, self.__config.get_name())
-        grid = Grid(2, 1)
-        grid.setField(Label("Network Name:"), 0, 0)
-        grid.setField(self.__name, 1, 0)
+        fields = []
+        fields.append(("Network name", self.__name))
+
         return [Label("Please choose a name for your virtual network"),
-                grid]
+                self.create_grid_from_fields(fields)]
 
     def get_ipv4_address_page(self, screen):
         ignore = screen
         self.__ipv4_address = Entry(18, self.__config.get_ipv4_address())
-        grid = Grid(2, 1)
-        grid.setField(Label("Network:"), 0, 0, anchorRight = 1)
-        grid.setField(self.__ipv4_address, 1, 0, anchorLeft = 1)
-        return [Label("You will need to choose an IPv4 address space for the virtual network:"),
-                grid,
-                Label("HINT: The network should be chosen from"),
-                Label("one of the IPv4 private address ranges;"),
-                Label("e.g., 10.0.0.0/8, 172.168.0.0/12, 192.168.0.0/16")]
+        fields = []
+        fields.append(("Network", self.__ipv4_address))
+        return [Label("You will need to choose an IPv4 address space for the virtual network"),
+                self.create_grid_from_fields(fields)]
 
     def get_network_details_page(self, screen):
         ignore = screen
-        grid = Grid(2, 6)
-        grid.setField(Label("Network:"), 0, 0, anchorRight = 1)
-        grid.setField(Label(self.__config.get_ipv4_address()), 1, 0, anchorLeft = 1)
-        grid.setField(Label("Netmask:"), 0, 1, anchorRight = 1)
-        grid.setField(Label(self.__config.get_ipv4_netmask()), 1, 1, anchorLeft = 1)
-        grid.setField(Label("Broadcast:"), 0, 2, anchorRight = 1)
-        grid.setField(Label(self.__config.get_ipv4_broadcast()), 1, 2, anchorLeft = 1)
-        grid.setField(Label("Gateway:"), 0, 3, anchorRight = 1)
-        grid.setField(Label(self.__config.get_ipv4_gateway()), 1, 3, anchorLeft = 1)
-        grid.setField(Label("Size:"), 0, 4, anchorRight = 1)
-        grid.setField(Label("%d addresses" % self.__config.get_ipv4_max_addresses()), 1, 4, anchorLeft = 1)
-        grid.setField(Label("Type:"), 0, 5, anchorRight = 1)
-        grid.setField(Label(self.__config.get_ipv4_network_type()), 1, 5, anchorLeft = 1)
-        return [Label("Network Details"),
-                grid]
+        fields = []
+        fields.append(("Network details", None))
+        fields.append(("Network", self.__config.get_ipv4_address()))
+        fields.append(("Netmask", self.__config.get_ipv4_netmask()))
+        fields.append(("Broadcast", self.__config.get_ipv4_broadcast()))
+        fields.append(("Gateway", self.__config.get_ipv4_gateway()))
+        fields.append(("Size", "%i" % self.__config.get_ipv4_max_addresses()))
+        fields.append(("Type", self.__config.get_ipv4_network_type()))
+        return [self.create_grid_from_fields(fields)]
 
     def get_public_network_alert_page(self, screen):
         ignore = screen
@@ -208,13 +202,12 @@ class DefineNetworkConfigScreen(VmmTuiConfigScreen):
         ignore = screen
         self.__start_address = Entry(15, self.__config.get_ipv4_start_address())
         self.__end_address   = Entry(15, self.__config.get_ipv4_end_address())
-        grid = Grid(2, 2)
-        grid.setField(Label("Start:"), 0, 0, anchorRight = 1)
-        grid.setField(self.__start_address, 1, 0, anchorLeft = 1)
-        grid.setField(Label("End:"), 0, 1, anchorRight = 1)
-        grid.setField(self.__end_address, 1, 1, anchorLeft = 1)
+        fields = []
+        fields.append(("Select the DHCP range", None))
+        fields.append(("Start", self.__start_address))
+        fields.append(("End", self.__end_address))
         return [Label("Selecting The DHCP Range"),
-                grid,
+                self.create_grid_from_fields(fields),
                 Label("TIP: Unless you wish to reserve some addresses to allow static network"),
                 Label("configuration in virtual machines, these paraemters can be left with"),
                 Label("their default values.")]
@@ -223,12 +216,12 @@ class DefineNetworkConfigScreen(VmmTuiConfigScreen):
         ignore = screen
         self.__isolated_network = Checkbox("Isolated virtual network",
                                            self.__config.is_isolated_network())
-        grid = Grid(1, 3)
-        grid.setField(Label("Please indicate whether this virtual network should be"), 0, 0, anchorLeft = 1)
-        grid.setField(Label("connected to the physical network."), 0, 1, anchorLeft = 1)
-        grid.setField(self.__isolated_network, 0, 2)
-        return [Label("Connecting To Physical Network"),
-                grid]
+        fields = []
+        fields.append((self.__isolated_network, None))
+
+        return [Label("Please indicate whether this virtual network should be"),
+                Label("connected to the physical network."),
+                self.create_grid_from_fields(fields)]
 
     def get_select_physical_network_page(self, screen):
         ignore = screen
@@ -237,11 +230,10 @@ class DefineNetworkConfigScreen(VmmTuiConfigScreen):
         for device in self.get_hal().list_network_devices():
             devices.append(["NAT to physical device %s" % device, device, self.__config.get_physical_device() == device])
         self.__physical_devices = RadioBar(screen, (devices))
-        grid = Grid(1, 2)
-        grid.setField(Label("Forward to physical network:"), 0, 0)
-        grid.setField(self.__physical_devices, 0, 1)
+        fields = []
+        fields.append(("Forward to physical network", self.__physical_devices))
         return [Label("Connecting To Physical Network"),
-                grid]
+                self.create_grid_from_fields(fields)]
 
     def get_summary_page(self, screen):
         ignore = screen
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]