Пример #1
0
 def new_dialog(self):
     '''
     Display a dialog for adding a new row.
     Values from a newly-created row are put into the "data" variable.
     Perhaps this is a hack, but it seems to work okay.
     '''
     
     dialog = InputDialog(NEW_DIALOG, self.fields, self.backend, parent=self)
     data = [] # Pass a created row back through this variable
     dialog.set_data(data)
     ret = dialog.exec_()
     if ret == QtGui.QDialog.Accepted:
         items = self.items_to_model(data)
         self.table_model.appendRow(items)
Пример #2
0
    def newSnippet(self, whatever):
        dialog = InputDialog(mainwindow=self.main_WIN)
        res = dialog.showInput(["title", "alias"],
                text="input the info of the snippet:")
        dialog.clear()
        uid = str(uuid.uuid1()).replace("-", "")
        sql = "insert into snippet (title, alias, filename) values (?, ?, ?);"
        cursor = self.conn.cursor()
        cursor.execute(sql, (res["title"], res["alias"], uid))
        self.conn.commit()

        # add items
        self.addItem(res["title"])
        self.updateResults()
Пример #3
0
 def edit_dialog(self):
     '''A dialog for editing an existing row.'''
     
     # Check that a row is highlighted
     row_num = self.current_row_num()
     if row_num == None:
         return
     
     # Get a highlighted row's values as a list of strings.
     col_count = self.table_model.columnCount()
     row = [self.table_model.item(row_num, i) for i in range(col_count)]
     data = map(lambda x: x.data(role=QtCore.Qt.DisplayRole).toString(), row)
     
     # Create and display an edit dialog.
     dialog = InputDialog(EDIT_DIALOG, self.fields, self.backend, parent=self)
     dialog.set_data(data)
     ret = dialog.exec_()
     if ret == QtGui.QDialog.Accepted:
         self.recycle_row(row_num)
Пример #4
0
 def inputdia(self, *args):
     inputdialog = InputDialog(mainwindow=self.main_WIN)
     result = inputdialog.showInput(["name", "age", "gender", "hello", "world"], "fill the info:")
     inputdialog.clear()
     self.redraw()
     return True