Added icons.
Added tableview for selected data
2
dm.py
|
@ -29,7 +29,7 @@ def createTables(tbl_list):
|
|||
x = x + 1
|
||||
qwery_create = qwery_create + index + ");"
|
||||
|
||||
#print(qwery_create)
|
||||
print(qwery_create)
|
||||
i = i + 1
|
||||
return tbl_names_list
|
||||
|
||||
|
|
131
gui.py
|
@ -5,18 +5,29 @@ import sys
|
|||
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QFrame,
|
||||
QSplitter, QStyleFactory, QApplication)
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication, QListView, QListWidget, QTableWidget , QTableView
|
||||
from PyQt5.QtWidgets import QMainWindow, QTextEdit, QAction, QApplication, QListView, QListWidget, QTableWidget , QTableView, QTableWidgetItem
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5 import QtSql
|
||||
from PyQt5.QtSql import *
|
||||
import pymysql
|
||||
import dm
|
||||
|
||||
conn = pymysql.connect(
|
||||
db='ats',
|
||||
user='dba',
|
||||
passwd='AlsprofilinE',
|
||||
host='kis',
|
||||
charset='utf8')
|
||||
c = conn.cursor()
|
||||
|
||||
class MainWin(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.initUI()
|
||||
|
||||
#заглушка
|
||||
def qqqq(self):
|
||||
print("ddddddddd")
|
||||
|
||||
def initUI(self):
|
||||
|
||||
|
@ -25,27 +36,99 @@ class MainWin(QMainWindow):
|
|||
self.setCentralWidget(splitter)
|
||||
#self.setCentralWidget(textEdit)
|
||||
|
||||
exitAction = QAction(QIcon('img/close.gif'), 'Выход', self)
|
||||
newAction = QAction(QIcon('img/new.gif'), 'Добавить', self)
|
||||
newAction.setShortcut('Ins')
|
||||
newAction.setStatusTip('Добавить')
|
||||
newAction.triggered.connect(self.qqqq)
|
||||
|
||||
deleteAction = QAction(QIcon('img/delete.gif'), 'Удалить', self)
|
||||
deleteAction.setShortcut('Del')
|
||||
deleteAction.setStatusTip('Удалить')
|
||||
deleteAction.triggered.connect(self.qqqq)
|
||||
|
||||
exitAction = QAction(QIcon('img/exit.gif'), 'Выход', self)
|
||||
exitAction.setShortcut('Ctrl+Q')
|
||||
exitAction.setStatusTip('Выход')
|
||||
exitAction.triggered.connect(self.close)
|
||||
|
||||
cutAction = QAction(QIcon('img/cut.gif'), 'Вырезать', self)
|
||||
cutAction.setShortcut('Ctrl+X')
|
||||
cutAction.setStatusTip('Вырезать')
|
||||
#cutAction.triggered.connect(self.close)
|
||||
|
||||
copyAction = QAction(QIcon('img/copy.gif'), 'Копировать', self)
|
||||
copyAction.setShortcut('Ctrl+С')
|
||||
copyAction.setStatusTip('Копировать')
|
||||
#copyAction.triggered.connect(self.close)
|
||||
|
||||
pasteAction = QAction(QIcon('img/paste.gif'), 'Вставить', self)
|
||||
pasteAction.setShortcut('Ctrl+V')
|
||||
pasteAction.setStatusTip('Вставить')
|
||||
#pasteAction.triggered.connect(self.close)
|
||||
|
||||
findAction = QAction(QIcon('img/find.gif'), 'Копировать', self)
|
||||
findAction.setShortcut('Ctrl+F')
|
||||
findAction.setStatusTip('Искать')
|
||||
# findAction.triggered.connect(self.close)
|
||||
|
||||
printAction = QAction(QIcon('img/print.gif'), 'Печатать', self)
|
||||
printAction.setShortcut('Ctrl+P')
|
||||
printAction.setStatusTip('Печатать')
|
||||
# printAction.triggered.connect(self.close)
|
||||
|
||||
|
||||
self.statusBar()
|
||||
|
||||
menubar = self.menuBar()
|
||||
fileMenu = menubar.addMenu('&Файл')
|
||||
fileMenu.addAction(newAction)
|
||||
fileMenu.addAction(deleteAction)
|
||||
fileMenu.addAction(printAction)
|
||||
fileMenu.addAction(exitAction)
|
||||
|
||||
editMenu = menubar.addMenu('&Редактирование')
|
||||
editMenu.addAction(copyAction)
|
||||
editMenu.addAction(cutAction)
|
||||
editMenu.addAction(pasteAction)
|
||||
editMenu.addAction(printAction)
|
||||
|
||||
helpMenu = menubar.addMenu('&Помощь')
|
||||
|
||||
toolbar = self.addToolBar('Выход')
|
||||
toolbar.addAction(exitAction)
|
||||
#toolbar = self.addToolBar('Редактирование')
|
||||
|
||||
toolbar = self.addToolBar('Панель инструментов')
|
||||
toolbar.addAction(newAction)
|
||||
toolbar.addAction(deleteAction)
|
||||
toolbar.addAction(copyAction)
|
||||
toolbar.addAction(cutAction)
|
||||
toolbar.addAction(pasteAction)
|
||||
toolbar.addAction(findAction)
|
||||
toolbar.addAction(printAction)
|
||||
#toolbar.addAction(exitAction)
|
||||
|
||||
self.setGeometry(300, 300, 850, 650)
|
||||
self.setWindowTitle('Ацкый быдлокод')
|
||||
self.show()
|
||||
|
||||
class MyTable(QTableWidget):
|
||||
def __init__(self, thestruct, *args):
|
||||
QTableWidget.__init__(self, *args)
|
||||
self.data = thestruct
|
||||
self.setmydata()
|
||||
|
||||
def setmydata(self):
|
||||
n = 0
|
||||
|
||||
for key in self.data:
|
||||
#print(key)
|
||||
m = 0
|
||||
for item in key:
|
||||
#print(item)
|
||||
newitem = QTableWidgetItem(item)
|
||||
self.setItem(m, n, newitem)
|
||||
n += 1
|
||||
m += 1
|
||||
|
||||
|
||||
class WorkArea(QWidget):
|
||||
|
||||
|
@ -81,22 +164,34 @@ class WorkArea(QWidget):
|
|||
listTablesWidget.addItem(i)
|
||||
|
||||
# заполняем правый список данными из выбранной таблицы
|
||||
def addList(tbl_name):
|
||||
# модель для таблицы
|
||||
#model = QtSql.QSqlQueryModel(parent=None)
|
||||
#qwery = "SELECT * FROM " + tbl_name
|
||||
#model.setQuery(qwery)
|
||||
#tablesDataWidget.setModel(model)
|
||||
def addData(tbl_name):
|
||||
qwery = "SELECT * FROM " + tbl_name
|
||||
c.execute(qwery)
|
||||
# удаляем предыдущий виджет таблицы
|
||||
item = splitter1.widget(1)
|
||||
if item is not None:
|
||||
#print(item)
|
||||
item.deleteLater()
|
||||
|
||||
#tablesDataWidget.setWindowTitle("ddd ddd")
|
||||
#tablesDataWidget.show()
|
||||
for j in dm.selectData(tbl_name):
|
||||
print(j)
|
||||
#tablesDataWidget.addItem(j)
|
||||
#tablesDataWidget.deleteLater()
|
||||
# rows = message.count('id') # считает количество строк в таблице
|
||||
# print(c.fetchall())
|
||||
data = c.fetchall()
|
||||
# проверка на наличие записей в таблице
|
||||
if data:
|
||||
# количество строк
|
||||
rows = len(data)
|
||||
# КОЛИЧЕСТВО КОЛОНОК
|
||||
cols = len(data[0])
|
||||
table = MyTable(data, rows, cols)
|
||||
table.setFrameShape(QFrame.StyledPanel)
|
||||
splitter1.addWidget(table)
|
||||
#table.show()
|
||||
#sys.exit(app.exec_())
|
||||
|
||||
# обработка нажатия мышой на списке
|
||||
#listTablesWidget.itemClicked.connect(lambda: dm.selectData(listTablesWidget.currentItem))
|
||||
listTablesWidget.itemClicked.connect(lambda: addList(listTablesWidget.model().data(listTablesWidget.currentIndex())))
|
||||
listTablesWidget.itemClicked.connect(lambda: addData(listTablesWidget.model().data(listTablesWidget.currentIndex())))
|
||||
|
||||
|
||||
def onChanged(self, text):
|
||||
|
|
BIN
img/archive.gif
Normal file
After Width: | Height: | Size: 399 B |
BIN
img/back.gif
Normal file
After Width: | Height: | Size: 613 B |
BIN
img/copy.gif
Normal file
After Width: | Height: | Size: 297 B |
BIN
img/cut.gif
Normal file
After Width: | Height: | Size: 360 B |
BIN
img/delete.gif
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
img/exit.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
img/find.gif
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
img/forward.gif
Normal file
After Width: | Height: | Size: 625 B |
BIN
img/help.gif
Normal file
After Width: | Height: | Size: 777 B |
BIN
img/new.gif
Normal file
After Width: | Height: | Size: 279 B |
BIN
img/open.gif
Normal file
After Width: | Height: | Size: 737 B |
BIN
img/paste.gif
Normal file
After Width: | Height: | Size: 360 B |
BIN
img/pdf.gif
Normal file
After Width: | Height: | Size: 515 B |
BIN
img/pdf_preview.gif
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
img/print.gif
Normal file
After Width: | Height: | Size: 344 B |
BIN
img/refresh.gif
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
img/save.gif
Normal file
After Width: | Height: | Size: 262 B |
BIN
img/save_all.gif
Normal file
After Width: | Height: | Size: 318 B |
BIN
img/save_as.gif
Normal file
After Width: | Height: | Size: 708 B |
BIN
img/table.gif
Normal file
After Width: | Height: | Size: 127 B |
BIN
img/top.gif
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
img/undo.gif
Normal file
After Width: | Height: | Size: 478 B |
41
tables.json
|
@ -88,6 +88,47 @@
|
|||
"autoIncrement": "no"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "address",
|
||||
"tableDescription": "Список адресов",
|
||||
"fieldList": [
|
||||
{
|
||||
"fName": "id",
|
||||
"fDescr": "Номер п.п.",
|
||||
"fType": "int(6)",
|
||||
"index": "PRIMARY KEY",
|
||||
"autoIncrement": "yes"
|
||||
},
|
||||
{
|
||||
"fName": "region",
|
||||
"fDescr": "Регион",
|
||||
"fType": "varchar(100)",
|
||||
"index": "yes",
|
||||
"autoIncrement": "no"
|
||||
},
|
||||
{
|
||||
"fName": "city",
|
||||
"fDescr": "Населеннй пункт",
|
||||
"fType": "varchar(200)",
|
||||
"index": "no",
|
||||
"autoIncrement": "no"
|
||||
},
|
||||
{
|
||||
"fName": "street",
|
||||
"fDescr": "Улица",
|
||||
"fType": "varchar(100)",
|
||||
"index": "no",
|
||||
"autoIncrement": "no"
|
||||
},
|
||||
{
|
||||
"fName": "house",
|
||||
"fDescr": "Дом",
|
||||
"fType": "char(6)",
|
||||
"index": "no",
|
||||
"autoIncrement": "no"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|