Displaying sqlite3 data into TreeviewHow to get a list of column names on sqlite3 / iPhone?How to set Sqlite3 to be case insensitive when string comparing?Data binding to SelectedItem in a WPF Treeviewsqlite3-ruby install error on UbuntuHow to output sqlite3 data in tkinter treeviewHow to delete record from tkinter treeview to apply the changes in sqlite3How to update only selected sqlite3 record from tkinter treeviewpython database (sqlite3) and the treeviewEditable Treeview in tkinter.ttkIs there any way to resize a tkinter button?

Strange Sticky Substance on Digital Camera

What do you do if you have developments on your paper during the long peer review process?

Norwegian refuses EU delay (4.7 hours) compensation because it turned out there was nothing wrong with the aircraft

Hilbert's hotel: why can't I repeat it infinitely many times?

I reverse the source code, you negate the input!

What's the lowest risk highest reward I can invest in for 5 years?

Does "as soon as" imply simultaneity?

How use custom order in folder on Windows 7 and 10

Organisational search option

Social leper versus social leopard

Worms crawling under skin

How can I repair this gas leak on my new range? Teflon tape isn't working

Do we know the situation in Britain before Sealion (summer 1940)?

Is "ln" (natural log) and "log" the same thing if used in this answer?

Writing a letter of recommendation for a mediocre student

Is this a Sherman, and if so what model?

2000s Animated TV show where teenagers could physically go into a virtual world

What is the size of a set of sets of the empty set , , ?

Ruby language curious integer arithmetic : (-5/2) != -(5/2)

How do pilots align the HUD with their eyeballs?

When is it acceptable to write a bad letter of recommendation?

Is it impolite to ask for halal food when traveling to and in Thailand?

Everyone and NTFS permissions

Does Sitecore have support for Sitecore products in containers?



Displaying sqlite3 data into Treeview


How to get a list of column names on sqlite3 / iPhone?How to set Sqlite3 to be case insensitive when string comparing?Data binding to SelectedItem in a WPF Treeviewsqlite3-ruby install error on UbuntuHow to output sqlite3 data in tkinter treeviewHow to delete record from tkinter treeview to apply the changes in sqlite3How to update only selected sqlite3 record from tkinter treeviewpython database (sqlite3) and the treeviewEditable Treeview in tkinter.ttkIs there any way to resize a tkinter button?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am writing some code that shows a list of food with their information.



My code:



-connects to data base and gets items successfully



-loops correctly



Problem:



-If the name of my product is one word (ex:eggs) my code displays everything in the correct column



-If the name of my product is two or more words (ex:frosted flakes) my code displays 'frosted' on first column then 'flakes' in next columns which is incorrect



from tkinter import ttk
import tkinter as tk
import sqlite3
try:
from Tkinter import *
except ImportError:
from tkinter import *

def View():
db = sqlite3.connect("food_data.db")
cursor = db.cursor()
cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
for row in cursor:
disp=('0 1 2'.format(row[0], row[1], row[2]))
tree.insert("",tk.END, values=disp)
db.close()

root = tk.Tk()
root.geometry("800x480")
tree = ttk.Treeview(column=("column1","column2","column3"),show='headings')
tree.heading("#1", text="Name")
tree.heading("#2", text="Quantity")
tree.heading("#3", text="Expiration Date")
tree.pack()

b2 = tk.Button(text="view data", command=View)
b2.pack()

root.mainloop()


It is suppose to successfully display items with multiple words in their name onto one column and not carry to the next one.










share|improve this question






























    1















    I am writing some code that shows a list of food with their information.



    My code:



    -connects to data base and gets items successfully



    -loops correctly



    Problem:



    -If the name of my product is one word (ex:eggs) my code displays everything in the correct column



    -If the name of my product is two or more words (ex:frosted flakes) my code displays 'frosted' on first column then 'flakes' in next columns which is incorrect



    from tkinter import ttk
    import tkinter as tk
    import sqlite3
    try:
    from Tkinter import *
    except ImportError:
    from tkinter import *

    def View():
    db = sqlite3.connect("food_data.db")
    cursor = db.cursor()
    cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
    for row in cursor:
    disp=('0 1 2'.format(row[0], row[1], row[2]))
    tree.insert("",tk.END, values=disp)
    db.close()

    root = tk.Tk()
    root.geometry("800x480")
    tree = ttk.Treeview(column=("column1","column2","column3"),show='headings')
    tree.heading("#1", text="Name")
    tree.heading("#2", text="Quantity")
    tree.heading("#3", text="Expiration Date")
    tree.pack()

    b2 = tk.Button(text="view data", command=View)
    b2.pack()

    root.mainloop()


    It is suppose to successfully display items with multiple words in their name onto one column and not carry to the next one.










    share|improve this question


























      1












      1








      1








      I am writing some code that shows a list of food with their information.



      My code:



      -connects to data base and gets items successfully



      -loops correctly



      Problem:



      -If the name of my product is one word (ex:eggs) my code displays everything in the correct column



      -If the name of my product is two or more words (ex:frosted flakes) my code displays 'frosted' on first column then 'flakes' in next columns which is incorrect



      from tkinter import ttk
      import tkinter as tk
      import sqlite3
      try:
      from Tkinter import *
      except ImportError:
      from tkinter import *

      def View():
      db = sqlite3.connect("food_data.db")
      cursor = db.cursor()
      cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
      for row in cursor:
      disp=('0 1 2'.format(row[0], row[1], row[2]))
      tree.insert("",tk.END, values=disp)
      db.close()

      root = tk.Tk()
      root.geometry("800x480")
      tree = ttk.Treeview(column=("column1","column2","column3"),show='headings')
      tree.heading("#1", text="Name")
      tree.heading("#2", text="Quantity")
      tree.heading("#3", text="Expiration Date")
      tree.pack()

      b2 = tk.Button(text="view data", command=View)
      b2.pack()

      root.mainloop()


      It is suppose to successfully display items with multiple words in their name onto one column and not carry to the next one.










      share|improve this question














      I am writing some code that shows a list of food with their information.



      My code:



      -connects to data base and gets items successfully



      -loops correctly



      Problem:



      -If the name of my product is one word (ex:eggs) my code displays everything in the correct column



      -If the name of my product is two or more words (ex:frosted flakes) my code displays 'frosted' on first column then 'flakes' in next columns which is incorrect



      from tkinter import ttk
      import tkinter as tk
      import sqlite3
      try:
      from Tkinter import *
      except ImportError:
      from tkinter import *

      def View():
      db = sqlite3.connect("food_data.db")
      cursor = db.cursor()
      cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
      for row in cursor:
      disp=('0 1 2'.format(row[0], row[1], row[2]))
      tree.insert("",tk.END, values=disp)
      db.close()

      root = tk.Tk()
      root.geometry("800x480")
      tree = ttk.Treeview(column=("column1","column2","column3"),show='headings')
      tree.heading("#1", text="Name")
      tree.heading("#2", text="Quantity")
      tree.heading("#3", text="Expiration Date")
      tree.pack()

      b2 = tk.Button(text="view data", command=View)
      b2.pack()

      root.mainloop()


      It is suppose to successfully display items with multiple words in their name onto one column and not carry to the next one.







      python-3.x tkinter sqlite treeview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 16:02









      eyevangeeeyevangee

      82 bronze badges




      82 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          def View():
          db = sqlite3.connect("food_data.db")
          cursor = db.cursor()
          cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
          for row in cursor:
          # disp=('0 1 2'.format(row[0], row[1], row[2]))
          tree.insert("",tk.END, values=(row[0], row[1], row[2]))
          db.close()


          Do it this way rather you have to insert the content in the treeview as tuple or list after iterating over it.



           tree.insert("",tk.END, values=(row[0], row[1], row[2]))





          share|improve this answer





























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402091%2fdisplaying-sqlite3-data-into-treeview%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            def View():
            db = sqlite3.connect("food_data.db")
            cursor = db.cursor()
            cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
            for row in cursor:
            # disp=('0 1 2'.format(row[0], row[1], row[2]))
            tree.insert("",tk.END, values=(row[0], row[1], row[2]))
            db.close()


            Do it this way rather you have to insert the content in the treeview as tuple or list after iterating over it.



             tree.insert("",tk.END, values=(row[0], row[1], row[2]))





            share|improve this answer































              0
















              def View():
              db = sqlite3.connect("food_data.db")
              cursor = db.cursor()
              cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
              for row in cursor:
              # disp=('0 1 2'.format(row[0], row[1], row[2]))
              tree.insert("",tk.END, values=(row[0], row[1], row[2]))
              db.close()


              Do it this way rather you have to insert the content in the treeview as tuple or list after iterating over it.



               tree.insert("",tk.END, values=(row[0], row[1], row[2]))





              share|improve this answer





























                0














                0










                0









                def View():
                db = sqlite3.connect("food_data.db")
                cursor = db.cursor()
                cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
                for row in cursor:
                # disp=('0 1 2'.format(row[0], row[1], row[2]))
                tree.insert("",tk.END, values=(row[0], row[1], row[2]))
                db.close()


                Do it this way rather you have to insert the content in the treeview as tuple or list after iterating over it.



                 tree.insert("",tk.END, values=(row[0], row[1], row[2]))





                share|improve this answer















                def View():
                db = sqlite3.connect("food_data.db")
                cursor = db.cursor()
                cursor.execute("SELECT name, quantity, expdate FROM food ORDER BY expdate ASC")
                for row in cursor:
                # disp=('0 1 2'.format(row[0], row[1], row[2]))
                tree.insert("",tk.END, values=(row[0], row[1], row[2]))
                db.close()


                Do it this way rather you have to insert the content in the treeview as tuple or list after iterating over it.



                 tree.insert("",tk.END, values=(row[0], row[1], row[2]))






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 28 at 16:47

























                answered Mar 28 at 16:38









                AD WANAD WAN

                1,0401 gold badge5 silver badges19 bronze badges




                1,0401 gold badge5 silver badges19 bronze badges

































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402091%2fdisplaying-sqlite3-data-into-treeview%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript