Public Activity

Fetched from http://localhost:40385/activitypub/public/page

{…}
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "OrderedCollectionPage",
  "orderedItems": [
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:00e08388-2962-457c-ad04-8d3524a6506e",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        }
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public"
      ],
      "id": "https://distbin.com/activities/e3d03f76-0b2e-4b13-a27e-873a91d3c277",
      "published": "2019-04-19T21:07:49.403Z",
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:e3d03f76-0b2e-4b13-a27e-873a91d3c277"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/e3d03f76-0b2e-4b13-a27e-873a91d3c277"
      ],
      "uuid": "e3d03f76-0b2e-4b13-a27e-873a91d3c277",
      "replies": "https://distbin.com/activities/e3d03f76-0b2e-4b13-a27e-873a91d3c277/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:c8a534e0-0aa5-41a0-af44-eb079a16813c",
        "type": "Note",
        "content": "import mysql.connector as mariadb\r\nfrom tkinter import *\r\nfrom tkinter import font\r\n\r\n# Database Connection Settings\r\nusername = 'python'\r\npassword = 'Python123'\r\ndb = 'python_testing'\r\n\r\n# Database Connection\r\nmariadb_connection = mariadb.connect(user=username, password=password, database=db)\r\n\r\n# Create Update function to update a row in the database\r\ndef updateRow(ID,name,email,row):\r\n\r\n    editWindow = Tk()\r\n    editWindow.title('Edit Database Row Information')\r\n\r\n    updateInputFrame = Frame(editWindow)\r\n    updateInputFrame.grid(row=0,column=0,padx=2,pady=2)\r\n\r\n    updateButtonsFrame = Frame(editWindow)\r\n    updateButtonsFrame.grid(row=1,column=0,padx=2,pady=2)\r\n\r\n    updateLblOuterPadding = 2\r\n    updateLblInnerPadding = 5\r\n\r\n    entryName = editWindow.StringVar()\r\n    entryName.set(\"testing\")\r\n\r\n    lblUpdateName = Label(updateInputFrame, textvariable=entryName)\r\n    lblUpdateName.grid(row=0,column=0, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)\r\n\r\n    entryUpdateName = Entry(updateInputFrame, text=name, width=50, textvariable=entryName)\r\n    entryUpdateName.grid(row=0,column=1, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)\r\n\r\n    \r\n\r\n    lblUpdateEmail = Label(updateInputFrame, text=\"Email:\")\r\n    lblUpdateEmail.grid(row=1,column=0, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)\r\n\r\n    \r\n    entryUpdateEmail = Entry(updateInputFrame, width=50)    \r\n    entryUpdateEmail.grid(row=1,column=1, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)\r\n\r\n    updateSubmit = Button(updateButtonsFrame, text=\"Submit Update\")\r\n    updateSubmit.grid(row=0,column=0)\r\n    # First update the database\r\n    #cursor.execute(\"UPDATE SET name=%s, email=%s WHERE ID=%s\",(name,email,ID))\r\n    #mariadb_connection.commit()\r\n\r\n    # Now update the gui with the new information\r\n\r\n\r\n# Create Delete function to delete a row from the database via it's ID, then remove it from the GUI\r\ndef delWithID(ID,row):\r\n    \r\n    # Remove the selected row from the database\r\n    cursor.execute(\"DELETE FROM table1 WHERE ID=%s\",(ID,))\r\n    mariadb_connection.commit()\r\n\r\n    # and now remove the row from the GUI\r\n    lblName[row].grid_remove()\r\n    lblNameOutput[row].grid_remove()\r\n    lblEmail[row].grid_remove()\r\n    lblEmailOutput[row].grid_remove()\r\n    btnEdit[row].grid_remove()\r\n    btnDel[row].grid_remove()\r\n\r\n# Create Window\r\nwindow = Tk()\r\nwindow.title('Media Database Application')\r\n\r\n# Instantiate the Cursor Object\r\ncursor = mariadb_connection.cursor()\r\n\r\n# Collect results from the table in the database\r\ncursor.execute(\"SELECT *, ROW_NUMBER() OVER(ORDER BY ID) AS row FROM table1 ORDER BY ID\")\r\n\r\n# Set settings for menu\r\nmenuOuterPadding = 1\r\nmenuInnerPadding = 15\r\nmenubgcolor = '#2B3389'\r\nmenuforecolor = '#EEEEEE'\r\n\r\n# Display menu\r\nmenu = Frame(window)\r\nmenu.grid(row=0)\r\nmenuFont = font.Font(weight='bold', size=10)\r\nlblMenu = Label(menu, text='View all Media', background=menubgcolor, foreground=menuforecolor, font=menuFont)\r\nlblMenu.grid(row=0, column=0, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)\r\nlblMenu = Label(menu, text='View All Audio', background=menubgcolor, foreground=menuforecolor, font=menuFont)\r\nlblMenu.grid(row=0, column=1, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)\r\nlblMenu = Label(menu, text='View All Videos', background=menubgcolor, foreground=menuforecolor, font=menuFont)\r\nlblMenu.grid(row=0, column=2, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)\r\nlblMenu = Label(menu, text='View All Books', background=menubgcolor, foreground=menuforecolor, font=menuFont)\r\nlblMenu.grid(row=0, column=3, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)\r\nlblMenu = Label(menu, text='Insert New Media', background=menubgcolor, foreground=menuforecolor, font=menuFont)\r\nlblMenu.grid(row=0, column=4, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)\r\n\r\n#Display Table Data\r\ndataTable = Frame(window)\r\ndataTable.grid(row=1,sticky=N+E+S+W)\r\n\r\n# Set settings for results table\r\ninnerPadding = 5\r\nouterPadding = 1\r\nrowbgcolor = '#333333'\r\nrowforecolor = '#eeeeee'\r\n\r\n# Define field arrays\r\nlblName = []\r\nlblNameOutput = [] \r\nlblEmail = []\r\nlblEmailOutput = []\r\nbtnEdit = []\r\nbtnDel = []\r\n\r\n# Display results\r\nfor ID, name, email, row in cursor:\r\n\r\n    #Minus one from row for zero indexing of arrarys\r\n    zeroIndexedRow = row - 1\r\n\r\n    #Name Columns\r\n    lblName.append(Label(dataTable, text='Name:', background=rowbgcolor, foreground=rowforecolor))\r\n    lblName[zeroIndexedRow].grid(row=row,column=0,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)\r\n\r\n    testEntry = StringVar()\r\n    testEntry.set(\"testing\")\r\n\r\n    lblNameOutput.append(Label(dataTable, textvariable=testEntry, background=rowbgcolor, foreground=rowforecolor))\r\n    lblNameOutput[zeroIndexedRow].grid(row=row,column=1,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)\r\n    \r\n    #Email Columns\r\n    lblEmail.append(Label(dataTable, text='Email:', background=rowbgcolor, foreground=rowforecolor))\r\n    lblEmail[zeroIndexedRow].grid(row=row,column=2,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)\r\n\r\n    lblEmailOutput.append(Label(dataTable, text=email, background=rowbgcolor, foreground=rowforecolor))\r\n    lblEmailOutput[zeroIndexedRow].grid(row=row,column=3,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)\r\n\r\n    #Edit Button\r\n    btnEdit.append(Button(dataTable, text='Edit', command=lambda id=ID,name=name,email=email,row=zeroIndexedRow:updateRow(id,name,email,row)))\r\n    btnEdit[zeroIndexedRow].grid(\r\n        row=row,\r\n        column=4,\r\n        padx=outerPadding,\r\n        pady=outerPadding,\r\n        ipadx=innerPadding,\r\n        ipady=innerPadding,\r\n        sticky=N+E+S+W)\r\n\r\n    #Delete Button : To select the correct lbl to remove use zeroIndexedRow\r\n    btnDel.append(Button(dataTable, text='Delete', command=lambda id=ID,row=zeroIndexedRow:delWithID(id,row)))\r\n    btnDel[zeroIndexedRow].grid(\r\n        row=row,\r\n        column=5,\r\n        padx=outerPadding,\r\n        pady=outerPadding,\r\n        ipadx=innerPadding,\r\n        ipady=innerPadding,\r\n        sticky=N+E+S+W)\r\n\r\n# Set things in motion\r\nwindow.mainloop()\r\n\r\n# Close the database connection\r\nmariadb_connection.close()",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        }
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public"
      ],
      "id": "https://distbin.com/activities/3b4ce9b4-5396-4c5d-aa89-ffd5b2b478af",
      "published": "2019-04-19T14:02:56.476Z",
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:3b4ce9b4-5396-4c5d-aa89-ffd5b2b478af"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/3b4ce9b4-5396-4c5d-aa89-ffd5b2b478af"
      ],
      "uuid": "3b4ce9b4-5396-4c5d-aa89-ffd5b2b478af",
      "replies": "https://distbin.com/activities/3b4ce9b4-5396-4c5d-aa89-ffd5b2b478af/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:ee490829-3fce-495b-8713-00730f9e01df",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/63565519-c0ae-42b7-a1f5-23fb662371a8",
      "published": "2019-04-18T18:27:58.029Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:63565519-c0ae-42b7-a1f5-23fb662371a8"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/63565519-c0ae-42b7-a1f5-23fb662371a8"
      ],
      "uuid": "63565519-c0ae-42b7-a1f5-23fb662371a8",
      "replies": "https://distbin.com/activities/63565519-c0ae-42b7-a1f5-23fb662371a8/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:5fcb3900-cf0c-442f-9b33-5d117c9867e0",
        "type": "Note",
        "content": "123",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/0c06b7a1-79a1-4ec0-a996-04de72b0e9fb",
      "published": "2019-04-18T04:36:28.076Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:0c06b7a1-79a1-4ec0-a996-04de72b0e9fb"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/0c06b7a1-79a1-4ec0-a996-04de72b0e9fb"
      ],
      "uuid": "0c06b7a1-79a1-4ec0-a996-04de72b0e9fb",
      "replies": "https://distbin.com/activities/0c06b7a1-79a1-4ec0-a996-04de72b0e9fb/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:6f99c554-ced3-4113-80d5-d10bfe080078",
        "type": "Note",
        "content": "dasd",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        }
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public"
      ],
      "id": "https://distbin.com/activities/620aeea6-b4b2-4a59-b33f-f96def603b0e",
      "published": "2019-04-17T19:38:11.951Z",
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:620aeea6-b4b2-4a59-b33f-f96def603b0e"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/620aeea6-b4b2-4a59-b33f-f96def603b0e"
      ],
      "uuid": "620aeea6-b4b2-4a59-b33f-f96def603b0e",
      "replies": "https://distbin.com/activities/620aeea6-b4b2-4a59-b33f-f96def603b0e/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:3875c43a-560d-46cf-bf65-1e0116465247",
        "type": "Note",
        "content": "ColorOS\r\nbased on Android\r\n\r\nModel\r\nOPPO R7s\r\n\r\nColorOS version\r\nV2.1\r\n\r\nAndroid version\r\n4.4.4\r\n\r\nCPU\r\nOcta core\r\n\r\nRAM\r\n4GB\r\n\r\nROM\r\n32GB (Total space)\r\n\r\nBuild number\r\nR7s_11_160818\r\n\r\nLegal information\r\n\r\nBaseband version\r\nMOLY.LR9.W1423.MD.LWTG.CMCC.MP.V10.P70,\r\n2016/01/21 20:07\r\n\r\nKernel version\r\n3.10.48-G201608181914",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        }
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public"
      ],
      "id": "https://distbin.com/activities/eb9510d4-80bd-49b6-a85f-b243c36f59b8",
      "published": "2019-04-16T13:29:47.775Z",
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:eb9510d4-80bd-49b6-a85f-b243c36f59b8"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/eb9510d4-80bd-49b6-a85f-b243c36f59b8"
      ],
      "uuid": "eb9510d4-80bd-49b6-a85f-b243c36f59b8",
      "replies": "https://distbin.com/activities/eb9510d4-80bd-49b6-a85f-b243c36f59b8/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:6c0446d8-4ffe-4af9-ba92-f58d6f30d7f2",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/ec3b2ecf-0542-457f-964f-c15dfa3915ee",
      "published": "2019-04-16T11:41:15.037Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:ec3b2ecf-0542-457f-964f-c15dfa3915ee"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/ec3b2ecf-0542-457f-964f-c15dfa3915ee"
      ],
      "uuid": "ec3b2ecf-0542-457f-964f-c15dfa3915ee",
      "replies": "https://distbin.com/activities/ec3b2ecf-0542-457f-964f-c15dfa3915ee/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:80d90725-9db4-4922-971e-e54af9cc57d0",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/3b1ec704-b65a-4a7a-88a4-98ae19c89120",
      "published": "2019-04-16T01:02:59.855Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:3b1ec704-b65a-4a7a-88a4-98ae19c89120"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/3b1ec704-b65a-4a7a-88a4-98ae19c89120"
      ],
      "uuid": "3b1ec704-b65a-4a7a-88a4-98ae19c89120",
      "replies": "https://distbin.com/activities/3b1ec704-b65a-4a7a-88a4-98ae19c89120/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:b5a15608-989d-4c0e-a42c-b8a3fb069dcb",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/5a608996-6a94-4dcb-a7a2-abc26af19ddc",
      "published": "2019-04-16T01:02:51.727Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:5a608996-6a94-4dcb-a7a2-abc26af19ddc"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/5a608996-6a94-4dcb-a7a2-abc26af19ddc"
      ],
      "uuid": "5a608996-6a94-4dcb-a7a2-abc26af19ddc",
      "replies": "https://distbin.com/activities/5a608996-6a94-4dcb-a7a2-abc26af19ddc/replies"
    },
    {
      "type": "Create",
      "@context": "https://www.w3.org/ns/activitystreams",
      "object": {
        "id": "urn:uuid:8f0119e2-858c-4fe7-aa79-1a6aa25ad9d1",
        "type": "Note",
        "content": "",
        "generator": {
          "type": "Application",
          "name": "distbin-html",
          "url": "https://distbin.com"
        },
        "inReplyTo": "http://distbin.com/about"
      },
      "cc": [
        "https://www.w3.org/ns/activitystreams#Public",
        "http://distbin.com/about"
      ],
      "id": "https://distbin.com/activities/6a86051b-7560-4cf9-8bb2-3c4ba3a9091a",
      "published": "2019-04-15T23:34:49.928Z",
      "distbin:activityPubDeliveryFailures": [
        {
          "name": "UnexpectedContentTypeError",
          "message": "Dont know how to parse contentType=text/html"
        }
      ],
      "distbin:activityPubDeliverySuccesses": [],
      "http://www.w3.org/2002/07/owl#sameAs": [
        "urn:uuid:6a86051b-7560-4cf9-8bb2-3c4ba3a9091a"
      ],
      "inbox": [
        "https://distbin.com/activitypub/inbox"
      ],
      "url": [
        "https://distbin.com/activities/6a86051b-7560-4cf9-8bb2-3c4ba3a9091a"
      ],
      "uuid": "6a86051b-7560-4cf9-8bb2-3c4ba3a9091a",
      "replies": "https://distbin.com/activities/6a86051b-7560-4cf9-8bb2-3c4ba3a9091a/replies"
    }
  ],
  "startIndex": 0,
  "next": "?cursor=%7B%22or%22%3A%5B%7B%22published%22%3A%7B%22lt%22%3A%222019-04-15T23%3A34%3A49.928Z%22%7D%7D%2C%7B%22and%22%3A%5B%7B%22published%22%3A%7B%22equals%22%3A%222019-04-15T23%3A34%3A49.928Z%22%7D%7D%2C%7B%22id%22%3A%7B%22lt%22%3A%22https%3A%2F%2Fdistbin.com%2Factivities%2F6a86051b-7560-4cf9-8bb2-3c4ba3a9091a%22%7D%7D%5D%7D%5D%7D",
  "partOf": "/activitypub/public"
}

https://distbin.com/activities/e3d03f76-0b2e-4b13-a27e-873a91d3c277

import mysql.connector as mariadb from tkinter import * from tkinter import font

Database Connection Settings

username = 'python' password = 'Python123' db = 'python_testing'

Database Connection

mariadb_connection = mariadb.connect(user=username, password=password, database=db)

Create Update function to update a row in the database

def updateRow(ID,name,email,row):

editWindow = Tk()
editWindow.title('Edit Database Row Information')

updateInputFrame = Frame(editWindow)
updateInputFrame.grid(row=0,column=0,padx=2,pady=2)

updateButtonsFrame = Frame(editWindow)
updateButtonsFrame.grid(row=1,column=0,padx=2,pady=2)

updateLblOuterPadding = 2
updateLblInnerPadding = 5

entryName = editWindow.StringVar()
entryName.set("testing")

lblUpdateName = Label(updateInputFrame, textvariable=entryName)
lblUpdateName.grid(row=0,column=0, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)

entryUpdateName = Entry(updateInputFrame, text=name, width=50, textvariable=entryName)
entryUpdateName.grid(row=0,column=1, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)



lblUpdateEmail = Label(updateInputFrame, text="Email:")
lblUpdateEmail.grid(row=1,column=0, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)


entryUpdateEmail = Entry(updateInputFrame, width=50)    
entryUpdateEmail.grid(row=1,column=1, padx=updateLblOuterPadding, pady=updateLblOuterPadding, ipadx=updateLblInnerPadding, ipady=updateLblInnerPadding)

updateSubmit = Button(updateButtonsFrame, text="Submit Update")
updateSubmit.grid(row=0,column=0)
# First update the database
#cursor.execute("UPDATE SET name=%s, email=%s WHERE ID=%s",(name,email,ID))
#mariadb_connection.commit()

# Now update the gui with the new information

Create Delete function to delete a row from the database via it's ID, then remove it from the GUI

def delWithID(ID,row):

# Remove the selected row from the database
cursor.execute("DELETE FROM table1 WHERE ID=%s",(ID,))
mariadb_connection.commit()

# and now remove the row from the GUI
lblName[row].grid_remove()
lblNameOutput[row].grid_remove()
lblEmail[row].grid_remove()
lblEmailOutput[row].grid_remove()
btnEdit[row].grid_remove()
btnDel[row].grid_remove()

Create Window

window = Tk() window.title('Media Database Application')

Instantiate the Cursor Object

cursor = mariadb_connection.cursor()

Collect results from the table in the database

cursor.execute("SELECT *, ROW_NUMBER() OVER(ORDER BY ID) AS row FROM table1 ORDER BY ID")

Set settings for menu

menuOuterPadding = 1 menuInnerPadding = 15 menubgcolor = '#2B3389' menuforecolor = '#EEEEEE'

Display menu

menu = Frame(window) menu.grid(row=0) menuFont = font.Font(weight='bold', size=10) lblMenu = Label(menu, text='View all Media', background=menubgcolor, foreground=menuforecolor, font=menuFont) lblMenu.grid(row=0, column=0, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W) lblMenu = Label(menu, text='View All Audio', background=menubgcolor, foreground=menuforecolor, font=menuFont) lblMenu.grid(row=0, column=1, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W) lblMenu = Label(menu, text='View All Videos', background=menubgcolor, foreground=menuforecolor, font=menuFont) lblMenu.grid(row=0, column=2, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W) lblMenu = Label(menu, text='View All Books', background=menubgcolor, foreground=menuforecolor, font=menuFont) lblMenu.grid(row=0, column=3, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W) lblMenu = Label(menu, text='Insert New Media', background=menubgcolor, foreground=menuforecolor, font=menuFont) lblMenu.grid(row=0, column=4, padx=menuOuterPadding, pady=menuOuterPadding, ipadx=menuInnerPadding, ipady=menuInnerPadding, sticky=N+E+S+W)

#Display Table Data dataTable = Frame(window) dataTable.grid(row=1,sticky=N+E+S+W)

Set settings for results table

innerPadding = 5 outerPadding = 1 rowbgcolor = '#333333' rowforecolor = '#eeeeee'

Define field arrays

lblName = [] lblNameOutput = [] lblEmail = [] lblEmailOutput = [] btnEdit = [] btnDel = []

Display results

for ID, name, email, row in cursor:

#Minus one from row for zero indexing of arrarys
zeroIndexedRow = row - 1

#Name Columns
lblName.append(Label(dataTable, text='Name:', background=rowbgcolor, foreground=rowforecolor))
lblName[zeroIndexedRow].grid(row=row,column=0,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)

testEntry = StringVar()
testEntry.set("testing")

lblNameOutput.append(Label(dataTable, textvariable=testEntry, background=rowbgcolor, foreground=rowforecolor))
lblNameOutput[zeroIndexedRow].grid(row=row,column=1,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)

#Email Columns
lblEmail.append(Label(dataTable, text='Email:', background=rowbgcolor, foreground=rowforecolor))
lblEmail[zeroIndexedRow].grid(row=row,column=2,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)

lblEmailOutput.append(Label(dataTable, text=email, background=rowbgcolor, foreground=rowforecolor))
lblEmailOutput[zeroIndexedRow].grid(row=row,column=3,padx=outerPadding,pady=outerPadding,ipadx=innerPadding,ipady=innerPadding,sticky=N+E+S+W)

#Edit Button
btnEdit.append(Button(dataTable, text='Edit', command=lambda id=ID,name=name,email=email,row=zeroIndexedRow:updateRow(id,name,email,row)))
btnEdit[zeroIndexedRow].grid(
    row=row,
    column=4,
    padx=outerPadding,
    pady=outerPadding,
    ipadx=innerPadding,
    ipady=innerPadding,
    sticky=N+E+S+W)

#Delete Button : To select the correct lbl to remove use zeroIndexedRow
btnDel.append(Button(dataTable, text='Delete', command=lambda id=ID,row=zeroIndexedRow:delWithID(id,row)))
btnDel[zeroIndexedRow].grid(
    row=row,
    column=5,
    padx=outerPadding,
    pady=outerPadding,
    ipadx=innerPadding,
    ipady=innerPadding,
    sticky=N+E+S+W)

Set things in motion

window.mainloop()

Close the database connection

mariadb_connection.close()

https://distbin.com/activities/63565519-c0ae-42b7-a1f5-23fb662371a8

123

dasd

ColorOS based on Android

Model OPPO R7s

ColorOS version V2.1

Android version 4.4.4

CPU Octa core

RAM 4GB

ROM 32GB (Total space)

Build number R7s_11_160818

Legal information

Baseband version MOLY.LR9.W1423.MD.LWTG.CMCC.MP.V10.P70, 2016/01/21 20:07

Kernel version 3.10.48-G201608181914

https://distbin.com/activities/ec3b2ecf-0542-457f-964f-c15dfa3915ee

https://distbin.com/activities/3b1ec704-b65a-4a7a-88a4-98ae19c89120

https://distbin.com/activities/5a608996-6a94-4dcb-a7a2-abc26af19ddc

https://distbin.com/activities/6a86051b-7560-4cf9-8bb2-3c4ba3a9091a

Next Page