Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:33:16+00:00 2026-06-05T22:33:16+00:00

I have a function creating entries via grid() like this: (replace while-loop with function,

  • 0

I have a function creating entries via grid() like this: (replace while-loop with function, this should just show you what it looks like later)

from Tkinter import * 

root = Tk()

index=0

while index < 10:

     col0 = Text(root,width=20, height=1, bg='white')
     col0.grid(row=index,column=0)
     col0.insert('0.0',"name")
     col1 = Text(root,width=20, height=1, bg='white')
     col1.grid(row=index,column=1)
     col1.insert('0.0',"attribute #1")
     col2 = Text(root,width=20, height=1, bg='white')
     col2.grid(row=index,column=2)
     col2.insert('0.0',"attribute #2")
     col3 = Text(root,width=20, height=1, bg='white')
     col3.grid(row=index,column=3)
     col3.insert('0.0',"counter")
     index+=1

root.mainloop()

so on special events the function is called and creates a new entry (a new row). but if there is already an entry for this event, i just want to increase the counter.

the eventnames and their entryrows (index) are saved in a dictionary, so i do have the row and column, but how can i actually access col3 now?

i planned to get the counter via col3.get(), but it is called col3 in every row, so how could i specify it?

is it alternatively possible to put col0,col1,col2 etc into a kind of structure (like a dictionary), so access them via col0[name].insert()… (name is unique)? i tried that but that did not work out (which does not mean its impossible i hope, i am just quite new to python)

does anyone have any suggestions or solutions to my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:33:18+00:00Added an answer on June 5, 2026 at 10:33 pm

    You need to save references to all the Text widgets that you create:

    colHeaders = ["name", "attribute #1", "attribute #2", "counter"]
    myTextWidgets = []
    for index in range(10):
        subList = []
        for i, header in enumerate(colHeaders):
            text = Text(root,width=20, height=1, bg='white')
            text.grid(row=index,column=i)
            text.insert('0.0',header)
            subList.append(text)
        myTextWidgets.append(subList)
    

    This would allow you to access each widget by it’s row/column:

    myTextWidgets[0][1].config(bg="purple")
    

    You could easily append a new row to this structure like so:

    subList = []
    for i, header in enumerate(colHeaders):
        text = Text(root,width=20, height=1, bg='white')
        text.grid(row=len(myTextWidgets),column=i)
        text.insert('0.0', header)
        subList.append(text)
    myTextWidgets.append(subList)
    

    With this structure, it’s not the names that are unique, but the positions of each cell.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a function that looks like this: public void AnimateLayoutTransform(object ControlToAnimate) {
I have function like this: function gi_insert() { if(!IS_AJAX){ $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Naslov', 'trim|required|strip_tags'); $this->form_validation->set_rules('body',
I have the below function creating new panels inside my ViewStack.. This works fine
I have a function creating a file for download like so: header(Content-type: application/octet-stream); header(Content-disposition:
if I have function like this: function Apple(){ this.color = green; return this; }
Okay, I feel like I should be able to do this, but I have
I have a function that is used to creating a directory. It uses CreateDirectoryA()
I have a looping function creating: <li id=id1 name=Tag1,Tag2,Tag3> <li id=id2 name=Tag1,Tag2,Tag3> $.each(data.posts, function(i,
I am creating a generic function that have the function definition as: public static
I have a function for creating a tooltip from a title. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.