# -*- coding: utf-8 -*-
"""
Created on Mon Feb 17 11:46:43 2020
@author: Onyx1
program:making form using python
"""
import tkinter as tk
def show_entry_fields():
print("CONTROLLER: %s\nPROCESSOR: %s\nFREQUENCY: %s\nFLASH: %s\nRAM: %s\nGPIO: %s\nADV_TM: %s\nGPTM: %s\nWDG: %s\nRTC: %s\nUART: %s\nI2C: %s\nSPI: %s\nADC: %s\nEEPROM: %s\nPACK: %s\nDAC: %s\nUSB: %s\nCAN: %s\nSDIO: %s\nCOMP: %s\nAES: %s\nTRNG: %s" % (e1.get(),
e2.get(),
e3.get(),
e4.get(),
e5.get(),
e6.get(),
e7.get(),
e8.get(),
e9.get(),
e10.get(),
e11.get(),
e12.get(),
e13.get(),
e14.get(),
e15.get(),
e16.get(),
e17.get(),
e18.get(),
e19.get(),
e20.get(),
e21.get(),
e22.get(),
e23.get()))
master = tk.Tk()
tk.Label(master, text="CONTROLLER").grid(row=0)
tk.Label(master, text="PROCESSOR").grid(row=1)
tk.Label(master, text="FREQUENCY").grid(row=2)
tk.Label(master, text="FLASH").grid(row=3)
tk.Label(master, text="RAM").grid(row=4)
tk.Label(master, text="GPIO").grid(row=5)
tk.Label(master, text="ADV_TM").grid(row=6)
tk.Label(master, text="GPTM").grid(row=7)
tk.Label(master, text="WDG").grid(row=8)
tk.Label(master, text="RTC").grid(row=9)
tk.Label(master, text="UART").grid(row=10)
tk.Label(master, text="I2C").grid(row=11)
tk.Label(master, text="SPI").grid(row=12)
tk.Label(master, text="ADC").grid(row=13)
tk.Label(master, text="EEPROM").grid(row=14)
tk.Label(master, text="PACK").grid(row=15)
tk.Label(master, text="DAC").grid(row=16)
tk.Label(master, text="USB").grid(row=17)
tk.Label(master, text="CAN").grid(row=18)
tk.Label(master, text="SDIO").grid(row=19)
tk.Label(master, text="COMP").grid(row=20)
tk.Label(master, text="AES").grid(row=21)
tk.Label(master, text="TRNG").grid(row=22)
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e4 = tk.Entry(master)
e5 = tk.Entry(master)
e6 = tk.Entry(master)
e7 = tk.Entry(master)
e8 = tk.Entry(master)
e9 = tk.Entry(master)
e10 = tk.Entry(master)
e11 = tk.Entry(master)
e12 = tk.Entry(master)
e13 = tk.Entry(master)
e14 = tk.Entry(master)
e15 = tk.Entry(master)
e16= tk.Entry(master)
e17= tk.Entry(master)
e18= tk.Entry(master)
e19= tk.Entry(master)
e20= tk.Entry(master)
e21= tk.Entry(master)
e22= tk.Entry(master)
e23= tk.Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)
e5.grid(row=4, column=1)
e6.grid(row=5, column=1)
e7.grid(row=6, column=1)
e8.grid(row=7, column=1)
e9.grid(row=8, column=1)
e10.grid(row=9, column=1)
e11.grid(row=10, column=1)
e12.grid(row=11, column=1)
e13.grid(row=12, column=1)
e14.grid(row=13, column=1)
e15.grid(row=14, column=1)
e16.grid(row=15, column=1)
e17.grid(row=16, column=1)
e18.grid(row=17, column=1)
e19.grid(row=18, column=1)
e20.grid(row=19, column=1)
e21.grid(row=20, column=1)
e22.grid(row=21, column=1)
e23.grid(row=22, column=1)
tk.Button(master, text='Quit', command=master.quit).grid(row=23,column=0,sticky=tk.W,pady=4)
tk.Button(master, text='Show', command=show_entry_fields).grid(row=23, column=1, sticky=tk.W,pady=4)
tk.mainloop()
output:
example 2:
import tkinter as tk
import pymysql
conn=pymysql.connect(host="localhost",user="root",password="",db="my_python")
mycursor=conn.cursor()
def show_db():
mycursor.execute("SELECT * FROM mm32_microcontroller")
row = mycursor.fetchone()
while row is not None:
print(row)
row = mycursor.fetchone()
def insert_db():
mycursor.execute("INSERT INTO mm32_microcontroller(id,controller,processor,frequency,flash,ram,gpio,adv_tm,gptm,wdg,rtc,uart,i2c,spi,adc,eeprom,pack,dac,usb,can,sdio,comp,aes,trng) VALUES(null,'MM32F003','ARM Cortex M0','48Mhz','16','2','16','1','5','2','-','1','1','1','8x12bit','-','QFN20','-','-','-','-','-','-','-');")
print("->data inserted")
conn.commit()
def entry_fields():
tk.Label(master, text="CONTROLLER").grid(row=0)
tk.Label(master, text="PROCESSOR").grid(row=1)
tk.Label(master, text="FREQUENCY").grid(row=2)
tk.Label(master, text="FLASH").grid(row=3)
tk.Label(master, text="RAM").grid(row=4)
tk.Label(master, text="GPIO").grid(row=5)
tk.Label(master, text="ADV_TM").grid(row=6)
tk.Label(master, text="GPTM").grid(row=7)
tk.Label(master, text="WDG").grid(row=8)
tk.Label(master, text="RTC").grid(row=9)
tk.Label(master, text="UART").grid(row=10)
tk.Label(master, text="I2C").grid(row=11)
tk.Label(master, text="SPI").grid(row=12)
tk.Label(master, text="ADC").grid(row=13)
tk.Label(master, text="EEPROM").grid(row=14)
tk.Label(master, text="PACK").grid(row=15)
tk.Label(master, text="DAC").grid(row=16)
tk.Label(master, text="USB").grid(row=17)
tk.Label(master, text="CAN").grid(row=18)
tk.Label(master, text="SDIO").grid(row=19)
tk.Label(master, text="COMP").grid(row=20)
tk.Label(master, text="AES").grid(row=21)
tk.Label(master, text="TRNG").grid(row=22)
def show_entry_fields():
print("CONTROLLER: %s\nPROCESSOR: %s\nFREQUENCY: %s\nFLASH: %s\nRAM: %s\nGPIO: %s\nADV_TM: %s\nGPTM: %s\nWDG: %s\nRTC: %s\nUART: %s\nI2C: %s\nSPI: %s\nADC: %s\nEEPROM: %s\nPACK: %s\nDAC: %s\nUSB: %s\nCAN: %s\nSDIO: %s\nCOMP: %s\nAES: %s\nTRNG: %s" % (e1.get(),
e2.get(),
e3.get(),
e4.get(),
e5.get(),
e6.get(),
e7.get(),
e8.get(),
e9.get(),
e10.get(),
e11.get(),
e12.get(),
e13.get(),
e14.get(),
e15.get(),
e16.get(),
e17.get(),
e18.get(),
e19.get(),
e20.get(),
e21.get(),
e22.get(),
e23.get()))
controller_value=e1.get()#received value is stored here
print(controller_value)#checking whether the value is correct or not
master = tk.Tk()
entry_fields()
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e4 = tk.Entry(master)
e5 = tk.Entry(master)
e6 = tk.Entry(master)
e7 = tk.Entry(master)
e8 = tk.Entry(master)
e9 = tk.Entry(master)
e10 = tk.Entry(master)
e11 = tk.Entry(master)
e12 = tk.Entry(master)
e13 = tk.Entry(master)
e14 = tk.Entry(master)
e15 = tk.Entry(master)
e16= tk.Entry(master)
e17= tk.Entry(master)
e18= tk.Entry(master)
e19= tk.Entry(master)
e20= tk.Entry(master)
e21= tk.Entry(master)
e22= tk.Entry(master)
e23= tk.Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)
e5.grid(row=4, column=1)
e6.grid(row=5, column=1)
e7.grid(row=6, column=1)
e8.grid(row=7, column=1)
e9.grid(row=8, column=1)
e10.grid(row=9, column=1)
e11.grid(row=10, column=1)
e12.grid(row=11, column=1)
e13.grid(row=12, column=1)
e14.grid(row=13, column=1)
e15.grid(row=14, column=1)
e16.grid(row=15, column=1)
e17.grid(row=16, column=1)
e18.grid(row=17, column=1)
e19.grid(row=18, column=1)
e20.grid(row=19, column=1)
e21.grid(row=20, column=1)
e22.grid(row=21, column=1)
e23.grid(row=22, column=1)
tk.Button(master, text='Quit', command=master.quit).grid(row=23,column=0,sticky=tk.W,pady=4)
tk.Button(master, text='ADD', command=insert_db).grid(row=23, column=1, sticky=tk.W,pady=4)
tk.Button(master, text='Show', command=show_entry_fields).grid(row=23, column=2, sticky=tk.W,pady=4)
print("\nPlease enter your choice\n")
#print
#while True:
choice=int(input("1.add\n2.show\n3.show all\n"))
if choice==1:
insert_db()
elif choice ==2 :
show_db()
else:
mycursor.execute("SELECT * FROM mm32_microcontroller")
rows = mycursor.fetchall()
print('Total Row(s):', mycursor.rowcount)
for row in rows:
print(row)
#conn.commit()
conn.close()
tk.mainloop()
output:
"""
Created on Mon Feb 17 11:46:43 2020
@author: Onyx1
program:making form using python
"""
import tkinter as tk
def show_entry_fields():
print("CONTROLLER: %s\nPROCESSOR: %s\nFREQUENCY: %s\nFLASH: %s\nRAM: %s\nGPIO: %s\nADV_TM: %s\nGPTM: %s\nWDG: %s\nRTC: %s\nUART: %s\nI2C: %s\nSPI: %s\nADC: %s\nEEPROM: %s\nPACK: %s\nDAC: %s\nUSB: %s\nCAN: %s\nSDIO: %s\nCOMP: %s\nAES: %s\nTRNG: %s" % (e1.get(),
e2.get(),
e3.get(),
e4.get(),
e5.get(),
e6.get(),
e7.get(),
e8.get(),
e9.get(),
e10.get(),
e11.get(),
e12.get(),
e13.get(),
e14.get(),
e15.get(),
e16.get(),
e17.get(),
e18.get(),
e19.get(),
e20.get(),
e21.get(),
e22.get(),
e23.get()))
master = tk.Tk()
tk.Label(master, text="CONTROLLER").grid(row=0)
tk.Label(master, text="PROCESSOR").grid(row=1)
tk.Label(master, text="FREQUENCY").grid(row=2)
tk.Label(master, text="FLASH").grid(row=3)
tk.Label(master, text="RAM").grid(row=4)
tk.Label(master, text="GPIO").grid(row=5)
tk.Label(master, text="ADV_TM").grid(row=6)
tk.Label(master, text="GPTM").grid(row=7)
tk.Label(master, text="WDG").grid(row=8)
tk.Label(master, text="RTC").grid(row=9)
tk.Label(master, text="UART").grid(row=10)
tk.Label(master, text="I2C").grid(row=11)
tk.Label(master, text="SPI").grid(row=12)
tk.Label(master, text="ADC").grid(row=13)
tk.Label(master, text="EEPROM").grid(row=14)
tk.Label(master, text="PACK").grid(row=15)
tk.Label(master, text="DAC").grid(row=16)
tk.Label(master, text="USB").grid(row=17)
tk.Label(master, text="CAN").grid(row=18)
tk.Label(master, text="SDIO").grid(row=19)
tk.Label(master, text="COMP").grid(row=20)
tk.Label(master, text="AES").grid(row=21)
tk.Label(master, text="TRNG").grid(row=22)
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e4 = tk.Entry(master)
e5 = tk.Entry(master)
e6 = tk.Entry(master)
e7 = tk.Entry(master)
e8 = tk.Entry(master)
e9 = tk.Entry(master)
e10 = tk.Entry(master)
e11 = tk.Entry(master)
e12 = tk.Entry(master)
e13 = tk.Entry(master)
e14 = tk.Entry(master)
e15 = tk.Entry(master)
e16= tk.Entry(master)
e17= tk.Entry(master)
e18= tk.Entry(master)
e19= tk.Entry(master)
e20= tk.Entry(master)
e21= tk.Entry(master)
e22= tk.Entry(master)
e23= tk.Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)
e5.grid(row=4, column=1)
e6.grid(row=5, column=1)
e7.grid(row=6, column=1)
e8.grid(row=7, column=1)
e9.grid(row=8, column=1)
e10.grid(row=9, column=1)
e11.grid(row=10, column=1)
e12.grid(row=11, column=1)
e13.grid(row=12, column=1)
e14.grid(row=13, column=1)
e15.grid(row=14, column=1)
e16.grid(row=15, column=1)
e17.grid(row=16, column=1)
e18.grid(row=17, column=1)
e19.grid(row=18, column=1)
e20.grid(row=19, column=1)
e21.grid(row=20, column=1)
e22.grid(row=21, column=1)
e23.grid(row=22, column=1)
tk.Button(master, text='Quit', command=master.quit).grid(row=23,column=0,sticky=tk.W,pady=4)
tk.Button(master, text='Show', command=show_entry_fields).grid(row=23, column=1, sticky=tk.W,pady=4)
tk.mainloop()
output:
example 2:
import tkinter as tk
import pymysql
conn=pymysql.connect(host="localhost",user="root",password="",db="my_python")
mycursor=conn.cursor()
def show_db():
mycursor.execute("SELECT * FROM mm32_microcontroller")
row = mycursor.fetchone()
while row is not None:
print(row)
row = mycursor.fetchone()
def insert_db():
mycursor.execute("INSERT INTO mm32_microcontroller(id,controller,processor,frequency,flash,ram,gpio,adv_tm,gptm,wdg,rtc,uart,i2c,spi,adc,eeprom,pack,dac,usb,can,sdio,comp,aes,trng) VALUES(null,'MM32F003','ARM Cortex M0','48Mhz','16','2','16','1','5','2','-','1','1','1','8x12bit','-','QFN20','-','-','-','-','-','-','-');")
print("->data inserted")
conn.commit()
def entry_fields():
tk.Label(master, text="CONTROLLER").grid(row=0)
tk.Label(master, text="PROCESSOR").grid(row=1)
tk.Label(master, text="FREQUENCY").grid(row=2)
tk.Label(master, text="FLASH").grid(row=3)
tk.Label(master, text="RAM").grid(row=4)
tk.Label(master, text="GPIO").grid(row=5)
tk.Label(master, text="ADV_TM").grid(row=6)
tk.Label(master, text="GPTM").grid(row=7)
tk.Label(master, text="WDG").grid(row=8)
tk.Label(master, text="RTC").grid(row=9)
tk.Label(master, text="UART").grid(row=10)
tk.Label(master, text="I2C").grid(row=11)
tk.Label(master, text="SPI").grid(row=12)
tk.Label(master, text="ADC").grid(row=13)
tk.Label(master, text="EEPROM").grid(row=14)
tk.Label(master, text="PACK").grid(row=15)
tk.Label(master, text="DAC").grid(row=16)
tk.Label(master, text="USB").grid(row=17)
tk.Label(master, text="CAN").grid(row=18)
tk.Label(master, text="SDIO").grid(row=19)
tk.Label(master, text="COMP").grid(row=20)
tk.Label(master, text="AES").grid(row=21)
tk.Label(master, text="TRNG").grid(row=22)
def show_entry_fields():
print("CONTROLLER: %s\nPROCESSOR: %s\nFREQUENCY: %s\nFLASH: %s\nRAM: %s\nGPIO: %s\nADV_TM: %s\nGPTM: %s\nWDG: %s\nRTC: %s\nUART: %s\nI2C: %s\nSPI: %s\nADC: %s\nEEPROM: %s\nPACK: %s\nDAC: %s\nUSB: %s\nCAN: %s\nSDIO: %s\nCOMP: %s\nAES: %s\nTRNG: %s" % (e1.get(),
e2.get(),
e3.get(),
e4.get(),
e5.get(),
e6.get(),
e7.get(),
e8.get(),
e9.get(),
e10.get(),
e11.get(),
e12.get(),
e13.get(),
e14.get(),
e15.get(),
e16.get(),
e17.get(),
e18.get(),
e19.get(),
e20.get(),
e21.get(),
e22.get(),
e23.get()))
controller_value=e1.get()#received value is stored here
print(controller_value)#checking whether the value is correct or not
master = tk.Tk()
entry_fields()
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e4 = tk.Entry(master)
e5 = tk.Entry(master)
e6 = tk.Entry(master)
e7 = tk.Entry(master)
e8 = tk.Entry(master)
e9 = tk.Entry(master)
e10 = tk.Entry(master)
e11 = tk.Entry(master)
e12 = tk.Entry(master)
e13 = tk.Entry(master)
e14 = tk.Entry(master)
e15 = tk.Entry(master)
e16= tk.Entry(master)
e17= tk.Entry(master)
e18= tk.Entry(master)
e19= tk.Entry(master)
e20= tk.Entry(master)
e21= tk.Entry(master)
e22= tk.Entry(master)
e23= tk.Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)
e5.grid(row=4, column=1)
e6.grid(row=5, column=1)
e7.grid(row=6, column=1)
e8.grid(row=7, column=1)
e9.grid(row=8, column=1)
e10.grid(row=9, column=1)
e11.grid(row=10, column=1)
e12.grid(row=11, column=1)
e13.grid(row=12, column=1)
e14.grid(row=13, column=1)
e15.grid(row=14, column=1)
e16.grid(row=15, column=1)
e17.grid(row=16, column=1)
e18.grid(row=17, column=1)
e19.grid(row=18, column=1)
e20.grid(row=19, column=1)
e21.grid(row=20, column=1)
e22.grid(row=21, column=1)
e23.grid(row=22, column=1)
tk.Button(master, text='Quit', command=master.quit).grid(row=23,column=0,sticky=tk.W,pady=4)
tk.Button(master, text='ADD', command=insert_db).grid(row=23, column=1, sticky=tk.W,pady=4)
tk.Button(master, text='Show', command=show_entry_fields).grid(row=23, column=2, sticky=tk.W,pady=4)
print("\nPlease enter your choice\n")
#while True:
choice=int(input("1.add\n2.show\n3.show all\n"))
if choice==1:
insert_db()
elif choice ==2 :
show_db()
else:
mycursor.execute("SELECT * FROM mm32_microcontroller")
rows = mycursor.fetchall()
print('Total Row(s):', mycursor.rowcount)
for row in rows:
print(row)
#conn.commit()
conn.close()
tk.mainloop()
output: