diff options
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/ActionHandler.py | 18 | ||||
-rw-r--r-- | grc/gui/Actions.py | 14 | ||||
-rw-r--r-- | grc/gui/Block.py | 32 | ||||
-rw-r--r-- | grc/gui/BlockTreeWindow.py | 16 | ||||
-rw-r--r-- | grc/gui/Connection.py | 14 | ||||
-rw-r--r-- | grc/gui/Dialogs.py | 20 | ||||
-rw-r--r-- | grc/gui/DrawingArea.py | 4 | ||||
-rw-r--r-- | grc/gui/Element.py | 84 | ||||
-rw-r--r-- | grc/gui/FileDialogs.py | 22 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 84 | ||||
-rw-r--r-- | grc/gui/MainWindow.py | 62 | ||||
-rw-r--r-- | grc/gui/Messages.py | 8 | ||||
-rw-r--r-- | grc/gui/NotebookPage.py | 58 | ||||
-rw-r--r-- | grc/gui/Param.py | 8 | ||||
-rw-r--r-- | grc/gui/Port.py | 42 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 24 | ||||
-rw-r--r-- | grc/gui/StateCache.py | 20 | ||||
-rw-r--r-- | grc/gui/Utils.py | 38 |
18 files changed, 412 insertions, 156 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 476c82b4f6..bb687529f2 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -47,8 +47,10 @@ class ActionHandler: ActionHandler constructor. Create the main window, setup the message handler, import the preferences, and connect all of the action handlers. Finally, enter the gtk main loop and block. - @param file_paths a list of flow graph file passed from command line - @param platform platform module + + Args: + file_paths: a list of flow graph file passed from command line + platform: platform module """ self.clipboard = None for action in Actions.get_all_actions(): action.connect('activate', self._handle_action) @@ -76,7 +78,9 @@ class ActionHandler: * some keys are ignored by the accelerators like the direction keys, * some keys are not registered to any accelerators but are still used. When not in focus, gtk and the accelerators handle the the key press. - @return false to let gtk handle the key action + + Returns: + false to let gtk handle the key action """ if not self.get_focus_flag(): return False return Actions.handle_key_press(event) @@ -86,7 +90,9 @@ class ActionHandler: Handle the delete event from the main window. Generated by pressing X to close, alt+f4, or right click+close. This method in turns calls the state handler to quit. - @return true + + Returns: + true """ Actions.APPLICATION_QUIT() return True @@ -350,7 +356,9 @@ class ExecFlowGraphThread(Thread): def __init__ (self, action_handler): """ ExecFlowGraphThread constructor. - @param action_handler an instance of an ActionHandler + + Args: + action_handler: an instance of an ActionHandler """ Thread.__init__(self) self.update_exec_stop = action_handler.update_exec_stop diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index 4d196477eb..2a8676e9b4 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -33,8 +33,12 @@ def handle_key_press(event): """ Call the action associated with the key press event. Both the key value and the mask must have a match. - @param event a gtk key press event - @return true if handled + + Args: + event: a gtk key press event + + Returns: + true if handled """ _used_mods_mask = reduce(lambda x, y: x | y, [mod_mask for keyval, mod_mask in _actions_keypress_dict], NO_MODS_MASK) #extract the key value and the consumed modifiers @@ -63,8 +67,10 @@ class Action(gtk.Action): def __init__(self, keypresses=(), name=None, label=None, tooltip=None, stock_id=None): """ Create a new Action instance. - @param key_presses a tuple of (keyval1, mod_mask1, keyval2, mod_mask2, ...) - @param the regular gtk.Action parameters (defaults to None) + + Args: + key_presses: a tuple of (keyval1, mod_mask1, keyval2, mod_mask2, ...) + the: regular gtk.Action parameters (defaults to None) """ if name is None: name = label gtk.Action.__init__(self, diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 27143e0704..11e66bff85 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -69,7 +69,9 @@ class Block(Element): def get_coordinate(self): """ Get the coordinate from the position param. - @return the coordinate tuple (x, y) or (0, 0) if failure + + Returns: + the coordinate tuple (x, y) or (0, 0) if failure """ try: #should evaluate to tuple coor = eval(self.get_param('_coordinate').get_value()) @@ -91,14 +93,18 @@ class Block(Element): def set_coordinate(self, coor): """ Set the coordinate into the position param. - @param coor the coordinate tuple (x, y) + + Args: + coor: the coordinate tuple (x, y) """ self.get_param('_coordinate').set_value(str(coor)) def get_rotation(self): """ Get the rotation from the position param. - @return the rotation in degrees or 0 if failure + + Returns: + the rotation in degrees or 0 if failure """ try: #should evaluate to dict rotation = eval(self.get_param('_rotation').get_value()) @@ -110,7 +116,9 @@ class Block(Element): def set_rotation(self, rot): """ Set the rotation into the position param. - @param rot the rotation in degrees + + Args: + rot: the rotation in degrees """ self.get_param('_rotation').set_value(str(rot)) @@ -171,8 +179,10 @@ class Block(Element): def draw(self, gc, window): """ Draw the signal block with label and inputs/outputs. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ x, y = self.get_coordinate() #draw main block @@ -191,9 +201,13 @@ class Block(Element): def what_is_selected(self, coor, coor_m=None): """ Get the element that is selected. - @param coor the (x,y) tuple - @param coor_m the (x_m, y_m) tuple - @return this block, a port, or None + + Args: + coor: the (x,y) tuple + coor_m: the (x_m, y_m) tuple + + Returns: + this block, a port, or None """ for port in self.get_ports(): port_selected = port.what_is_selected(coor, coor_m) diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py index 0175c8becf..e5a4027eb8 100644 --- a/grc/gui/BlockTreeWindow.py +++ b/grc/gui/BlockTreeWindow.py @@ -46,8 +46,10 @@ class BlockTreeWindow(gtk.VBox): Create a tree view of the possible blocks in the platform. The tree view nodes will be category names, the leaves will be block names. A mouse double click or button press action will trigger the add block event. - @param platform the particular platform will all block prototypes - @param get_flow_graph get the selected flow graph + + Args: + platform: the particular platform will all block prototypes + get_flow_graph: get the selected flow graph """ gtk.VBox.__init__(self) self.platform = platform @@ -97,8 +99,10 @@ class BlockTreeWindow(gtk.VBox): """ Add a block with category to this selection window. Add only the category when block is None. - @param category the category list or path string - @param block the block object or None + + Args: + category: the category list or path string + block: the block object or None """ if isinstance(category, str): category = category.split('/') category = tuple(filter(lambda x: x, category)) #tuple is hashable @@ -124,7 +128,9 @@ class BlockTreeWindow(gtk.VBox): def _get_selected_block_key(self): """ Get the currently selected block key. - @return the key of the selected block or a empty string + + Returns: + the key of the selected block or a empty string """ selection = self.treeview.get_selection() treestore, iter = selection.get_selected() diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py index fabf34ee72..5d24fefded 100644 --- a/grc/gui/Connection.py +++ b/grc/gui/Connection.py @@ -38,7 +38,9 @@ class Connection(Element): """ Get the 0,0 coordinate. Coordinates are irrelevant in connection. - @return 0, 0 + + Returns: + 0, 0 """ return (0, 0) @@ -46,7 +48,9 @@ class Connection(Element): """ Get the 0 degree rotation. Rotations are irrelevant in connection. - @return 0 + + Returns: + 0 """ return 0 @@ -120,8 +124,10 @@ class Connection(Element): def draw(self, gc, window): """ Draw the connection. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ sink = self.get_sink() source = self.get_source() diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 473c796aff..df424750b9 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -28,7 +28,9 @@ class TextDisplay(gtk.TextView): def __init__(self, text=''): """ TextDisplay constructor. - @param text the text to display (string) + + Args: + text: the text to display (string) """ text_buffer = gtk.TextBuffer() text_buffer.set_text(text) @@ -42,12 +44,18 @@ class TextDisplay(gtk.TextView): def MessageDialogHelper(type, buttons, title=None, markup=None): """ Create a modal message dialog and run it. - @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR - @param buttons the predefined set of buttons to use: + + Args: + type: the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR + buttons: the predefined set of buttons to use: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL - @param tittle the title of the window (string) - @param markup the message text with pango markup - @return the gtk response from run() + + Args: + tittle: the title of the window (string) + markup: the message text with pango markup + + Returns: + the gtk response from run() """ message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons) if title: message_dialog.set_title(title) diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py index 790df7c3fa..da16eb7cf2 100644 --- a/grc/gui/DrawingArea.py +++ b/grc/gui/DrawingArea.py @@ -32,7 +32,9 @@ class DrawingArea(gtk.DrawingArea): """ DrawingArea contructor. Connect event handlers. - @param main_window the main_window containing all flow graphs + + Args: + main_window: the main_window containing all flow graphs """ self.ctrl_mask = False self._flow_graph = flow_graph diff --git a/grc/gui/Element.py b/grc/gui/Element.py index e020c5caa9..eac59d88eb 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -40,8 +40,12 @@ class Element(object): """ Is this element horizontal? If rotation is None, use this element's rotation. - @param rotation the optional rotation - @return true if rotation is horizontal + + Args: + rotation: the optional rotation + + Returns: + true if rotation is horizontal """ rotation = rotation or self.get_rotation() return rotation in (0, 180) @@ -50,8 +54,12 @@ class Element(object): """ Is this element vertical? If rotation is None, use this element's rotation. - @param rotation the optional rotation - @return true if rotation is vertical + + Args: + rotation: the optional rotation + + Returns: + true if rotation is vertical """ rotation = rotation or self.get_rotation() return rotation in (90, 270) @@ -74,10 +82,12 @@ class Element(object): def draw(self, gc, window, border_color, bg_color): """ Draw in the given window. - @param gc the graphics context - @param window the gtk window to draw on - @param border_color the color for lines and rectangle borders - @param bg_color the color for the inside of the rectangle + + Args: + gc: the graphics context + window: the gtk window to draw on + border_color: the color for lines and rectangle borders + bg_color: the color for the inside of the rectangle """ X,Y = self.get_coordinate() for (rX,rY),(W,H) in self._areas_list: @@ -94,7 +104,9 @@ class Element(object): def rotate(self, rotation): """ Rotate all of the areas by 90 degrees. - @param rotation multiple of 90 degrees + + Args: + rotation: multiple of 90 degrees """ self.set_rotation((self.get_rotation() + rotation)%360) @@ -106,41 +118,53 @@ class Element(object): def set_coordinate(self, coor): """ Set the reference coordinate. - @param coor the coordinate tuple (x,y) + + Args: + coor: the coordinate tuple (x,y) """ self.coor = coor def get_parent(self): """ Get the parent of this element. - @return the parent + + Returns: + the parent """ return self.parent def set_highlighted(self, highlighted): """ Set the highlight status. - @param highlighted true to enable highlighting + + Args: + highlighted: true to enable highlighting """ self.highlighted = highlighted def is_highlighted(self): """ Get the highlight status. - @return true if highlighted + + Returns: + true if highlighted """ return self.highlighted def get_coordinate(self): """Get the coordinate. - @return the coordinate tuple (x,y) + + Returns: + the coordinate tuple (x,y) """ return self.coor def move(self, delta_coor): """ Move the element by adding the delta_coor to the current coordinate. - @param delta_coor (delta_x,delta_y) tuple + + Args: + delta_coor: (delta_x,delta_y) tuple """ deltaX, deltaY = delta_coor X, Y = self.get_coordinate() @@ -154,8 +178,10 @@ class Element(object): A positive width is to the right of the coordinate. A positive height is above the coordinate. The area is associated with a rotation. - @param rel_coor (x,y) offset from this element's coordinate - @param area (width,height) tuple + + Args: + rel_coor: (x,y) offset from this element's coordinate + area: (width,height) tuple """ self._areas_list.append((rel_coor, area)) @@ -165,8 +191,10 @@ class Element(object): A line is defined by 2 relative coordinates. Lines must be horizontal or vertical. The line is associated with a rotation. - @param rel_coor1 relative (x1,y1) tuple - @param rel_coor2 relative (x2,y2) tuple + + Args: + rel_coor1: relative (x1,y1) tuple + rel_coor2: relative (x2,y2) tuple """ self._lines_list.append((rel_coor1, rel_coor2)) @@ -178,9 +206,13 @@ class Element(object): Both coordinates specified: Is this element within the rectangular region defined by both coordinates? ie: do any area corners or line endpoints fall within the region? - @param coor the selection coordinate, tuple x, y - @param coor_m an additional selection coordinate. - @return self if one of the areas/lines encompasses coor, else None. + + Args: + coor: the selection coordinate, tuple x, y + coor_m: an additional selection coordinate. + + Returns: + self if one of the areas/lines encompasses coor, else None. """ #function to test if p is between a and b (inclusive) in_between = lambda p, a, b: p >= min(a, b) and p <= max(a, b) @@ -215,14 +247,18 @@ class Element(object): def get_rotation(self): """ Get the rotation in degrees. - @return the rotation + + Returns: + the rotation """ return self.rotation def set_rotation(self, rotation): """ Set the rotation in degrees. - @param rotation the rotation""" + + Args: + rotation: the rotation""" if rotation not in POSSIBLE_ROTATIONS: raise Exception('"%s" is not one of the possible rotations: (%s)'%(rotation, POSSIBLE_ROTATIONS)) self.rotation = rotation diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py index 3b210c33f3..20172a7418 100644 --- a/grc/gui/FileDialogs.py +++ b/grc/gui/FileDialogs.py @@ -79,8 +79,10 @@ class FileDialogHelper(gtk.FileChooserDialog): FileDialogHelper contructor. Create a save or open dialog with cancel and ok buttons. Use standard settings: no multiple selection, local files only, and the * filter. - @param action gtk.FILE_CHOOSER_ACTION_OPEN or gtk.FILE_CHOOSER_ACTION_SAVE - @param title the title of the dialog (string) + + Args: + action: gtk.FILE_CHOOSER_ACTION_OPEN or gtk.FILE_CHOOSER_ACTION_SAVE + title: the title of the dialog (string) """ ok_stock = {gtk.FILE_CHOOSER_ACTION_OPEN : 'gtk-open', gtk.FILE_CHOOSER_ACTION_SAVE : 'gtk-save'}[action] gtk.FileChooserDialog.__init__(self, title, None, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK)) @@ -94,7 +96,9 @@ class FileDialog(FileDialogHelper): def __init__(self, current_file_path=''): """ FileDialog constructor. - @param current_file_path the current directory or path to the open flow graph + + Args: + current_file_path: the current directory or path to the open flow graph """ if not current_file_path: current_file_path = path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + Preferences.file_extension()) if self.type == OPEN_FLOW_GRAPH: @@ -115,7 +119,9 @@ class FileDialog(FileDialogHelper): def add_and_set_filter(self, filter): """ Add the gtk file filter to the list of filters and set it as the default file filter. - @param filter a gtk file filter. + + Args: + filter: a gtk file filter. """ self.add_filter(filter) self.set_filter(filter) @@ -126,7 +132,9 @@ class FileDialog(FileDialogHelper): If this is a save dialog and the file name is missing the extension, append the file extension. If the file name with the extension already exists, show a overwrite dialog. If this is an open dialog, return a list of filenames. - @return the complete file path + + Returns: + the complete file path """ if gtk.FileChooserDialog.run(self) != gtk.RESPONSE_OK: return None #response was cancel ############################################# @@ -164,7 +172,9 @@ class FileDialog(FileDialogHelper): def run(self): """ Get the filename and destroy the dialog. - @return the filename or None if a close/cancel occured. + + Returns: + the filename or None if a close/cancel occured. """ filename = self.get_rectified_filename() self.destroy() diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 9f3326adaf..418366dbb8 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -79,8 +79,10 @@ class FlowGraph(Element): def add_new_block(self, key, coor=None): """ Add a block of the given key to this flow graph. - @param key the block key - @param coor an optional coordinate or None for random + + Args: + key: the block key + coor: an optional coordinate or None for random """ id = self._get_unique_id(key) #calculate the position coordinate @@ -103,7 +105,9 @@ class FlowGraph(Element): def copy_to_clipboard(self): """ Copy the selected blocks and connections into the clipboard. - @return the clipboard + + Returns: + the clipboard """ #get selected blocks blocks = self.get_selected_blocks() @@ -129,7 +133,9 @@ class FlowGraph(Element): def paste_from_clipboard(self, clipboard): """ Paste the blocks and connections from the clipboard. - @param clipboard the nested data of blocks, connections + + Args: + clipboard: the nested data of blocks, connections """ selected = set() (x_min, y_min), blocks_n, connections_n = clipboard @@ -177,24 +183,36 @@ class FlowGraph(Element): def type_controller_modify_selected(self, direction): """ Change the registered type controller for the selected signal blocks. - @param direction +1 or -1 - @return true for change + + Args: + direction: +1 or -1 + + Returns: + true for change """ return any([sb.type_controller_modify(direction) for sb in self.get_selected_blocks()]) def port_controller_modify_selected(self, direction): """ Change port controller for the selected signal blocks. - @param direction +1 or -1 - @return true for changed + + Args: + direction: +1 or -1 + + Returns: + true for changed """ return any([sb.port_controller_modify(direction) for sb in self.get_selected_blocks()]) def enable_selected(self, enable): """ Enable/disable the selected blocks. - @param enable true to enable - @return true if changed + + Args: + enable: true to enable + + Returns: + true if changed """ changed = False for selected_block in self.get_selected_blocks(): @@ -206,7 +224,9 @@ class FlowGraph(Element): def move_selected(self, delta_coordinate): """ Move the element and by the change in coordinates. - @param delta_coordinate the change in coordinates + + Args: + delta_coordinate: the change in coordinates """ for selected_block in self.get_selected_blocks(): selected_block.move(delta_coordinate) @@ -215,8 +235,12 @@ class FlowGraph(Element): def rotate_selected(self, rotation): """ Rotate the selected blocks by multiples of 90 degrees. - @param rotation the rotation in degrees - @return true if changed, otherwise false. + + Args: + rotation: the rotation in degrees + + Returns: + true if changed, otherwise false. """ if not self.get_selected_blocks(): return False #initialize min and max coordinates @@ -241,7 +265,9 @@ class FlowGraph(Element): def remove_selected(self): """ Remove selected elements - @return true if changed. + + Returns: + true if changed. """ changed = False for selected_element in self.get_selected_elements(): @@ -325,9 +351,13 @@ class FlowGraph(Element): Iterate though the elements backwards since top elements are at the end of the list. If an element is selected, place it at the end of the list so that is is drawn last, and hence on top. Update the selected port information. - @param coor the coordinate of the mouse click - @param coor_m the coordinate for multi select - @return the selected blocks and connections or an empty list + + Args: + coor: the coordinate of the mouse click + coor_m: the coordinate for multi select + + Returns: + the selected blocks and connections or an empty list """ selected_port = None selected = set() @@ -353,7 +383,9 @@ class FlowGraph(Element): def get_selected_connections(self): """ Get a group of selected connections. - @return sub set of connections in this flow graph + + Returns: + sub set of connections in this flow graph """ selected = set() for selected_element in self.get_selected_elements(): @@ -363,7 +395,9 @@ class FlowGraph(Element): def get_selected_blocks(self): """ Get a group of selected blocks. - @return sub set of blocks in this flow graph + + Returns: + sub set of blocks in this flow graph """ selected = set() for selected_element in self.get_selected_elements(): @@ -373,21 +407,27 @@ class FlowGraph(Element): def get_selected_block(self): """ Get the selected block when a block or port is selected. - @return a block or None + + Returns: + a block or None """ return self.get_selected_blocks() and self.get_selected_blocks()[0] or None def get_selected_elements(self): """ Get the group of selected elements. - @return sub set of elements in this flow graph + + Returns: + sub set of elements in this flow graph """ return self._selected_elements def get_selected_element(self): """ Get the selected element. - @return a block, port, or connection or None + + Returns: + a block, port, or connection or None """ return self.get_selected_elements() and self.get_selected_elements()[0] or None diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 2f761df1f8..4c2a3ae2d2 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -118,7 +118,9 @@ class MainWindow(gtk.Window): Handle the delete event from the main window. Generated by pressing X to close, alt+f4, or right click+close. This method in turns calls the state handler to quit. - @return true + + Returns: + true """ Actions.APPLICATION_QUIT() return True @@ -128,9 +130,11 @@ class MainWindow(gtk.Window): Handle a page change. When the user clicks on a new tab, reload the flow graph to update the vars window and call handle states (select nothing) to update the buttons. - @param notebook the notebook - @param page new page - @param page_num new page number + + Args: + notebook: the notebook + page: new page + page_num: new page number """ self.current_page = self.notebook.get_nth_page(page_num) Messages.send_page_switch(self.current_page.get_file_path()) @@ -143,7 +147,9 @@ class MainWindow(gtk.Window): def add_report_line(self, line): """ Place line at the end of the text buffer, then scroll its window all the way down. - @param line the new text + + Args: + line: the new text """ self.text_display.insert(line) vadj = self.reports_scrolled_window.get_vadjustment() @@ -158,8 +164,10 @@ class MainWindow(gtk.Window): """ Create a new notebook page. Set the tab to be selected. - @param file_path optional file to load into the flow graph - @param show true if the page should be shown after loading + + Args: + file_path: optional file to load into the flow graph + show: true if the page should be shown after loading """ #if the file is already open, show the open page and return if file_path and file_path in self._get_files(): #already open @@ -189,7 +197,9 @@ class MainWindow(gtk.Window): def close_pages(self): """ Close all the pages in this notebook. - @return true if all closed + + Returns: + true if all closed """ open_files = filter(lambda file: file, self._get_files()) #filter blank files open_file = self.get_page().get_file_path() @@ -212,7 +222,9 @@ class MainWindow(gtk.Window): Close the current page. If the notebook becomes empty, and ensure is true, call new page upon exit to ensure that at least one page exists. - @param ensure boolean + + Args: + ensure: boolean """ if not self.page_to_be_closed: self.page_to_be_closed = self.get_page() #show the page if it has an executing flow graph or is unsaved @@ -240,7 +252,9 @@ class MainWindow(gtk.Window): Set the title of the main window. Set the titles on the page tabs. Show/hide the reports window. - @param title the window title + + Args: + title: the window title """ gtk.Window.set_title(self, Utils.parse_template(MAIN_WINDOW_TITLE_TMPL, basename=os.path.basename(self.get_page().get_file_path()), @@ -266,21 +280,27 @@ class MainWindow(gtk.Window): def get_page(self): """ Get the selected page. - @return the selected page + + Returns: + the selected page """ return self.current_page def get_flow_graph(self): """ Get the selected flow graph. - @return the selected flow graph + + Returns: + the selected flow graph """ return self.get_page().get_flow_graph() def get_focus_flag(self): """ Get the focus flag from the current page. - @return the focus flag + + Returns: + the focus flag """ return self.get_page().get_drawing_area().get_focus_flag() @@ -291,7 +311,9 @@ class MainWindow(gtk.Window): def _set_page(self, page): """ Set the current page. - @param page the page widget + + Args: + page: the page widget """ self.current_page = page self.notebook.set_current_page(self.notebook.page_num(self.current_page)) @@ -299,7 +321,9 @@ class MainWindow(gtk.Window): def _save_changes(self): """ Save changes to flow graph? - @return true if yes + + Returns: + true if yes """ return MessageDialogHelper( gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 'Unsaved Changes!', @@ -309,13 +333,17 @@ class MainWindow(gtk.Window): def _get_files(self): """ Get the file names for all the pages, in order. - @return list of file paths + + Returns: + list of file paths """ return map(lambda page: page.get_file_path(), self._get_pages()) def _get_pages(self): """ Get a list of all pages in the notebook. - @return list of pages + + Returns: + list of pages """ return [self.notebook.get_nth_page(page_num) for page_num in range(self.notebook.get_n_pages())] diff --git a/grc/gui/Messages.py b/grc/gui/Messages.py index e98e897aa6..a9f0e36b85 100644 --- a/grc/gui/Messages.py +++ b/grc/gui/Messages.py @@ -26,14 +26,18 @@ MESSENGERS_LIST = list() def register_messenger(messenger): """ Append the given messenger to the list of messengers. - @param messenger a method thats takes a string + + Args: + messenger: a method thats takes a string """ MESSENGERS_LIST.append(messenger) def send(message): """ Give the message to each of the messengers. - @param message a message string + + Args: + message: a message string """ for messenger in MESSENGERS_LIST: messenger(message) diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index 86b6f1513c..095c045a66 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -36,8 +36,10 @@ class NotebookPage(gtk.HBox): def __init__(self, main_window, flow_graph, file_path=''): """ Page constructor. - @param main_window main window - @param file_path path to a flow graph file + + Args: + main_window: main window + file_path: path to a flow graph file """ self._flow_graph = flow_graph self.set_proc(None) @@ -89,7 +91,9 @@ class NotebookPage(gtk.HBox): def get_generator(self): """ Get the generator object for this flow graph. - @return generator + + Returns: + generator """ return self.get_flow_graph().get_parent().get_generator()( self.get_flow_graph(), @@ -100,7 +104,9 @@ class NotebookPage(gtk.HBox): """ The button was clicked. Make the current page selected, then close. - @param the button + + Args: + the: button """ self.main_window.page_to_be_closed = self Actions.FLOW_GRAPH_CLOSE() @@ -108,35 +114,45 @@ class NotebookPage(gtk.HBox): def set_markup(self, markup): """ Set the markup in this label. - @param markup the new markup text + + Args: + markup: the new markup text """ self.label.set_markup(markup) def get_tab(self): """ Get the gtk widget for this page's tab. - @return gtk widget + + Returns: + gtk widget """ return self.tab def get_proc(self): """ Get the subprocess for the flow graph. - @return the subprocess object + + Returns: + the subprocess object """ return self.process def set_proc(self, process): """ Set the subprocess object. - @param process the new subprocess + + Args: + process: the new subprocess """ self.process = process def get_flow_graph(self): """ Get the flow graph. - @return the flow graph + + Returns: + the flow graph """ return self._flow_graph @@ -144,7 +160,9 @@ class NotebookPage(gtk.HBox): """ Get the read-only state of the file. Always false for empty path. - @return true for read-only + + Returns: + true for read-only """ if not self.get_file_path(): return False return os.path.exists(self.get_file_path()) and \ @@ -153,14 +171,18 @@ class NotebookPage(gtk.HBox): def get_file_path(self): """ Get the file path for the flow graph. - @return the file path or '' + + Returns: + the file path or '' """ return self.file_path def set_file_path(self, file_path=''): """ Set the file path, '' for no file path. - @param file_path file path string + + Args: + file_path: file path string """ if file_path: self.file_path = os.path.abspath(file_path) else: self.file_path = '' @@ -168,20 +190,26 @@ class NotebookPage(gtk.HBox): def get_saved(self): """ Get the saved status for the flow graph. - @return true if saved + + Returns: + true if saved """ return self.saved def set_saved(self, saved=True): """ Set the saved status. - @param saved boolean status + + Args: + saved: boolean status """ self.saved = saved def get_state_cache(self): """ Get the state cache for the flow graph. - @return the state cache + + Returns: + the state cache """ return self.state_cache diff --git a/grc/gui/Param.py b/grc/gui/Param.py index cb6c663e30..da76b6b82c 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -175,7 +175,9 @@ class Param(Element): An enum requires and combo parameter. A non-enum with options gets a combined entry/combo parameter. All others get a standard entry parameter. - @return gtk input class + + Returns: + gtk input class """ if self.is_enum(): return EnumParam(self, *args, **kwargs) if self.get_options(): return EnumEntryParam(self, *args, **kwargs) @@ -184,6 +186,8 @@ class Param(Element): def get_markup(self): """ Get the markup for this param. - @return a pango markup string + + Returns: + a pango markup string """ return Utils.parse_template(PARAM_MARKUP_TMPL, param=self) diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 2896d04c18..7b4c27dd5f 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -106,8 +106,10 @@ class Port(Element): def draw(self, gc, window): """ Draw the socket with a label. - @param gc the graphics context - @param window the gtk window to draw on + + Args: + gc: the graphics context + window: the gtk window to draw on """ Element.draw( self, gc, window, bg_color=self._bg_color, @@ -123,7 +125,9 @@ class Port(Element): def get_connector_coordinate(self): """ Get the coordinate where connections may attach to. - @return the connector coordinate (x, y) tuple + + Returns: + the connector coordinate (x, y) tuple """ x,y = self._connector_coordinate X,Y = self.get_coordinate() @@ -134,7 +138,9 @@ class Port(Element): Get the direction that the socket points: 0,90,180,270. This is the rotation degree if the socket is an output or the rotation degree + 180 if the socket is an input. - @return the direction in degrees + + Returns: + the direction in degrees """ if self.is_source(): return self.get_rotation() elif self.is_sink(): return (self.get_rotation() + 180)%360 @@ -143,48 +149,62 @@ class Port(Element): """ Get the length of the connector. The connector length increases as the port index changes. - @return the length in pixels + + Returns: + the length in pixels """ return self._connector_length def get_rotation(self): """ Get the parent's rotation rather than self. - @return the parent's rotation + + Returns: + the parent's rotation """ return self.get_parent().get_rotation() def move(self, delta_coor): """ Move the parent rather than self. - @param delta_corr the (delta_x, delta_y) tuple + + Args: + delta_corr: the (delta_x, delta_y) tuple """ self.get_parent().move(delta_coor) def rotate(self, direction): """ Rotate the parent rather than self. - @param direction degrees to rotate + + Args: + direction: degrees to rotate """ self.get_parent().rotate(direction) def get_coordinate(self): """ Get the parent's coordinate rather than self. - @return the parents coordinate + + Returns: + the parents coordinate """ return self.get_parent().get_coordinate() def set_highlighted(self, highlight): """ Set the parent highlight rather than self. - @param highlight true to enable highlighting + + Args: + highlight: true to enable highlighting """ self.get_parent().set_highlighted(highlight) def is_highlighted(self): """ Get the parent's is highlight rather than self. - @return the parent's highlighting status + + Returns: + the parent's highlighting status """ return self.get_parent().is_highlighted() diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index cc84fd0888..5264857fab 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -28,8 +28,12 @@ def get_title_label(title): """ Get a title label for the params window. The title will be bold, underlined, and left justified. - @param title the text of the title - @return a gtk object + + Args: + title: the text of the title + + Returns: + a gtk object """ label = gtk.Label() label.set_markup('\n<b><span underline="low">%s</span>:</b>\n'%title) @@ -45,7 +49,9 @@ class PropsDialog(gtk.Dialog): def __init__(self, block): """ Properties dialog contructor. - @param block a block instance + + Args: + block: a block instance """ self._hash = 0 LABEL_SPACING = 7 @@ -94,7 +100,9 @@ class PropsDialog(gtk.Dialog): To the props dialog, the hide setting of 'none' and 'part' are identical. Therfore, the props dialog only cares if the hide setting is/not 'all'. Make a hash that uniquely represents the params' state. - @return true if changed + + Returns: + true if changed """ old_hash = self._hash #create a tuple of things from each param that affects the params box @@ -153,7 +161,9 @@ class PropsDialog(gtk.Dialog): """ Handle key presses from the keyboard. Call the ok response when enter is pressed. - @return false to forward the keypress + + Returns: + false to forward the keypress """ if event.keyval == gtk.keysyms.Return: self.response(gtk.RESPONSE_ACCEPT) @@ -163,7 +173,9 @@ class PropsDialog(gtk.Dialog): def run(self): """ Run the dialog and get its response. - @return true if the response was accept + + Returns: + true if the response was accept """ response = gtk.Dialog.run(self) self.destroy() diff --git a/grc/gui/StateCache.py b/grc/gui/StateCache.py index 3f6b792240..50d85bf960 100644 --- a/grc/gui/StateCache.py +++ b/grc/gui/StateCache.py @@ -30,7 +30,9 @@ class StateCache(object): def __init__(self, initial_state): """ StateCache constructor. - @param initial_state the intial state (nested data) + + Args: + initial_state: the intial state (nested data) """ self.states = [None] * STATE_CACHE_SIZE #fill states self.current_state_index = 0 @@ -43,7 +45,9 @@ class StateCache(object): """ Save a new state. Place the new state at the next index and add one to the number of previous states. - @param state the new state + + Args: + state: the new state """ self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE self.states[self.current_state_index] = state @@ -55,7 +59,9 @@ class StateCache(object): def get_current_state(self): """ Get the state at the current index. - @return the current state (nested data) + + Returns: + the current state (nested data) """ self.update_actions() return self.states[self.current_state_index] @@ -63,7 +69,9 @@ class StateCache(object): def get_prev_state(self): """ Get the previous state and decrement the current index. - @return the previous state or None + + Returns: + the previous state or None """ if self.num_prev_states > 0: self.current_state_index = (self.current_state_index + STATE_CACHE_SIZE -1)%STATE_CACHE_SIZE @@ -75,7 +83,9 @@ class StateCache(object): def get_next_state(self): """ Get the nest state and increment the current index. - @return the next state or None + + Returns: + the next state or None """ if self.num_next_states > 0: self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index bb19ed3d96..b68c19c4e1 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -29,10 +29,12 @@ def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTE Load the destination pixmap with a rotated version of the source pixmap. The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap. The pixbuf is a client-side drawable, where a pixmap is a server-side drawable. - @param gc the graphics context - @param src_pixmap the source pixmap - @param dst_pixmap the destination pixmap - @param angle the angle to rotate by + + Args: + gc: the graphics context + src_pixmap: the source pixmap + dst_pixmap: the destination pixmap + angle: the angle to rotate by """ width, height = src_pixmap.get_size() pixbuf = gtk.gdk.Pixbuf( @@ -47,9 +49,13 @@ def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTE def get_rotated_coordinate(coor, rotation): """ Rotate the coordinate by the given rotation. - @param coor the coordinate x, y tuple - @param rotation the angle in degrees - @return the rotated coordinates + + Args: + coor: the coordinate x, y tuple + rotation: the angle in degrees + + Returns: + the rotated coordinates """ #handles negative angles rotation = (rotation + 360)%360 @@ -68,9 +74,13 @@ def get_rotated_coordinate(coor, rotation): def get_angle_from_coordinates((x1,y1), (x2,y2)): """ Given two points, calculate the vector direction from point1 to point2, directions are multiples of 90 degrees. - @param (x1,y1) the coordinate of point 1 - @param (x2,y2) the coordinate of point 2 - @return the direction in degrees + + Args: + (x1,y1): the coordinate of point 1 + (x2,y2): the coordinate of point 2 + + Returns: + the direction in degrees """ if y1 == y2:#0 or 180 if x2 > x1: return 0 @@ -83,8 +93,12 @@ def parse_template(tmpl_str, **kwargs): """ Parse the template string with the given args. Pass in the xml encode method for pango escape chars. - @param tmpl_str the template as a string - @return a string of the parsed template + + Args: + tmpl_str: the template as a string + + Returns: + a string of the parsed template """ kwargs['encode'] = gobject.markup_escape_text return str(Template(tmpl_str, kwargs)) |