• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question : How Make Smart Loop And Make Everythings We Think?

 
Greenhorn
Posts: 4
jQuery Python Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all brothers and sisters my question is how i can make many buttons for all records from database in tkinter that each button delete one record that in loop we made i write this code but with this way delete last record with all button how is posible each button delete that record in that round made together with button in loop?
Thank You Very Much God Blesed You And Your Love And Your Familly :X.

   def deletebtn():
       connection = sqlite3.connect('DBphonebook.db')
       c = connection.cursor()
       c.execute("DELETE from phonebook WHERE Name= :Name AND Familly= :Familly", {'Name':i[0], 'Familly':i[1]})
       connection.commit()
       connection.close()

   for i in listofrecords:
       x += 20
       Button(second_frame, text='delete', command=deletebtn).grid(row=x , column=0, padx=1, pady=1)
       Label(second_frame, text= i[3]).grid(row=x, column=150, pady=10, padx=130)
       Label(second_frame, text= i[2]).grid(row=x, column=200, pady=10, padx=30)
       Label(second_frame, text= i[0]).grid(row=x, column=300, pady=10, padx=30)
       Label(second_frame, text= i[1]).grid(row=x, column=250, pady=10, padx=30)

In This Code We Have Many Code Before For Making Window And Database Records But In This Loop We Put Every Record From Database With Label And Before This Every Round We Make One Button For Delete Each Record But Why In Every Round Every Button Don't Work For Delete That Record In That round Beacuase In One Funtion That Name Is deletebtn I Put Deleting Proccess For Database Commands? How This Is Possible ?



       
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I am afraid your post is very difficult to read., Please Don't Write Every Word With A Capital Letter, and please use some punctuation. Please don't double‑space your code.
 
Amin Ojaghi
Greenhorn
Posts: 4
jQuery Python Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi my brother thanks for your comment after this i write my questions and posts like this god blesed you and your love and your familly.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amin Ojaghi wrote:. . . god blesed you . . . .

Thank you. But you will only get help with your question if we can read it easily.
 
Amin Ojaghi
Greenhorn
Posts: 4
jQuery Python Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again i changed my explenations about this question in your thinking now is good?
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite a bit better, thank you.
I don't know any Python and I have forgotten most of SQL, but yes, you can delete a line from a database by pushing a button. How do you know that deletion isn't executed correctly? How do you know that the name you are deleting is the same as in the database?
 
Amin Ojaghi
Greenhorn
Posts: 4
jQuery Python Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have one window as list of poeple who they added by program inside and i can know my add record work good.
And with this command i can delete from database but i cant find one way to make button in loop that i put records with label becuase i put recods of poeple with loop in one list and in this list i need for each record one button for delete but when i write button like this all button becuase they made by loop don't work i need one way to make these button with this loop becuase of records of database that have change and go more i need loop for buttons to if record added button also add.

   def deletebtn():
       connection = sqlite3.connect('DBphonebook.db')
       c = connection.cursor()
       c.execute("DELETE from phonebook WHERE Name= :Name AND Familly= :Familly", {'Name':i[0], 'Familly':i[1]})
       connection.commit()
i want to put this function as command in option of buttons that i make with loop for delete records when you click on each button.

And i am thinking about developing loop to much becuase good loop is very important in developing in every program we write if you have good algoritm for loops you can write your program very simple and for start i am looking for make one loop to make variable becuase in these loop we have we can just put one or more but not 1000000 variable with diffrent name if we make one loop for produce variable with diffrent name we are too much more powerfull .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic