Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifiy the order of columns #2

Open
GoogleCodeExporter opened this issue May 2, 2015 · 1 comment
Open

Specifiy the order of columns #2

GoogleCodeExporter opened this issue May 2, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hi,

I am trying to use your module to import some stored data and programmatically 
add rows as new information comes in.  I am having trouble specifying the order 
of the columns as they are created.  

I have modified your createData() function as:

def createData():

    data = {}
    serials = [ '3456', '2343', '2345' ]
    colnames = [ 'Serial', 'IP', 'Name' ]

    for sn in serials:
        data[sn] = {}

    ips = ['172.26.2.1', '172.26.2.2', '172.26.2.3']
    names = ['Test1', 'Test2', 'Test3']

    i=0
    for sn in serials:
        data[sn][colnames[0]] = serials[i]
        data[sn][colnames[1]] = ips[i]
        data[sn][colnames[2]] = names[i]
        i+=1

    return data

The problem I am finding is that the IP column is the first column, rather than 
the serial number.  How can I switch the order of these columns at the start of 
the program?

Thanks,

Patrick


Original issue reported on code.google.com by pfarrel...@gmail.com on 3 Mar 2013 at 4:31

@GoogleCodeExporter
Copy link
Author

This is not a real problem in the programm. It's rather that dictionaries have 
no fixed order. So you could rearrange the columns like that. 
yourTableModel.moveColumn(yourTableModel.getColumnIndex('columnName'), 
desiredColumnIndex)
This worked for me.
I hope I could help. :)

Original comment by LGurki...@gmail.com on 8 Jun 2013 at 1:36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant