python-simpletables 0.1.26__tar.gz → 0.1.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/PKG-INFO +2 -1
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/pyproject.toml +5 -2
- python_simpletables-0.1.27/python_simpletables/__init__.py +5 -0
- python_simpletables-0.1.27/python_simpletables/__main__.py +64 -0
- python_simpletables-0.1.27/python_simpletables/table.py +67 -0
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/PKG-INFO +2 -1
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/SOURCES.txt +2 -1
- python_simpletables-0.1.27/python_simpletables.egg-info/requires.txt +1 -0
- python_simpletables-0.1.26/python_simpletables/__init__.py +0 -5
- python_simpletables-0.1.26/python_simpletables/example.py +0 -14
- python_simpletables-0.1.26/python_simpletables/table.py +0 -53
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables/app.py +0 -0
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/dependency_links.txt +0 -0
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/top_level.txt +0 -0
- {python_simpletables-0.1.26 → python_simpletables-0.1.27}/setup.cfg +0 -0
|
@@ -4,10 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python_simpletables"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.27"
|
|
8
8
|
description = "Simple connection between SQL and tkinter."
|
|
9
9
|
authors = [{name = "Захар Васильев", email = "vasilyev.zakhar@gmail.com"}]
|
|
10
10
|
license = {text = "MIT"}
|
|
11
|
-
|
|
11
|
+
dependencies = [
|
|
12
|
+
"pandas"
|
|
13
|
+
]
|
|
14
|
+
|
|
12
15
|
[tool.setuptools.packages.find]
|
|
13
16
|
where = ["."]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import os,os.path as op,re,json,sqlite3,tkinter as tk,atexit
|
|
2
|
+
from tkinter import ttk
|
|
3
|
+
from . import Table,Field
|
|
4
|
+
|
|
5
|
+
def showid(table,field,value):
|
|
6
|
+
return str(value).rjust(5,"0")
|
|
7
|
+
def showbool(table,field,value):
|
|
8
|
+
return "Да" if value else "Нет"
|
|
9
|
+
class ExampleApp(tk.Tk):
|
|
10
|
+
def __init__(self,database_path):
|
|
11
|
+
conn = sqlite3.connect(database_path)
|
|
12
|
+
with open(op.join(op.dirname(__file__),"__main__.sql"),"r",encoding="utf8") as script:
|
|
13
|
+
for cmd in script.read().split(";"):
|
|
14
|
+
cmd=cmd.strip()
|
|
15
|
+
try: conn.execute(cmd) if cmd else None
|
|
16
|
+
except: print(repr(cmd))
|
|
17
|
+
super().__init__()
|
|
18
|
+
self.geometry("800x560")
|
|
19
|
+
self.minsize(400,300)
|
|
20
|
+
conn = sqlite3.connect(database_path)
|
|
21
|
+
tabs = tk.Frame(self)
|
|
22
|
+
tabs.pack(side="top",fill="x")
|
|
23
|
+
box = tk.Frame(self)
|
|
24
|
+
box.pack(side="top",fill="both",expand=True)
|
|
25
|
+
self.all_tables=[]
|
|
26
|
+
self.all_buttons={}
|
|
27
|
+
selector = lambda name: lambda: self.select_table(name)
|
|
28
|
+
for name,title,fields in [
|
|
29
|
+
("Customers","Заказчики",[
|
|
30
|
+
Field("id","ID",show=showid,primary=True),
|
|
31
|
+
Field("name","ФИО / Организация"),
|
|
32
|
+
Field("inn","ИНН"),
|
|
33
|
+
Field("addres","Адрес"),
|
|
34
|
+
Field("phone","Телефон"),
|
|
35
|
+
Field("salesman","Продавец?",show=showbool),
|
|
36
|
+
Field("buyer","Покупатель?",show=showbool),
|
|
37
|
+
]),
|
|
38
|
+
("Goods","Товары",[
|
|
39
|
+
Field("id","ID",show=showid,primary=True),
|
|
40
|
+
Field("name","Наименование",multiply=2.5),
|
|
41
|
+
Field("price_for_unit","Цена за ед."),
|
|
42
|
+
Field("unit","Ед.изм."),
|
|
43
|
+
]),
|
|
44
|
+
]:
|
|
45
|
+
self.all_tables.append(Table(conn,box,name,fields))
|
|
46
|
+
self.all_buttons[name]=tk.Button(tabs,text=title,command=selector(name))
|
|
47
|
+
self.all_buttons[name].pack(side="left")
|
|
48
|
+
self.select_table(self.all_tables[0].name)
|
|
49
|
+
def select_table(self,name):
|
|
50
|
+
res=[t for t in self.all_tables if t.name==name]
|
|
51
|
+
if len(res)!=1: return
|
|
52
|
+
table=res[0]
|
|
53
|
+
for v in self.all_tables:
|
|
54
|
+
v.pack_forget()
|
|
55
|
+
for k,v in self.all_buttons.items():
|
|
56
|
+
v.config(relief="raised")
|
|
57
|
+
self.all_buttons[table.name].config(relief="sunken")
|
|
58
|
+
table.pack(fill="both",expand=True)
|
|
59
|
+
def example_main():
|
|
60
|
+
database=op.join(op.dirname(__file__),"__main__.db")
|
|
61
|
+
ExampleApp(database).mainloop()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__=="__main__": example_main()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import tkinter as tk,json
|
|
2
|
+
from tkinter import ttk
|
|
3
|
+
from tkinter import messagebox as mb
|
|
4
|
+
from tkinter import simpledialog as sd
|
|
5
|
+
from tkinter import filedialog as fd
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
def q(s): return json.dumps(s,ensure_ascii=False)
|
|
9
|
+
@dataclass
|
|
10
|
+
class Field:
|
|
11
|
+
name:str
|
|
12
|
+
title:str
|
|
13
|
+
show:object = str
|
|
14
|
+
primary:bool = False
|
|
15
|
+
width:int = 0
|
|
16
|
+
multiply:float = 1
|
|
17
|
+
class Table(tk.Frame):
|
|
18
|
+
def __init__(self,conn,master,name,fields):
|
|
19
|
+
self.conn = conn
|
|
20
|
+
self.name = name
|
|
21
|
+
self.fields = fields
|
|
22
|
+
super().__init__(master)
|
|
23
|
+
self.buttons = tk.Frame(self)
|
|
24
|
+
self.buttons.pack(side="bottom",fill="x")
|
|
25
|
+
for name,side,cmd in [
|
|
26
|
+
("Создать","left",self.ui_create),
|
|
27
|
+
("Изменить","left",self.ui_edit),
|
|
28
|
+
("Удалить","left",self.ui_delete),
|
|
29
|
+
("Импорт из JSON","right",self.ui_import_json),
|
|
30
|
+
("Импорт из Excel","right",self.ui_import_excel),
|
|
31
|
+
("Экспорт в JSON","right",self.ui_export_json),
|
|
32
|
+
("Экспорт в Excel","right",self.ui_export_excel),
|
|
33
|
+
]: tk.Button(self.buttons,text=name,command=cmd).pack(side=side)
|
|
34
|
+
self.tree = ttk.Treeview(self,columns=[f.name for f in self.fields],show="headings")
|
|
35
|
+
self.tree.pack(side="bottom",fill="both",expand=True)
|
|
36
|
+
for field in fields:
|
|
37
|
+
self.tree.column(field.name,width=field.width or int(max(30,len(field.title)*8)*field.multiply))
|
|
38
|
+
self.tree.heading(field.name,text=field.title)
|
|
39
|
+
self.update()
|
|
40
|
+
def update(self):
|
|
41
|
+
self.tree.delete(*self.tree.get_children())
|
|
42
|
+
for raw in self.conn.execute(f"SELECT * FROM {q(self.name)}").fetchall():
|
|
43
|
+
values = [e.show(self,e,raw[i]) for i,e in enumerate(self.fields)]
|
|
44
|
+
self.tree.insert("","end",values=values)
|
|
45
|
+
def ui_create(self): pass
|
|
46
|
+
def ui_create(self): pass
|
|
47
|
+
def ui_edit(self): pass
|
|
48
|
+
def ui_delete(self): pass
|
|
49
|
+
def ui_import_json(self): pass
|
|
50
|
+
def ui_import_excel(self):
|
|
51
|
+
file = fd.askopenfile(title="Имортировать файл",filetypes=[
|
|
52
|
+
("Таблицы","*.xlsx","*.xls","*.csv"),
|
|
53
|
+
("Все файлы","*"),
|
|
54
|
+
])
|
|
55
|
+
def ui_export_json(self): pass
|
|
56
|
+
def ui_export_excel(self): pass
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
#
|
{python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/SOURCES.txt
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
pyproject.toml
|
|
2
2
|
python_simpletables/__init__.py
|
|
3
|
+
python_simpletables/__main__.py
|
|
3
4
|
python_simpletables/app.py
|
|
4
|
-
python_simpletables/example.py
|
|
5
5
|
python_simpletables/table.py
|
|
6
6
|
python_simpletables.egg-info/PKG-INFO
|
|
7
7
|
python_simpletables.egg-info/SOURCES.txt
|
|
8
8
|
python_simpletables.egg-info/dependency_links.txt
|
|
9
|
+
python_simpletables.egg-info/requires.txt
|
|
9
10
|
python_simpletables.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pandas
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import os,os.path as op,re,json,sqlite3,tkinter as tk
|
|
2
|
-
from tkinter import ttk
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ExampleApp(tk.Tk):
|
|
6
|
-
def __init__(self,database_path):
|
|
7
|
-
super().__init__()
|
|
8
|
-
self.geometry("600x480")
|
|
9
|
-
conn = sqlite3.connect(database_path)
|
|
10
|
-
tabs = tk.Frame(self)
|
|
11
|
-
tabs.pack(side="top",fill="x")
|
|
12
|
-
box = tk.Frame(self)
|
|
13
|
-
box.pack(side="top",fill="both",expand=True)
|
|
14
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import tkinter as tk,json
|
|
2
|
-
from tkinter import ttk
|
|
3
|
-
|
|
4
|
-
def q(s): return json.dumps(s,ensure_ascii=False)
|
|
5
|
-
class Table(tk.Frame):
|
|
6
|
-
def __init__(self,conn,master,name,fields):
|
|
7
|
-
super().__init__(master)
|
|
8
|
-
tk.Label(self,text=name).pack(side="top",fill="x")
|
|
9
|
-
self.tree = ttk.Treeview(self,columns=[f.name for f in self.fields],show="headings")
|
|
10
|
-
self.tree.pack(side="top",fill="both",expand=True)
|
|
11
|
-
self.buttons = tk.Frame(self)
|
|
12
|
-
self.buttons.pack(side="bottom",fill="x")
|
|
13
|
-
for name,side,cmd in [
|
|
14
|
-
("Создать","left",self.ui_create),
|
|
15
|
-
("Изменить","left",self.ui_edit),
|
|
16
|
-
("Удалить","left",self.ui_delete),
|
|
17
|
-
("Импорт из JSON","right",self.ui_import_json),
|
|
18
|
-
("Импорт из Excel","right",self.ui_import_excel),
|
|
19
|
-
("Экспорт в JSON","right",self.ui_export_json),
|
|
20
|
-
("Экспорт в Excel","right",self.ui_export_excel),
|
|
21
|
-
]: tk.Button().pack(side=side)
|
|
22
|
-
self.update()
|
|
23
|
-
def update(self):
|
|
24
|
-
conn.execute(f"SELECT * FROM {q(self.name)}")
|
|
25
|
-
def ui_create(self): pass
|
|
26
|
-
def ui_create(self): pass
|
|
27
|
-
def ui_edit(self): pass
|
|
28
|
-
def ui_delete(self): pass
|
|
29
|
-
def ui_import_json(self): pass
|
|
30
|
-
def ui_import_excel(self): pass
|
|
31
|
-
def ui_export_json(self): pass
|
|
32
|
-
def ui_export_excel(self): pass
|
|
33
|
-
|
|
34
|
-
class Example(tk.Tk):
|
|
35
|
-
def __init__(self,database_path):
|
|
36
|
-
super().__init__()
|
|
37
|
-
self.geometry("600x480")
|
|
38
|
-
self.conn = sqlite3.connect(database_path)
|
|
39
|
-
tabs = tk.Frame(self)
|
|
40
|
-
tabs.pack(side="top",fill="x")
|
|
41
|
-
box = tk.Frame(self)
|
|
42
|
-
box.pack(side="top",fill="both",expand=True)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
#
|
|
File without changes
|
|
File without changes
|
{python_simpletables-0.1.26 → python_simpletables-0.1.27}/python_simpletables.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|