comparison Gtk/gui.py @ 4:4e976a99efb9

update ImportPriceDatabase
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Sun, 31 Oct 2010 23:12:06 +0100
parents a221c14c3c31
children 6502bfdaa84d
comparison
equal deleted inserted replaced
3:a221c14c3c31 4:4e976a99efb9
102 _menuitemImportFiebdc(self, widget) 102 _menuitemImportFiebdc(self, widget)
103 _menuitemImportPriceDatabase(self, widget) 103 _menuitemImportPriceDatabase(self, widget)
104 _menuitemOpenPriceDatabase(self, widget) 104 _menuitemOpenPriceDatabase(self, widget)
105 _menuitemOpen 105 _menuitemOpen
106 _menuitemClose(self, widget) 106 _menuitemClose(self, widget)
107 _menuitemText(self, widget)
108 _delete_event(self, widget, event) 107 _delete_event(self, widget, event)
109 _destroy(self, widget) 108 _destroy(self, widget)
110 """ 109 """
111 # TODO:* Can choose open budget in new window 110 # TODO:* Can choose open budget in new window
112 # TODO:* gtk.Action for menu and toolbar 111 # TODO:* gtk.Action for menu and toolbar
222 _last_budget = self.__budget_list[-1] 221 _last_budget = self.__budget_list[-1]
223 _page = Page(_last_budget) 222 _page = Page(_last_budget)
224 self.__notebook.append_page(_page.widget, _page.title) 223 self.__notebook.append_page(_page.widget, _page.title)
225 self.__page_list.append(_page) 224 self.__page_list.append(_page)
226 225
227 def _testBudgetList2(self):
228 """def _testBudgetList2(self)
229
230 Test if the number of budgets ("__budget_list") is greater
231 than the number of pages ("__page_list"), if it is greater
232 appendPage method is called to create a page to show the new budget
233 and save the budget in a durus file.
234 """
235 if len(self.__budget_list) > len(self.__page_list):
236 self._appendPage()
237 #-# in test mode
238 # TODO: It must be in a thread
239 _last_budget = self.__budget_list[-1]
240 _path = globals.getHomePath("DURUS-DATABASE")
241 _file_whit_path_bc3 = _last_budget.filename
242 _filename_bc3 = _file_whit_path_bc3.split("/")[-1]
243 _filename = _filename_bc3.split(".")[-2]
244 _file = _path + _filename + ".durus"
245 print utils.mapping(_("Saving file: $1"), (_file,))
246 _time = time.time()
247 _durus_file = durusdatabase.DurusFile(_file,True)
248 _durus_file.setBudget(_last_budget)
249 _durus_file.close()
250 print utils.mapping(_("Saving time: $1 seconds"),
251 (("%.2f" %(time.time()-_time) ),))
252 #-#
253 return False
254 return True
255 226
256 def _menuitemImportFiebdc(self, widget): 227 def _menuitemImportFiebdc(self, widget):
257 """def _menuitemImportFiebdc(self, widget) 228 """def _menuitemImportFiebdc(self, widget)
258 229
259 widget: the widget where the event is emitted from 230 widget: the widget where the event is emitted from
266 _budget = base.Budget() 237 _budget = base.Budget()
267 self.__budget_temp_list.append(_budget) 238 self.__budget_temp_list.append(_budget)
268 _budget_file = fiebdc.Read() 239 _budget_file = fiebdc.Read()
269 _read_method = _budget_file.readFile 240 _read_method = _budget_file.readFile
270 _filename = "file" 241 _filename = "file"
242 _filetype = "budget"
271 _exit_method = _budget_file.cancel 243 _exit_method = _budget_file.cancel
272 _file_window = importFiebdc.FileSelectionWindow(self, 244 _file_window = importFiebdc.FileSelectionWindow(self,
273 _read_method, _budget, _filename, _exit_method) 245 _read_method, _budget, _filename, _exit_method, _filetype)
274 246
275 def _menuitemImportPriceDatabase(self, widget): 247 def _menuitemImportPriceDatabase(self, widget):
276 """def _menuitemImportPriceDatabase(self, widget) 248 """def _menuitemImportPriceDatabase(self, widget)
277 249
278 widget: the widget where the event is emitted from 250 widget: the widget where the event is emitted from
280 Inits a timeout to test if a budgets is appended to "__budget_list" 252 Inits a timeout to test if a budgets is appended to "__budget_list"
281 calling _testBudgetList method if it is true. 253 calling _testBudgetList method if it is true.
282 254
283 Creates and shows a window to open a budget file. 255 Creates and shows a window to open a budget file.
284 """ 256 """
285 #TODO: change timeout, it is deprecated
286 #TODO: the .durus file must be direted saved
287 gobject.timeout_add(100, self._testBudgetList2)
288 _budget = base.Budget() 257 _budget = base.Budget()
289 self.__budget_temp_list.append(_budget) 258 self.__budget_temp_list.append(_budget)
290 _budget_file = fiebdc.Read() 259 _budget_file = fiebdc.Read()
291 _read_method = _budget_file.readFile 260 _read_method = _budget_file.readFile
292 _filename = "file" 261 _filename = "file"
262 _filetype = "basedate"
293 _exit_method = _budget_file.cancel 263 _exit_method = _budget_file.cancel
294 _file_window = importFiebdc.FileSelectionWindow(self, 264 _file_window = importFiebdc.FileSelectionWindow(self,
295 _read_method, _budget, _filename, _exit_method) 265 _read_method, _budget, _filename, _exit_method, _filetype)
296 266
297 def _menuitemOpenPriceDatabase(self, widget): 267 def _menuitemOpenPriceDatabase(self, widget):
298 """def _menuitemImportPriceDatabase(self, widget) 268 """def _menuitemOpenPriceDatabase(self, widget)
299 269
300 widget: the widget where the event is emitted from 270 widget: the widget where the event is emitted from
301 Callback to open a budget file. 271 Callback to open a budget file.
302 Inits a timeout to test if a budgets is appended to "__budget_list"
303 calling _testBudgetList method if it is true.
304 272
305 Creates and shows a window to open a budget file. 273 Creates and shows a window to open a budget file.
306 """ 274 """
307 _openDialog = OpenDurusDatabase(self._OpenDurusDatabase) 275 _openDialog = OpenDurusDatabase(self._OpenDurusDatabase)
308 _openDialog.main() 276 _openDialog.main()
380 348
381 class EmptyPage(object): 349 class EmptyPage(object):
382 """ 350 """
383 """ 351 """
384 def __init__(self, mainWindow, readFileMethod, budget, filename, 352 def __init__(self, mainWindow, readFileMethod, budget, filename,
385 cancelMethod): 353 cancelMethod, filetype):
386 """def __init__(self, mainWindow, readFileMethod, budget, filename, 354 """def __init__(self, mainWindow, readFileMethod, budget, filename,
387 cancelMethod) 355 cancelMethod, filetype)
388 356
389 """ 357 """
390 self.__mainWindow = mainWindow 358 self.__mainWindow = mainWindow
391 self.__readFileMethod = readFileMethod 359 self.__readFileMethod = readFileMethod
392 self.__budget = budget 360 self.__budget = budget
393 self.__filename = filename 361 self.__filename = filename
362 self.__filetype = filetype
394 self.__cancelMethod = cancelMethod 363 self.__cancelMethod = cancelMethod
395 self.__children = None 364 self.__children = None
396 self.__cancel = [False, False] 365 self.__cancel = [False, False]
397 self.__progress = 0.0 366 self.__progress = 0.0
398 self.__widget = gtk.VBox() 367 self.__widget = gtk.VBox()
463 Launch the thread to read the file 432 Launch the thread to read the file
464 """ 433 """
465 if self.__children is None: 434 if self.__children is None:
466 self.__children = importFiebdc.Thread(self, self.__mainWindow, 435 self.__children = importFiebdc.Thread(self, self.__mainWindow,
467 self.__readFileMethod, self.__budget, self.__filename, 436 self.__readFileMethod, self.__budget, self.__filename,
468 self.__cancelMethod) 437 self.__cancelMethod, self.__filetype)
469 self.__children.start() 438 self.__children.start()
470 439
471 def _launchTimeout(self): 440 def _launchTimeout(self):
472 """def _launchTimeout(self) 441 """def _launchTimeout(self)
473 442