473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to delete the rows with the delete button and how to edit with edit button

the code that am sharing is just working for the add button only would you help me in the delete and edit button....thanks so much


Expand|Select|Wrap|Line Numbers
  1. from PyQt4 import QtGui , QtCore
  2. class Example ( QtGui.QWidget ):
  3.     row = 0
  4.     def __init__ ( self ):
  5.         super ( Example , self ). __init__ ()
  6.         self.setGeometry (300 , 300 , 350 , 250)
  7.         self.setWindowTitle ( " names " )
  8.         #self.menubar()
  9.         self.initData ()
  10.         self.initUI ()
  11.         row=0;
  12.         col=0;
  13.     def initData ( self ):
  14.         data = ("David otewa","meshack Otewa" )
  15.         self.model = QtGui.QStandardItemModel (12 , 1)
  16.  
  17.         col = 0
  18.         for i in data :
  19.             item = QtGui.QStandardItem(str((i)))
  20.             self.model.setItem(self.row,col,item )
  21.             self.row = self.row + 1
  22.     def initUI ( self ):
  23.         lv = QtGui . QListView( self )
  24.         lv.setModel(self.model )
  25.  
  26.         layout=QtGui.QVBoxLayout()
  27.         layout.addWidget(lv)
  28.         col=0
  29.         row=0
  30.         add=QtGui.QPushButton("Add",self)
  31.         add.move(265,30)
  32.  
  33.         self.connect(add, QtCore.SIGNAL('clicked()'), self.showDialog)
  34.  
  35.         delete=QtGui.QPushButton("Delete",self)
  36.         delete.move(265,60)
  37.  
  38.         edit=QtGui.QPushButton("Edit",self )
  39.         edit.move(265,90)
  40.  
  41.  
  42.  
  43.     def showDialog(self):
  44.  
  45.         text, ok = QtGui.QInputDialog.getText(self, 'Names', 
  46.                 'Enter your name:')
  47.  
  48.         if ok:
  49.             name=str(text)
  50.             self.add(name)
  51.  
  52.     def add(self,name):
  53.         data=str(name)
  54.         col=0
  55.         if data != ("") :
  56.             item = QtGui.QStandardItem(str((data)))
  57.             self.model.setItem(self.row,col,item )
  58.             self.row = self.row + 1
  59.  
  60.  
  61. app=QtGui.QApplication([])
  62. ex=Example()
  63. ex.show()
  64. app.exec_()
Sep 8 '11 #1
0 1245

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: rcamarda | last post by:
Hi, I need to delete rows from my user tables dependant upon there non existence from another table: delete student where student_id not in (select student_id from tblStudent) The reasons is...
11
by: suma | last post by:
Hello, I want to delete duplicate rows in a table when no primary key is defined. For eg: If we have table1 with data as below, Suma 23 100 Suma 23 100 I want to delete a row from this...
1
by: Randall Parker | last post by:
Currently in an asp:DataGrid I have a column for bringing up an edit form on a particular row and that is done by a hyperlink as follows: <asp:TemplateColumn HeaderText="Edit Record">...
9
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like...
13
by: Shelley | last post by:
Compare Current Year Worksheet with Previous Year Worksheet and if SSN exists in Current Year Worksheet & Not in Previous Year - Copy this Row from Current Year Worksheet & Paste into Previous Year...
1
by: abdulkarim | last post by:
I have tried to delete rows in a table with same ID in access database by using the following vb code with a click on command button, but it deletes only a single row instead of entire rows with same...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
3
by: lisles | last post by:
hey,i've got a page that displays rows from a db.im want a function to dynamically delete rows.i've put it 1,bt i get an error as follows: Parse error: syntax error, unexpected T_STRING, expecting...
0
by: aswaditya | last post by:
Hi, I am new to SSIS packages. I have 6 Excel workbooks with data spread over two worksheets each and i have to map individual data to individual SQL tables. Please note that each worksheet is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.