Changeset 2144 for coopr.gui.pyomo


Ignore:
Timestamp:
Jan 11, 2010 11:57:08 PM (10 years ago)
Author:
wehart
Message:

Changing some of the API to make file selection controlled by
a FileChooser? object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.gui.pyomo/trunk/coopr/gui/pyomo/GUI.py

    r2141 r2144  
    116116        self.tabbed.add(panel, 'Tab %d' % self.tab_id)
    117117        #
     118        # Creating button for model
     119        #
     120        input1 = swing.JPanel(FlowLayout(alignment=FlowLayout.LEFT))
     121        tab.buttonInput1 = swing.JButton("Pyomo Model File", actionPerformed=self._buttonInput1)
     122        input1.add(tab.buttonInput1)
     123        bag.addRow(input1)
     124        tab.text1 = swing.JTextField("",60)
     125        bag.addRow(tab.text1)
     126        #
     127        # Create button for data
     128        #
     129        input2 = swing.JPanel(FlowLayout(alignment=FlowLayout.LEFT))
     130        tab.buttonInput2 = swing.JButton("Pyomo Data File", actionPerformed=self._buttonInput2)
     131        input2.add(tab.buttonInput2)
     132        bag.addRow(input2)
     133        tab.text2 = swing.JTextField("",60)
     134        bag.addRow(tab.text2)
     135        #
    118136        # Creating a text area for the command that will be executed
    119137        #
    120         tab.input = swing.JTextArea("", 6, 80)
    121         bag.addRow(tab.input)
    122         tab.input.append("COMMAND %d" % self.tab_id)
     138        ##tab.input = swing.JTextArea("", 6, 80)
     139        ##bag.addRow(tab.input)
     140        ##tab.input.append("COMMAND %d" % self.tab_id)
    123141        #
    124142        # create panel for buttons that manage command execution/output
     
    174192
    175193    def _fileLoad(self, event=None):
     194        file,absfile = self._select_file()
     195        if not absfile is None:
     196            INPUT = open(absfile)
     197            (a,b) = pickle.load(INPUT)
     198            INPUT.close()
     199
     200    def _fileSave(self, event=None):
     201        file,absfile = self._select_file()
     202        if not absfile is None:
     203            object = ("AA",  "BB")
     204            OUTPUT = open(absfile, 'w')
     205            pickle.dump(object, OUTPUT)
     206            OUTPUT.close()
     207
     208    def _fileSaveToFile(self, event=None):
     209        pass
     210
     211    def _fileQuit(self, event=None):
     212        import sys
     213        sys.exit(0)
     214
     215    def _editCopy(self, event=None):
     216        pass
     217
     218    def _editPaste(self, event=None):
     219        pass
     220
     221    def _editSelectAll(self, event=None):
     222        pass
     223
     224    def _helpConsole(self, event=None):
     225        pass
     226
     227    def _helpCoinWiki(self, event=None):
     228        pass
     229
     230    def _helpCooprWiki(self, event=None):
     231        pass
     232
     233    def _helpAbout(self, event=None):
     234        pass
     235
     236    def _packagesVersions(self, event=None):
     237        pass
     238
     239    def _packagesInstall(self, event=None):
     240        pass
     241
     242    def _packagesUpdate(self, event=None):
     243        pass
     244
     245    def _buttonExecute(self, event=None):
     246        pass
     247
     248    def _buttonClearOutput(self, event=None):
     249        pass
     250
     251    def _select_file(self):
    176252        self.chooser.rescanCurrentDirectory()
    177253        returnVal = self.chooser.showOpenDialog(self.frame)
    178254        if returnVal == APPROVE_OPTION:
    179             file = open(os.path.join(self.chooser.currentDirectory.path,
    180                      self.chooser.selectedFile.name))
    181             (setup, each, style, color,
    182              colorname, self.numelements) = pickle.load(file)
    183             file.close()
    184             self.chart.color = java.awt.Color(color)
    185             self.colorname.selectedIndex = colorname
    186             self.chart.style = style
    187             self.execentry.text = setup
    188             self.numpoints.selectedIndex = self.sizes.index(self.numelements)
    189             self.evalentry.text = each
    190             self.update(None)
    191 
    192     def _fileSave(self, event=None):
    193         self.chooser.rescanCurrentDirectory()
    194         returnVal = self.chooser.showSaveDialog(self.frame)
    195         if returnVal == APPROVE_OPTION:
    196             object = (self.execentry.text,  self.evalentry.text,
    197                       self.chart.style,
    198                       self.chart.color.RGB,
    199                       self.colorname.selectedIndex,
    200                       self.numelements)
    201             file = open(os.path.join(self.chooser.currentDirectory.path,
    202                         self.chooser.selectedFile.name), 'w')
    203             pickle.dump(object, file)
    204             file.close()
    205 
    206     def _fileSaveToFile(self, event=None):
    207         pass
    208 
    209     def _fileQuit(self, event=None):
    210         import sys
    211         sys.exit(0)
    212 
    213     def _editCopy(self, event=None):
    214         pass
    215 
    216     def _editPaste(self, event=None):
    217         pass
    218 
    219     def _editSelectAll(self, event=None):
    220         pass
    221 
    222     def _helpConsole(self, event=None):
    223         pass
    224 
    225     def _helpCoinWiki(self, event=None):
    226         pass
    227 
    228     def _helpCooprWiki(self, event=None):
    229         pass
    230 
    231     def _helpAbout(self, event=None):
    232         pass
    233 
    234     def _packagesVersions(self, event=None):
    235         pass
    236 
    237     def _packagesInstall(self, event=None):
    238         pass
    239 
    240     def _packagesUpdate(self, event=None):
    241         pass
    242 
    243     def _buttonExecute(self, event=None):
    244         pass
    245 
    246     def _buttonClearOutput(self, event=None):
    247         pass
     255            return (self.chooser.selectedFile.name, os.path.join(self.chooser.currentDirectory.path, self.chooser.selectedFile.name))
     256        return (None,None)
     257       
     258    def _buttonInput1(self, event=None):
     259        file, absfile = self._select_file()
     260        self.tab_info[1].text1.text = absfile
     261
     262    def _buttonInput2(self, event=None):
     263        file, absfile = self._select_file()
     264        self.tab_info[1].text2.text = absfile
     265
    248266
    249267
Note: See TracChangeset for help on using the changeset viewer.