Esempio n. 1
0
 def table_handle(self):
     """Insert Table"""
     iter_insert = self.dad.curr_buffer.get_iter_at_mark(self.dad.curr_buffer.get_insert())
     ret_ok, ret_csv = self.dialog_tablehandle(_("Insert Table"), True)
     if not ret_ok: return
     if not ret_csv:
         self.table_insert(iter_insert)
     else:
         filepath = support.dialog_file_select(filter_pattern=["*.csv"],
                                               filter_name=_("CSV File"),
                                               curr_folder=self.dad.pick_dir,
                                               parent=self.dad.window)
         if filepath != None:
             self.dad.pick_dir = os.path.dirname(filepath)
             support.text_file_rm_emptylines(filepath)
             file_descriptor = open(filepath, 'r')
             reader = UnicodeReader(file_descriptor)
             table_matrix = []
             row = reader.next()
             while row:
                 table_matrix.append(row)
                 row = reader.next()
             file_descriptor.close()
             table_matrix.append(table_matrix.pop(0))
             self.table_insert(iter_insert, {'col_min': cons.TABLE_DEFAULT_COL_MIN,
                                             'col_max': cons.TABLE_DEFAULT_COL_MAX,
                                             'matrix': table_matrix})
Esempio n. 2
0
 def table_handle(self):
     """Insert Table"""
     iter_insert = self.dad.curr_buffer.get_iter_at_mark(
         self.dad.curr_buffer.get_insert())
     ret_ok, ret_csv = self.dialog_tablehandle(_("Insert Table"), True)
     if not ret_ok: return
     if not ret_csv:
         self.table_insert(iter_insert)
     else:
         filepath = support.dialog_file_select(
             filter_pattern=["*.csv"],
             filter_name=_("CSV File"),
             curr_folder=self.dad.pick_dir_csv,
             parent=self.dad.window)
         if filepath != None:
             self.dad.pick_dir_csv = os.path.dirname(filepath)
             support.text_file_rm_emptylines(filepath)
             file_descriptor = open(filepath, 'r')
             reader = UnicodeReader(file_descriptor)
             table_matrix = []
             row = reader.next()
             while row:
                 table_matrix.append(row)
                 row = reader.next()
             file_descriptor.close()
             table_matrix.append(table_matrix.pop(0))
             self.table_insert(
                 iter_insert, {
                     'col_min': cons.TABLE_DEFAULT_COL_MIN,
                     'col_max': cons.TABLE_DEFAULT_COL_MAX,
                     'matrix': table_matrix
                 })
Esempio n. 3
0
 def codebox_load_from_file(self, action):
     """Load the CodeBox Content From a Text File"""
     if not self.dad.is_curr_node_not_read_only_or_error(): return
     filepath = support.dialog_file_select(curr_folder=self.dad.pick_dir, parent=self.dad.window)
     if not filepath: return
     self.dad.pick_dir = os.path.dirname(filepath)
     with open(filepath, 'r') as fd:
         self.curr_codebox_anchor.sourcebuffer.set_text(fd.read())
Esempio n. 4
0
 def codebox_load_from_file(self, action):
     """Load the CodeBox Content From a Text File"""
     if not self.dad.is_curr_node_not_read_only_or_error(): return
     filepath = support.dialog_file_select(curr_folder=self.dad.pick_dir, parent=self.dad.window)
     if not filepath: return
     self.dad.pick_dir = os.path.dirname(filepath)
     with open(filepath, 'r') as fd:
         self.curr_codebox_anchor.sourcebuffer.set_text(fd.read())