Package client :: Module Actions :: Class Actions
[hide private]
[frames] | no frames]

Class Actions

source code

Overview

This class holds virtually all of the QAction's that the client will perform. That is not to say it holds all of the functionality, but rather the middleman to the functionality. These actions define what happens when they are activated, and then other things like buttons use a QAction to actually do something useful.

Every action in the menu bar is contained here. They exist here and not in the menu class because other things, such as the tool bar also use them. They are grouped according to package/section in a python list. This is so that other objects can unroll the entire list and get all of the actions at once.

If you are adding an action to an existing package, then its as easy as copying a previous entry. It will be propogated through the entire program from here.

Packages are a tad trickier to implement, but not that much. You can mimic the way they are laid out here, however, objects like the tool/menu bar will need to be aware the new package exists. See the individual object's class for details.

Instance Methods [hide private]
 
__init__(self, bridge)
This initialization method takes only the bridge to set up its interconnectivity.
source code
 
menuConnect(self)
This method will enable or disable actions depending on whether they should be used if you are connected.
source code
 
menuDisconnect(self)
This argument-less method will enable/disable actions depending on whether they should be used if you are disconnected.
source code
 
menuRegionSelected(self)
Assuming everything is connected and parallel, this will enable the Save Action.
source code
 
menuRegionNotSelected(self)
Assuming everything is connected and parallel, this will disable the Save Action.
source code
 
importFile(self)
This will create an instance of the RemoteFileBrowser.
source code
 
exportFile(self)
This will create an instance of the RemoteFileBrowserExport.
source code
 
saveBatch(self)
Saving a batch is a mildy complicated process because the idea is to save the commands from the entire session, not just while a single user was connected to a connection.
source code
 
loadBatch(self)
This method will use the QFileDialog widget from Qt to open up the batch file.
source code
 
helpWiki(self)
This is just a quick QMessageBox that pops up and shows the user the clickable urls for our wiki-documentation sites.
source code
 
helpAbout(self)
This is just a quick QMessageBox that pops up and shows the user a brief synopsis of Basin.
source code
 
connect(self)
All of the functionality is handled within the ConnectionDialog, so that should be your primary source of information.
source code
 
disconnect(self)
Disconnecting is quite easy, since all of the information about your connection is stored locally, we can just destroy the rc variable in the ipython session.
source code
 
preferences(self)
This method will create an intance of the Preferences dialog.
source code
Method Details [hide private]

__init__(self, bridge)
(Constructor)

source code 

Overview

This initialization method takes only the bridge to set up its interconnectivity. Other than that it is simply setting up lists of QActions and Actions.

QActions are used for non-dock related actions. This is for things like open/save which are independant.

Actions are used for dock related actions. They handle some of the hiding/showing of the widget as well as enabling/disabling the action when its in use.

It looks painful looking at all of the definitions in here, however they get propogated everywhere else, so a little pain here helps the other widgets that need these actions defined.

Parameters:
  • bridge (Bridge) - The bridge object which connects all interactive components together.

menuConnect(self)

source code 

Overview

This method will enable or disable actions depending on whether they should be used if you are connected. This, of course, gets called whenever your connectivity changes. You can, though you shouldn't, add any dock-related widgets to this method.

menuDisconnect(self)

source code 

Overview

This argument-less method will enable/disable actions depending on whether they should be used if you are disconnected. This, of course, gets called whenever your connectivity changes. You can, though you shouldn't, add any dock-related widgets to this method.

menuRegionSelected(self)

source code 

Overview

Assuming everything is connected and parallel, this will enable the Save Action. Presumably this is only called when you click on a Region in the RegionViewer.

menuRegionNotSelected(self)

source code 

Overview

Assuming everything is connected and parallel, this will disable the Save Action. Presumably this is only called when you click on a non-Region in the RegionViewer.

importFile(self)

source code 

Overview

This will create an instance of the RemoteFileBrowser. After it is done, it will retrieve the finalresult from the RemoteFileBrowser, and if one actually exists it will create an ipython statement that will go ahead and open up the file.

This is where the naming convention of reg# is generated. It does this by getting a list of all the top-level regions and it starts counting from reg0 up, and as soon as it finds a name not being used, it takes it.

One should always remember that the filename retrieved will be one on the remote host, and that the Region constructor in basin_remote handles which BASIN_IO sub-class to use to open the file, so this doesn't need to.

exportFile(self)

source code 

Overview

This will create an instance of the RemoteFileBrowserExport. After it is done, it will retrieve the finalresult from the RemoteFileBrowser, and if one actually exists it will create an ipython statement that will go ahead and save up the file.

Unlike opening files, saving them requires knowledge as to what format you want. It is here that you will need to decide what format to use. I use regular expressions to determine if the filename chosen works with our formats to figure out what to save it as.

Note that there is already a mechanism to stop users from opening this until they have selected a Region, however, this will also safeguard against users from saving non-regions.

saveBatch(self)

source code 

Overview

Saving a batch is a mildy complicated process because the idea is to save the commands from the entire session, not just while a single user was connected to a connection. This makes it so that whenever any command from the ipython shell is entered, it is likely also sent to an ipython server script that saves it to the server's drive. Thus, to save a batch, this server buffer file must be read, which is what is done here.

After the server's buffer history is read, it is stored and sent to the BatchSave class which will display a dialog which aids the user in selecting/deselecting which commands to keep and which to throw out. The BatchSave class also handles the actual file io of saving the newly created batch file.

Please note that a batch file is nothing more than a clear text file of ipython commands, except the first line is a number, the number of lines to read. Also note that like any interactive python session, when you enter multiple line constructs, an extra newline is reuqired to end the construct, and this line counts towards the top number.

loadBatch(self)

source code 

Overview

This method will use the QFileDialog widget from Qt to open up the batch file. Once a file has been chosen, it will read the first line, the total number of lines to process. Originally this was to make a progresbar, which calculates its percentage from number completed out of total things. I never got around to doing this, so if you're interested look up the class QProgressBar.

After that, it reads every line thereafter and executes it. This was written before my IpythonView's BatchCommands was written, so this could likely be written slightly more concisely with that, but this should suffice either way.

connect(self)

source code 

Overview

All of the functionality is handled within the ConnectionDialog, so that should be your primary source of information.

Roughly speaking, it brings up a dialog which manages different profiles for connection to ipython sessions. These profiles get saved to ~/.basin/client/connection.conf to be loaded later on.

disconnect(self)

source code 

Overview

Disconnecting is quite easy, since all of the information about your connection is stored locally, we can just destroy the rc variable in the ipython session. This will render you disconnected without any harm.

preferences(self)

source code 

Overview

This method will create an intance of the Preferences dialog. The dialog will allow the user to change settings regarding:

  • General/Miscellaneous
  • Connection
  • Toolbar
  • Appearance