20 _moduleLogger = logging.getLogger("gonvert_glade")
22 gettext.bindtextdomain('gonvert', '/usr/share/locale')
23 gettext.textdomain('gonvert')
27 def change_menu_label(widgets, labelname, newtext):
28 item_label = widgets.get_widget(labelname).get_children()[0]
29 item_label.set_text(newtext)
32 class Gonvert(object):
35 os.path.join(os.path.dirname(__file__), "gonvert.glade"),
36 os.path.join(os.path.dirname(__file__), "../data/gonvert.glade"),
37 os.path.join(os.path.dirname(__file__), "../lib/gonvert.glade"),
38 '/usr/lib/gonvert/gonvert.glade',
42 self._unitDataInCategory = None
43 self._calcsuppress = False
44 self._unit_sort_direction = False
45 self._value_sort_direction = False
46 self._units_sort_direction = False
48 self._find_result = [] # empty find result list
49 self._find_count = 0 # default to find result number zero
51 self._selected_category = '' # preset to no selected category
52 self._selected_units = {} # empty dictionary for later use
54 #check to see if glade file is in current directory (user must be
55 # running from download untar directory)
56 for gladePath in self._glade_files:
57 if os.path.isfile(gladePath):
58 homepath = os.path.dirname(gladePath)
59 pixmapspath = "/".join((homepath, "pixmaps"))
60 widgets = gtk.glade.XML(gladePath)
65 self._mainWindow = widgets.get_widget('mainWindow')
67 change_menu_label(widgets, 'fileMenuItem', _('File'))
68 change_menu_label(widgets, 'exitMenuItem', _('Exit'))
69 change_menu_label(widgets, 'toolsMenuItem', _('Tools'))
70 change_menu_label(widgets, 'clearSelectionMenuItem', _('Clear selections'))
71 change_menu_label(widgets, 'writeUnitsMenuItem', _('Write Units'))
72 change_menu_label(widgets, 'helpMenuItem', _('Help'))
73 change_menu_label(widgets, 'aboutMenuItem', _('About'))
74 change_menu_label(widgets, 'findButton', _('Find'))
76 self._shortlistcheck = widgets.get_widget('shortlistcheck')
77 self._toggleShortList = widgets.get_widget('toggleShortList')
79 self._categoryView = widgets.get_widget('categoryView')
81 self._unitsView = widgets.get_widget('unitsView')
82 self._unitsView_selection = self._unitsView.get_selection()
84 self._unitName = widgets.get_widget('unitName')
85 self._unitValue = widgets.get_widget('unitValue')
86 self._previousUnitName = widgets.get_widget('previousUnitName')
87 self._previousUnitValue = widgets.get_widget('previousUnitValue')
88 messagebox = widgets.get_widget('msgbox')
89 messageboxtext = widgets.get_widget('msgboxtext')
91 self._unitSymbol = widgets.get_widget('unitSymbol')
92 self._previousUnitSymbol = widgets.get_widget('previousUnitSymbol')
94 self._unitDescription = widgets.get_widget('unitDescription')
96 self._findEntry = widgets.get_widget('findEntry')
97 self._findLabel = widgets.get_widget('findLabel')
98 findButton = widgets.get_widget('findButton')
99 ToolTips = gtk.Tooltips()
100 ToolTips.set_tip(findButton, _(u'Find unit (F6)'))
102 #insert a self._categoryColumnumn into the units list even though the heading will not be seen
103 renderer = gtk.CellRendererText()
104 self._unitNameColumn = gtk.TreeViewColumn(_('Unit Name'), renderer)
105 self._unitNameColumn.set_property('resizable', 1)
106 self._unitNameColumn.add_attribute(renderer, 'text', 0)
107 self._unitNameColumn.set_clickable(True)
108 self._unitNameColumn.connect("clicked", self._on_click_unit_column)
109 self._unitsView.append_column(self._unitNameColumn)
111 self._unitValueColumn = gtk.TreeViewColumn(_('Value'), renderer)
112 self._unitValueColumn.set_property('resizable', 1)
113 self._unitValueColumn.add_attribute(renderer, 'text', 1)
114 self._unitValueColumn.set_clickable(True)
115 self._unitValueColumn.connect("clicked", self._on_click_unit_column)
116 self._unitsView.append_column(self._unitValueColumn)
118 self._unitSymbolColumn = gtk.TreeViewColumn(_('Units'), renderer)
119 self._unitSymbolColumn.set_property('resizable', 1)
120 self._unitSymbolColumn.add_attribute(renderer, 'text', 2)
121 self._unitSymbolColumn.set_clickable(True)
122 self._unitSymbolColumn.connect("clicked", self._on_click_unit_column)
123 self._unitsView.append_column(self._unitSymbolColumn)
125 #Insert a column into the category list even though the heading will not be seen
126 renderer = gtk.CellRendererText()
127 self._categoryColumn = gtk.TreeViewColumn('Title', renderer)
128 self._categoryColumn.set_property('resizable', 1)
129 self._categoryColumn.add_attribute(renderer, 'text', 0)
130 self._categoryView.append_column(self._categoryColumn)
132 self._categoryModel = gtk.ListStore(gobject.TYPE_STRING)
133 self._categoryView.set_model(self._categoryModel)
134 #colourize each row differently for easier reading
135 self._categoryView.set_property('rules_hint', 1)
137 #Populate the catagories list
138 for key in unit_data.UNIT_CATEGORIES:
139 iter = self._categoryModel.append()
140 self._categoryModel.set(iter, 0, key)
142 #--------- connections to GUI ----------------
144 "on_exit_menu_activate": self._on_user_exit,
145 "on_main_window_destroy": self._on_user_exit,
146 "on_categoryView_select_row": self._on_click_category,
147 "on_unitsView__on_click_unit_column": self._on_click_unit_column,
148 "on_unitValue_changed": self._on_unit_value_changed,
149 "on_previousUnitValue_changed": self._on_previous_unit_value_changed,
150 "on_writeUnitsMenuItem_activate": self._on_user_write_units,
151 "on_findButton_clicked": self._on_user_find_units,
152 "on_findEntry_activated": self._on_user_find_units,
153 "on_findEntry_changed": self._on_findEntry_changed,
154 "on_aboutMenuItem_activate": self._on_about_clicked,
155 "on_messagebox_ok_clicked": self.messagebox_ok_clicked,
156 "on_clearSelectionMenuItem_activate": self._on_user_clear_selections,
157 "on_unitsView_cursor_changed": self._on_click_unit,
158 "on_unitsView_button_released": self._on_button_released,
159 "on_shortlistcheck_toggled": self._on_shortlist_changed,
160 "on_toggleShortList_activate": self._on_edit_shortlist,
162 widgets.signal_autoconnect(dic)
164 self._mainWindow.set_title('gonvert- %s - Unit Conversion Utility' % constants.__version__)
165 iconPath = pixmapspath + '/gonvert.png'
166 if os.path.exists(iconPath):
167 self._mainWindow.set_icon(gtk.gdk.pixbuf_new_from_file(iconPath))
169 _moduleLogger.warn("Error: Could not find gonvert icon: %s" % iconPath)
171 self._load_settings()
173 def _load_settings(self):
174 #Restore window size from previously saved settings if it exists and is valid.
175 windowDatPath = "/".join((constants._data_path_, "window.dat"))
176 if os.path.exists(windowDatPath):
177 #Retrieving previous window settings from ~/.gonvert/window.dat
178 saved_window = pickle.load(open(windowDatPath, "r"))
179 #If the 'size' has been stored, then extract size from saved_window.
180 if 'size' in saved_window:
181 a, b = saved_window['size']
182 self._mainWindow.resize(a, b)
184 #Maximize if no previous size was found
185 #self._mainWindow.maximize()
188 #Maximize if no previous window.dat file was found
189 #self._mainWindow.maximize()
192 #Restore selections from previously saved settings if it exists and is valid.
193 historical_catergory_found = False
194 selectionsDatPath = "/".join((constants._data_path_, "selections.dat"))
195 if os.path.exists(selectionsDatPath):
196 #Retrieving previous selections from ~/.gonvert/selections.dat
197 selections = pickle.load(open(selectionsDatPath, 'r'))
198 #Restoring previous selections.
199 #If the 'selected_unts' has been stored, then extract self._selected_units from selections.
200 if 'selected_units' in selections:
201 self._selected_units = selections['selected_units']
202 #Make sure that the 'self._selected_category' has been stored.
203 if 'selected_category' in selections:
204 #Match an available category to the previously selected category.
205 for counter in range(len(unit_data.UNIT_CATEGORIES)):
206 if selections['selected_category'] == unit_data.UNIT_CATEGORIES[counter]:
207 # Restore the previously selected category.
208 self._categoryView.set_cursor(counter, self._categoryColumn, False)
209 self._categoryView.grab_focus()
210 historical_catergory_found = True
212 if not historical_catergory_found:
213 print "Couldn't find saved category, using default."
214 #If historical records were not kept then default to
215 # put the focus on the first category
216 self._categoryView.set_cursor(0, self._categoryColumn, False)
217 self._categoryView.grab_focus()
221 def _save_settings(self):
223 This routine saves the selections to a file, and
224 should therefore only be called when exiting the program.
226 Update selections dictionary which consists of the following keys:
227 'self._selected_category': full name of selected category
228 'self._selected_units': self._selected_units dictionary which contains:
229 [categoryname: #1 displayed unit, #2 displayed unit]
231 #Determine the contents of the selected category row
232 selected, iter = self._categoryView.get_selection().get_selected()
233 self._selected_category = self._categoryModel.get_value(iter, 0)
236 'selected_category': self._selected_category,
237 'selected_units': self._selected_units
239 selectionsDatPath = "/".join((constants._data_path_, "selections.dat"))
240 pickle.dump(selections, open(selectionsDatPath, 'w'))
242 #Get last size of app and save it
244 'size': self._mainWindow.get_size()
246 windowDatPath = "/".join((constants._data_path_, "window.dat"))
247 pickle.dump(window_settings, open(windowDatPath, 'w'))
249 def _on_shortlist_changed(self, a):
250 raise NotImplementedError("%s" % self._shortlistcheck.get_active())
252 def _on_edit_shortlist(self, a):
253 raise NotImplementedError("%s" % self._toggleShortList.get_active())
255 def _on_user_clear_selections(self, a):
256 selectionsDatPath = "/".join((constants._data_path_, "selections.dat"))
257 os.remove(selectionsDatPath)
258 self._selected_units = {}
260 def _on_user_exit(self, a):
262 self._save_settings()
266 def _on_findEntry_changed(self, a):
268 Clear out find results since the user wants to look for something new
270 # switch to "new find" state
271 self._find_result = []
274 # Clear our user message
275 self._findLabel.set_text('')
277 def _first_find(self):
278 assert len(self._find_result) == 0
279 assert self._find_count == 0
280 findString = string.lower(string.strip(self._findEntry.get_text()))
284 # Gather info on all the matching units from all categories
285 for catIndex, category in enumerate(unit_data.UNIT_CATEGORIES):
286 units = unit_data.get_units(category)
287 for unitIndex, unit in enumerate(units):
288 loweredUnit = unit.lower()
289 if loweredUnit in findString or findString in loweredUnit:
290 self._find_result.append((category, unit, catIndex, unitIndex))
292 if not self._find_result:
295 self._select_found_unit()
297 def _find_wrap_around(self):
298 assert 0 < len(self._find_result)
299 assert self._find_count + 1 == len(self._find_result)
302 self._select_found_unit()
304 def _find_next(self):
305 assert 0 < len(self._find_result)
306 assert self._find_count + 1 < len(self._find_result)
307 self._find_count += 1
308 self._select_found_unit()
310 def _select_found_unit(self):
311 assert 0 < len(self._find_result)
312 #check if next find is in a new category (prevent category changes when unnecessary
313 if self._selected_category != self._find_result[self._find_count][0]:
314 self._categoryView.set_cursor(self._find_result[self._find_count][2], self._categoryColumn, False)
315 self._unitsView.set_cursor(self._find_result[self._find_count][3], self._unitNameColumn, True)
317 def _on_user_find_units(self, a):
319 check if 'new find' or 'last find' or 'next-find'
321 new-find = run the find algorithm which also selects the first found unit
322 = self._find_count = 0 and self._find_result = []
324 last-find = restart from top again
325 = self._find_count = len(self._find_result)
327 next-find = continue to next found location
328 = self._find_count = 0 and len(self._find_result)>0
330 if len(self._find_result) == 0:
333 if self._find_count == len(self._find_result)-1:
334 self._find_wrap_around()
338 if not self._find_result:
339 self._findLabel.set_text('Text not found')
341 resultsLeft = len(self._find_result) - self._find_count - 1
342 self._findLabel.set_text(
343 '%s result(s) left' % (resultsLeft, )
346 def _on_click_unit_column(self, col):
348 Sort the contents of the col when the user clicks on the title.
350 #Determine which column requires sorting
351 if col is self._unitNameColumn:
352 selectedUnitColumn = 0
353 self._unitNameColumn.set_sort_indicator(True)
354 self._unitValueColumn.set_sort_indicator(False)
355 self._unitSymbolColumn.set_sort_indicator(False)
356 self._unitNameColumn.set_sort_order(not self._unit_sort_direction)
357 elif col is self._unitValueColumn:
358 selectedUnitColumn = 1
359 self._unitNameColumn.set_sort_indicator(False)
360 self._unitValueColumn.set_sort_indicator(True)
361 self._unitSymbolColumn.set_sort_indicator(False)
362 self._unitValueColumn.set_sort_order(not self._value_sort_direction)
363 elif col is self._unitSymbolColumn:
364 selectedUnitColumn = 2
365 self._unitNameColumn.set_sort_indicator(False)
366 self._unitValueColumn.set_sort_indicator(False)
367 self._unitSymbolColumn.set_sort_indicator(True)
368 self._unitSymbolColumn.set_sort_order(not self._units_sort_direction)
370 assert False, "Unknown column: %s" % (col.get_title(), )
372 #declare a spot to hold the sorted list
375 #point to the first row
376 iter = self._unitModel.get_iter_first()
380 #grab all text from columns for sorting
382 #get the text from each column
383 unit_text = self._unitModel.get_value(iter, 0)
384 units_text = self._unitModel.get_value(iter, 2)
386 #do not bother sorting if the value column is empty
387 if self._unitModel.get_value(iter, 1) == '' and selectedUnitColumn == 1:
390 #special sorting exceptions for ascii values (instead of float values)
391 if self._selected_category == "Computer Numbers":
392 value_text = self._unitModel.get_value(iter, 1)
394 if self._unitModel.get_value(iter, 1) == None or self._unitModel.get_value(iter, 1) == '':
397 value_text = float(self._unitModel.get_value(iter, 1))
399 if selectedUnitColumn == 0:
400 sorted_list.append((unit_text, value_text, units_text))
401 elif selectedUnitColumn == 1:
402 sorted_list.append((value_text, unit_text, units_text))
404 sorted_list.append((units_text, value_text, unit_text))
406 #point to the next row in the self._unitModel
407 iter = self._unitModel.iter_next(iter)
410 #check if no calculations have been made yet (don't bother sorting)
414 if selectedUnitColumn == 0:
415 if not self._unit_sort_direction:
416 sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(x), string.lower(y)))
417 self._unit_sort_direction = True
419 sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(y), string.lower(x)))
420 self._unit_sort_direction = False
421 elif selectedUnitColumn == 1:
423 if not self._value_sort_direction:
424 self._value_sort_direction = True
426 sorted_list.reverse()
427 self._value_sort_direction = False
429 if not self._units_sort_direction:
430 sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(x), string.lower(y)))
431 self._units_sort_direction = True
433 sorted_list.sort(lambda (x, xx, xxx), (y, yy, yyy): cmp(string.lower(y), string.lower(x)))
434 self._units_sort_direction = False
436 #Clear out the previous list of units
437 self._unitModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
438 self._unitsView.set_model(self._unitModel)
440 #colourize each row differently for easier reading
441 self._unitsView.set_property('rules_hint', 1)
443 #Clear out the description
444 text_model = gtk.TextBuffer(None)
445 self._unitDescription.set_buffer(text_model)
447 if selectedUnitColumn == 0:
448 for unit, value, units in sorted_list:
449 iter = self._unitModel.append()
450 self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
451 elif selectedUnitColumn == 1:
452 for value, unit, units in sorted_list:
453 iter = self._unitModel.append()
454 self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
456 for units, value, unit in sorted_list:
457 iter = self._unitModel.append()
458 self._unitModel.set(iter, 0, unit, 1, str(value), 2, units)
461 def _on_click_category(self, row):
462 #Clear out the previous list of units
463 self._unitModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
464 self._unitsView.set_model(self._unitModel)
466 #Colourize each row alternately for easier reading
467 self._unitsView.set_property('rules_hint', 1)
469 #Clear out the description
470 text_model = gtk.TextBuffer(None)
471 self._unitDescription.set_buffer(text_model)
473 #Determine the contents of the selected category row
474 selected, iter = row.get_selection().get_selected()
476 self._selected_category = self._categoryModel.get_value(iter, 0)
478 self._unit_sort_direction = False
479 self._value_sort_direction = False
480 self._units_sort_direction = False
481 self._unitNameColumn.set_sort_indicator(False)
482 self._unitValueColumn.set_sort_indicator(False)
483 self._unitSymbolColumn.set_sort_indicator(False)
485 self._unitDataInCategory = unit_data.UNIT_DESCRIPTIONS[selected.get_value(iter, 0)]
486 keys = self._unitDataInCategory.keys()
488 del keys[0] # do not display .base_unit description key
490 #Fill up the units descriptions and clear the value cells
492 iter = self._unitModel.append()
493 self._unitModel.set(iter, 0, key, 1, '', 2, self._unitDataInCategory[key][1])
495 self._unitName.set_text('')
496 self._unitValue.set_text('')
497 self._previousUnitName.set_text('')
498 self._previousUnitValue.set_text('')
499 self._unitSymbol.set_text('')
500 self._previousUnitSymbol.set_text('')
504 def restore_units(self):
505 # Restore the previous historical settings of previously selected units in this newly selected category
506 #Since category has just been clicked, the list will be sorted already.
507 if self._selected_category in self._selected_units:
508 if self._selected_units[self._selected_category][0]:
510 #self._selected_units[self._selected_category] = [selected_unit, self._selected_units[self._selected_category][0]]
512 units = unit_data.UNIT_DESCRIPTIONS[self._selected_category].keys()
514 del units[0] # do not display .base_unit description key
516 #Restore oldest selection first.
517 if self._selected_units[self._selected_category][1]:
520 if unit == self._selected_units[self._selected_category][1]:
521 self._unitsView.set_cursor(unit_no, self._unitNameColumn, True)
524 #Restore newest selection second.
527 if unit == self._selected_units[self._selected_category][0]:
528 self._unitsView.set_cursor(unit_no, self._unitNameColumn, True)
531 # select the text so user can start typing right away
532 self._unitValue.grab_focus()
533 self._unitValue.select_region(0, -1)
535 def _on_button_released(self, row, a):
536 self._on_click_unit(row)
538 def _on_click_unit(self, row):
539 self._calcsuppress = True #suppress calculations
541 #Determine the contents of the selected row.
542 selected, iter = self._unitsView.get_selection().get_selected()
544 selected_unit = selected.get_value(iter, 0)
546 unit_spec = self._unitDataInCategory[selected_unit]
548 #Clear out the description
549 text_model = gtk.TextBuffer(None)
550 self._unitDescription.set_buffer(text_model)
552 enditer = text_model.get_end_iter()
553 text_model.insert(enditer, unit_spec[2])
555 if self._unitName.get_text() != selected_unit:
556 self._previousUnitName.set_text(self._unitName.get_text())
557 self._previousUnitValue.set_text(self._unitValue.get_text())
558 if self._unitSymbol.get() == None:
559 self._previousUnitSymbol.set_text('')
561 self._previousUnitSymbol.set_text(self._unitSymbol.get())
562 self._unitName.set_text(selected_unit)
564 self._unitValue.set_text(selected.get_value(iter, 1))
566 self._unitSymbol.set_text(unit_spec[1]) # put units into label text
567 if self._unitValue.get_text() == '':
568 if self._selected_category == "Computer Numbers":
569 self._unitValue.set_text("0")
571 self._unitValue.set_text("0.0")
573 #For historical purposes, record this unit as the most recent one in this category.
574 # Also, if a previous unit exists, then shift that previous unit to oldest unit.
575 if self._selected_category in self._selected_units:
576 if self._selected_units[self._selected_category][0]:
577 self._selected_units[self._selected_category] = [selected_unit, self._selected_units[self._selected_category][0]]
579 self._selected_units[self._selected_category] = [selected_unit, '']
581 # select the text so user can start typing right away
582 self._unitValue.grab_focus()
583 self._unitValue.select_region(0, -1)
585 self._calcsuppress = False #enable calculations
587 def messagebox_ok_clicked(self, a):
590 def _on_user_write_units(self, a):
591 ''"Write the list of categories and units to stdout for documentation purposes.''"
592 messagebox_model = gtk.TextBuffer(None)
593 messageboxtext.set_buffer(messagebox_model)
594 messagebox_model.insert_at_cursor(_(u'The units are being written to stdout. You can capture this printout by starting gonvert from the command line as follows: \n$ gonvert > file.txt'), -1)
596 while gtk.events_pending():
597 gtk.mainiteration(False)
601 print 'gonvert-%s%s' % (
602 constants.__version__,
603 _(u' - Unit Conversion Utility - Convertible units listing: ')
605 for category_key in unit_data.UNIT_CATEGORIES:
606 total_categories = total_categories + 1
607 print category_key, ": "
608 self._unitDataInCategory = unit_data.UNIT_DESCRIPTIONS[category_key]
609 unit_keys = self._unitDataInCategory.keys()
611 del unit_keys[0] # do not display .base_unit description key
612 for unit_key in unit_keys:
613 total_units = total_units + 1
615 print total_categories, ' categories'
616 print total_units, ' units'
618 def _on_unit_value_changed(self, a):
619 if self._calcsuppress:
620 #self._calcsuppress = False
622 # determine if value to be calculated is empty
623 if self._selected_category == "Computer Numbers":
624 if self._unitValue.get_text() == '':
627 value = self._unitValue.get_text()
629 if self._unitValue.get_text() == '':
632 value = float(self._unitValue.get_text())
634 if self._unitName.get_text() != '':
635 func, arg = self._unitDataInCategory[self._unitName.get_text()][0] #retrieve the conversion function and value from the selected unit
636 base = apply(func.to_base, (value, arg, )) #determine the base unit value
638 keys = self._unitDataInCategory.keys()
643 #point to the first row
644 iter = self._unitModel.get_iter_first()
647 #get the formula from the name at the row
648 func, arg = self._unitDataInCategory[self._unitModel.get_value(iter, 0)][0]
650 #set the result in the value column
651 self._unitModel.set(iter, 1, str(apply(func.from_base, (base, arg, ))))
653 #point to the next row in the self._unitModel
654 iter = self._unitModel.iter_next(iter)
656 # if the second row has a unit then update its value
657 if self._previousUnitName.get_text() != '':
658 self._calcsuppress = True
659 func, arg = self._unitDataInCategory[self._previousUnitName.get_text()][0]
660 self._previousUnitValue.set_text(str(apply(func.from_base, (base, arg, ))))
661 self._calcsuppress = False
663 def _on_previous_unit_value_changed(self, a):
664 if self._calcsuppress == True:
665 #self._calcsuppress = False
667 # determine if value to be calculated is empty
668 if self._selected_category == "Computer Numbers":
669 if self._previousUnitValue.get_text() == '':
672 value = self._previousUnitValue.get_text()
674 if self._previousUnitValue.get_text() == '':
677 value = float(self._previousUnitValue.get_text())
679 if self._previousUnitName.get_text() != '':
680 func, arg = self._unitDataInCategory[self._previousUnitName.get_text()][0] #retrieve the conversion function and value from the selected unit
681 base = apply(func.to_base, (value, arg, )) #determine the base unit value
683 keys = self._unitDataInCategory.keys()
688 #point to the first row
689 iter = self._unitModel.get_iter_first()
692 #get the formula from the name at the row
693 func, arg = self._unitDataInCategory[self._unitModel.get_value(iter, 0)][0]
695 #set the result in the value column
696 self._unitModel.set(iter, 1, str(apply(func.from_base, (base, arg, ))))
698 #point to the next row in the self._unitModel
699 iter = self._unitModel.iter_next(iter)
701 # if the second row has a unit then update its value
702 if self._unitName.get_text() != '':
703 self._calcsuppress = True
704 func, arg = self._unitDataInCategory[self._unitName.get_text()][0]
705 self._unitValue.set_text(str(apply(func.from_base, (base, arg, ))))
706 self._calcsuppress = False
708 def _on_about_clicked(self, a):
709 dlg = gtk.AboutDialog()
710 dlg.set_name(constants.__pretty_app_name__)
711 dlg.set_version("%s-%d" % (constants.__version__, constants.__build__))
712 dlg.set_copyright("Copyright 2009 - GPL")
714 dlg.set_website("http://unihedron.com/projects/gonvert/gonvert.php")
715 dlg.set_authors(["Anthony Tekatch <anthony@unihedron.com>", "Ed Page <edpage@byu.net>"])
721 logging.basicConfig(level = logging.DEBUG)
723 os.makedirs(constants._data_path_)
732 if __name__ == "__main__":