gui module¶
-
class
gui.Dialog(parent, title=None)¶ Bases:
tkinter.ToplevelAbstract base class for constructing dialog boxes.
This base class handles widget creation/destruction, and implements basic button functionality (Ok & Cancel buttons). The dialog box content must be defined by subclasses by implementing a body method. Likewise, data validation is handled by the (abstract) validate method, and the actual processing/handling of input is done by the (abstract) apply method.
Parameters: - parent (tkinter.Widget) – parent of this widget
- title (str) – dialog box title
-
apply()¶ Process the data entered in the dialog box.
Returns: None
-
body(master)¶ Create dialog box body.
Should be overridden by subclasses.
Parameters: master (tkinter.Frame) – parent of this widget Returns: the widget with initial focus Return type: tkinter.Widget
Create dialog box buttons.
Returns: None
-
cancel(event=None)¶ Define the action of the “Cancel” button.
Returns: None
-
ok(event=None)¶ Define the action of the “Ok” button.
Returns: None
-
validate()¶ Validate the data entered in the dialog box.
Returns: True iff the data is valid Return type: bool
-
class
gui.FlowDialog(parent, title=None)¶ Bases:
gui.InputDialogDialog box for specifying flow parameters.
The last entry in this dialog box is the TCP specification. Since all TCP algorithms take a window size & timeout, they appear as entries by default; any additional arguments should be specified in the last entry box, as a comma-separated list of values following a valid TCP specifier. See
process.Flow.allowed_tcpfor a list of TCP specifiers, and the corresponding classes.Parameters: - parent (tkinter.Widget) – parent of this widget
- title (str) – dialog box title
-
apply()¶ Store the values entered in the entry labels.
Values are cast according to FlowDialog.types; the last value maps allowed TCP specifiers to the types they expect.
Returns: None
-
labels= ['Data', 'Initial delay', 'Window', 'Timeout', 'TCP']¶ Flow positional parameters (label names).
-
types= [<class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, {'FAST': [<class 'int'>, <class 'float'>], 'Reno': []}]¶ Input types.
-
validate()¶ Check that all values entered are valid.
All values must be >= 0, and the TCP specifier must be one of those supported by
process.Flow.Returns: True iff the data is valid Return type: bool
-
class
gui.InputDialog(parent, title=None)¶ Bases:
gui.DialogBase dialog box class for entering field data.
Parameters: - parent (tkinter.Widget) – parent of this widget
- title (str) – dialog box title
-
apply()¶ Store the values entered in the entry labels.
Returns: None
-
body(master)¶ Create a labeled entry box for each label.
Parameters: master (tkinter.Frame) – parent of this widget Returns: the entry field with initial focus, or None Return type: tkinter.Widget
-
labels= []¶ Entry field labels.
-
types= []¶ Input types.
-
class
gui.LinkDialog(parent, title=None)¶ Bases:
gui.InputDialogDialog box for specifying link parameters.
Parameters: - parent (tkinter.Widget) – parent of this widget
- title (str) – dialog box title
-
labels= ['Capacity', 'Buffer size', 'Delay']¶ Link positional parameters (label names).
-
types= [<class 'int'>, <class 'int'>, <class 'int'>]¶ Link parameter types.
-
validate()¶ Check that all values entered are >= 0.
Returns: True iff the data is valid Return type: bool
-
class
gui.NetworkInput(master, width_=600, height_=400)¶ Bases:
tkinter.FrameThis class implements a GUI to draw a network configuration.
In the GUI, pressing “h” places a host under the cursor, pressing “r” places a router under the cursor, left-clicking one component, then a different component, draws a link between the two, and right- clicking one host, then a different host, draws a flow between those hosts. After two valid endpoints have been given for a link or flow, a dialog box will appear and prompt the user for link/flow parameters. See
LinkDialogorFlowDialogfor details on what values these dialog boxes expect.Parameters: - master (tkinter.Tk) – Parent of this widget
- width (int) – Width of the GUI window
- height (int) – Height of the GUI window
-
draw_host(event)¶ Draw a host.
Parameters: event (tkinter.Event) – “h” keypress event Returns: None
-
draw_link(event)¶ Draw a link.
Parameters: event (tkinter.Event) – left mouse button click event Returns: None
-
draw_router(event)¶ Draw a router.
Parameters: event (tkinter.Event) – “r” keypress event Returns: None
-
flows¶ The flows defined on this canvas.
Returns: a list of flows defined in this network Return type: list
-
links¶ The links connected on this canvas.
Returns: an adjacency list specifying the network topology Return type: list
-
make_flow(event)¶ Make a flow from one host to another.
Parameters: event (tkinter.Event) – right mouse button click event Returns: None
-
gui.draw()¶ Draw the network configuration GUI.
See
test.Networkfor details on the output format.Returns: returns drawn network as (adjacency list, flows) Return type: (list, list)