コード例 #1
0
ファイル: listComp.py プロジェクト: sg45905/Python_Projects
    def __init__(self):
        self._dbconnect = DBConnect()
        self._dbconnect.row_factory = sqlite3.Row

        # define the root view
        self._root = Tk()
        self._root.title('List of Complaints')

        # define the table
        tv = Treeview(self._root)

        tv.pack()

        tv.heading('#0', text='ID')
        tv.configure(column=('#Name', '#Gender', '#Comment'))
        tv.heading('#Name', text='Name')
        tv.heading('#Gender', text='Gender')
        tv.heading('#Comment', text='Comment')

        cursor = self._dbconnect.ListRequest()

        for row in cursor:
            tv.insert('', 'end', '#{}'.format(row['ID']), text=row['ID'])
            tv.set('#{}'.format(row['ID']), '#Name', row['Name'])
            tv.set('#{}'.format(row['ID']), '#Gender', row['Gender'])
            tv.set('#{}'.format(row['ID']), '#Comment', row['Comment'])
コード例 #2
0
ファイル: GazanOOP.py プロジェクト: K-DOT/GazanPlayer
 def loadFiles(self):
     '''
     This method loads files, put them into queue, add the title of the track to "play" list(for displaying in the table)
     Also creates grabb artwork images and save them in file 
         TODO: program should save images in sqlite database, not files.
     '''
     untitled_count = 0 # Count of intitled songs (for list)
     for file in self.files:
         self.song = pyglet.media.load(file)  # Load the file
         self.instance.player.queue(self.song)  # Put the file into a queue
         #self.instance.player.volume = 0.1
         #if self.song.info.title not in self.instance.play_files:
         if not self.song.info.title: self.song.info.title =('Unknown%d' % untitled_count if untitled_count else 'Unknown'); untitled_count+=1 
         self.instance.play_files.append(self.song.info.title)  # add song to list
         try:
             fileMp3 = File(file)   # get artwork 
             if file.endswith('.mp3'):
                 artwork = fileMp3.tags['APIC:'].data
             elif file.endswith('.m4a') or file.endswith('.mp4'): 
                 artwork = fileMp3.tags['covr'][0]
             elif file.endswith('.flac'):  
                 artwork =  fileMp3.pictures[0].data  
             else:
                 artwork =  ''
             if artwork and self.song.info.album:
                 database = DBConnect('GPlayer.db')
                 database.add_image(self.song.info.album, artwork)
                 #with open('%s.jpg' % (self.song.info.album), 'wb') as img:
                      #img.write(artwork) # write artwork to new image  
         except (KeyError, TypeError) as e:
             pass          
コード例 #3
0
ファイル: GazanOOP.py プロジェクト: kthulhu/GazanPlayer
 def loadFiles(self):
     '''
     This method loads files, put them into queue, add the title of the track to "play" list(for displaying in the table)
     Also creates grabb artwork images and save them in file 
         TODO: program should save images in sqlite database, not files.
     '''
     untitled_count = 0  # Count of intitled songs (for list)
     for file in self.files:
         self.song = pyglet.media.load(file)  # Load the file
         self.instance.player.queue(self.song)  # Put the file into a queue
         #self.instance.player.volume = 0.1
         #if self.song.info.title not in self.instance.play_files:
         if not self.song.info.title:
             self.song.info.title = ('Unknown%d' % untitled_count
                                     if untitled_count else 'Unknown')
             untitled_count += 1
         self.instance.play_files.append(
             self.song.info.title)  # add song to list
         try:
             fileMp3 = File(file)  # get artwork
             if file.endswith('.mp3'):
                 artwork = fileMp3.tags['APIC:'].data
             elif file.endswith('.m4a') or file.endswith('.mp4'):
                 artwork = fileMp3.tags['covr'][0]
             elif file.endswith('.flac'):
                 artwork = fileMp3.pictures[0].data
             else:
                 artwork = ''
             if artwork and self.song.info.album:
                 database = DBConnect('GPlayer.db')
                 database.add_image(self.song.info.album, artwork)
                 #with open('%s.jpg' % (self.song.info.album), 'wb') as img:
                 #img.write(artwork) # write artwork to new image
         except (KeyError, TypeError) as e:
             pass
コード例 #4
0
 def __init__(self):
     self._dbconnect = DBConnect()
     self._dbconnect.row_factory = sqlite3.Row
     self._root = Tk()
     self._root.geometry('800x800')
     self._root.title('List of Complaints')
     self.tree = Treeview(self._root)
     self.fillTable()
コード例 #5
0
ファイル: utils.py プロジェクト: jeff-hughes/portertree
def export_data(db_conn: DBConnect) -> str:
    """Given a connection to the database, this exports the data to
    CSV files, zips them and saves them to the <APP_ROOT>/static/data/
    directory. Returns the name of the file (without the directory)."""
    date = datetime.now().strftime("%Y%m%d")
    tables = ["people", "marriages", "children"]
    with tempfile.TemporaryDirectory() as tmpdir:
        for table in tables:
            with open(os.path.join(tmpdir, f"{table}_{date}.csv"), "w") as f:
                db_conn.export_data(table, f)

        os.makedirs(os.path.join(os.environ.get("APP_ROOT"), "static/data"),
                    exist_ok=True)
        shutil.make_archive(
            os.path.join(os.environ.get("APP_ROOT"), "static/data",
                         f"data_{date}"), "zip", tmpdir)
    return f"data_{date}.zip"
コード例 #6
0
ファイル: GazanOOP.py プロジェクト: K-DOT/GazanPlayer
 def on_change(self, s, lst):
     self.labArt.setFixedHeight(300)
     self.labArt.setFixedWidth(300)
     database = DBConnect('GPlayer.db')
     try:
         data = database.get_image(unicode(s.encode('iso8859-1')))
         pm = QtGui.QPixmap()
         pm.loadFromData(QtCore.QByteArray(data))
         self.labArt.setPixmap(pm)
     except:
         self.labArt.setPixmap('logo.png')
     
     lst = [unicode(x.encode('iso8859-1')) for x in lst ]
     self.add_list(lst)  # add list to gui tracks table
     self.set_current(lst.index(instance.player.source.info.title or u'Unknown'))
     self.slider.setMaximum(instance.player.source.duration-1)
     self.slider.setValue(instance.player.time)
コード例 #7
0
ファイル: GazanOOP.py プロジェクト: kthulhu/GazanPlayer
    def on_change(self, s, lst):
        self.labArt.setFixedHeight(300)
        self.labArt.setFixedWidth(300)
        database = DBConnect('GPlayer.db')
        try:
            data = database.get_image(unicode(s.encode('iso8859-1')))
            pm = QtGui.QPixmap()
            pm.loadFromData(QtCore.QByteArray(data))
            self.labArt.setPixmap(pm)
        except:
            self.labArt.setPixmap('logo.png')

        lst = [unicode(x.encode('iso8859-1')) for x in lst]
        self.add_list(lst)  # add list to gui tracks table
        self.set_current(
            lst.index(instance.player.source.info.title or u'Unknown'))
        self.slider.setMaximum(instance.player.source.duration - 1)
        self.slider.setValue(instance.player.time)
コード例 #8
0
ファイル: listComp.py プロジェクト: rshah2399/Python-Project
	def __init__(self):
		self._dbconnect = DBConnect()
		self._dbconnect.row_factory = sqlite3.Row
		self._root = Tk()
		self._root.title('List of Complaints')
		tv = Treeview(self._root)
		tv.pack()
		tv.heading('#0', text='ID')
		tv.configure(column=('#PoliceStation', '#Subject', '#ComplaintType', '#Name', '#Gender', '#Address', '#Phone', '#Comment'))
		
		colwidth=150
		
		tv.heading('#PoliceStation',text='Police')
		tv.heading('#Subject',text='Subject')
		tv.heading('#ComplaintType',text='ComplaintType')		
		tv.heading('#Name', text='Name')
		tv.heading('#Gender', text='Gender')
		tv.heading('#Address', text='Address')
		tv.heading('#Phone', text='Phone')				
		tv.heading('#Comment', text='Comment')
		cursor = self._dbconnect.ListRequest()
		
		tv.column("#0", width=100 )
		tv.column("#PoliceStation", width=colwidth )
		tv.column("#Subject", width=colwidth )
		tv.column("#ComplaintType", width=colwidth )
		tv.column("#Name", width=colwidth )
		tv.column("#Gender", width=colwidth )
		tv.column("#Address", width=colwidth )
		tv.column("#Phone", width=colwidth )
		tv.column("#Comment", width=colwidth )
		
		for row in cursor:
			tv.insert('', 'end', '#{}'.format(row['ID']),text=row['ID'])
			tv.set('#{}'.format(row['ID']),'#PoliceStation',row['Police'])
			tv.set('#{}'.format(row['ID']),'#Subject',row['Subject'])
			tv.set('#{}'.format(row['ID']),'#ComplaintType',row['ComplaintType'])			
			tv.set('#{}'.format(row['ID']),'#Name',row['Name'])
			tv.set('#{}'.format(row['ID']),'#Gender',row['Gender'])
			tv.set('#{}'.format(row['ID']),'#Address',row['Address'])
			tv.set('#{}'.format(row['ID']),'#Phone',row['Phone'])			
			tv.set('#{}'.format(row['ID']),'#Comment',row['Comment'])
コード例 #9
0
#!/usr/bin/python3
from tkinter import *
from tkinter.ttk import *
from tkinter.messagebox import *
from db import DBConnect
from listComp import ListComp

#Config
conn = DBConnect()
root = Tk()
root.geometry('1800x1000')
root.title('FIR Complaint System')
root.configure(background='#AEB6BF')

#Style
style = Style()
style.theme_use('classic')
for elem in ['TLabel', 'TButton', 'TRadioutton']:
    style.configure(elem, background='#AEB6BF')

#Entries

w1 = Label(root,
           text='Welcome To FIR Complaint System',
           font=("Helvetica", 20)).grid(row=0, column=1, padx=10, pady=10)

logo1 = PhotoImage(file="logo.png")
Label(root, image=logo1).grid(row=0)

w2 = Label(root, text='Police Station:').grid(row=1,
                                              column=0,
コード例 #10
0
from flask_mailman import Mail, EmailMessage

from auth import User, hash_pass
from db import DBConnect, DBEntry, DBEntryType, PERSON_COLS, MARRIAGE_COLS
import utils

# special cases with extended notes about the early family members
EXTENDED_NOTES = ["1", "1.1", "1.2", "1.3", "1.5", "1.6", "1.7", "1.8"]

app = Flask(__name__)
app.config.from_envvar('FLASK_SETTINGS')
mail = Mail(app)
login_manager = LoginManager(app)
login_manager.login_view = "admin_login"

db = DBConnect()


@app.route('/')
def index():
    raw_data_file = utils.get_latest_export()
    if raw_data_file is None:
        raw_data_file = utils.export_data(db)
    raw_data_file = "data/" + raw_data_file
    return render_template("index.html", raw_data=raw_data_file)


@app.route('/search', methods=['GET'])
def search():
    if len(request.args) > 0:
        terms = request.args.get("search", "").split()
コード例 #11
0
class ListComp:
    def __init__(self):
        self._dbconnect = DBConnect()
        self._dbconnect.row_factory = sqlite3.Row
        self._root = Tk()
        self._root.geometry('800x800')
        self._root.title('List of Complaints')
        self.tree = Treeview(self._root)
        self.fillTable()

    def OnDoubleClick(self, event):
        item = self.tree.selection()
        print('item:', item)
        #print('event:', event)
        item = self.tree.selection()[0]
        curItem = self.tree.focus()
        print(self.tree.item(curItem)["values"][8])

        toggle = 1

        if self.tree.item(curItem)["values"][8] == "Case Closed":
            toggle = 0

        row = self.tree.item(item, "text")
        cursor = self._dbconnect.UpdateRow(toggle, int(row))
        self.fillTable()

    def fillTable(self):
        tv = self.tree
        tv.delete(*tv.get_children())
        tv.bind("<<TreeviewSelect>>", self.OnDoubleClick)
        tv.pack()
        tv.heading('#0', text='ID')
        tv.configure(column=('#PoliceStation', '#Subject', '#ComplaintType',
                             '#Name', '#Gender', '#Address', '#Phone',
                             '#Comment', '#Closed'))

        colwidth = 80

        tv.heading('#PoliceStation', text='Police')
        tv.heading('#Subject', text='Subject')
        tv.heading('#ComplaintType', text='ComplaintType')
        tv.heading('#Name', text='Name')
        tv.heading('#Gender', text='Gender')
        tv.heading('#Address', text='Address')
        tv.heading('#Phone', text='Phone')
        tv.heading('#Comment', text='Comment')
        tv.heading('#Closed', text='Case Closed')
        cursor = self._dbconnect.ListRequest()

        tv.column("#0", width=50)
        tv.column("#PoliceStation", width=colwidth)
        tv.column("#Subject", width=colwidth)
        tv.column("#ComplaintType", width=colwidth)
        tv.column("#Name", width=colwidth)
        tv.column("#Gender", width=colwidth)
        tv.column("#Address", width=colwidth)
        tv.column("#Phone", width=colwidth)
        tv.column("#Comment", width=colwidth)
        tv.column("#Closed", width=colwidth)

        for row in cursor:
            tv.insert('', 'end', '#{}'.format(row['ID']), text=row['ID'])
            tv.set('#{}'.format(row['ID']), '#PoliceStation', row['Police'])
            tv.set('#{}'.format(row['ID']), '#Subject', row['Subject'])
            tv.set('#{}'.format(row['ID']), '#ComplaintType',
                   row['ComplaintType'])
            tv.set('#{}'.format(row['ID']), '#Name', row['Name'])
            tv.set('#{}'.format(row['ID']), '#Gender', row['Gender'])
            tv.set('#{}'.format(row['ID']), '#Address', row['Address'])
            tv.set('#{}'.format(row['ID']), '#Phone', row['Phone'])
            tv.set('#{}'.format(row['ID']), '#Comment', row['Comment'])
            closed = "Investigation ongoing"
            if row['Closed'] == 1:
                closed = "Case Closed"
            tv.set('#{}'.format(row['ID']), '#Closed', closed)