Added icons.

Added tableview for selected data
This commit is contained in:
Sergey Kalinin 2017-03-14 14:09:31 +03:00
parent bc20135cc1
commit 5c26c1b898
25 changed files with 155 additions and 19 deletions

2
dm.py
View File

@ -29,7 +29,7 @@ def createTables(tbl_list):
x = x + 1 x = x + 1
qwery_create = qwery_create + index + ");" qwery_create = qwery_create + index + ");"
#print(qwery_create) print(qwery_create)
i = i + 1 i = i + 1
return tbl_names_list return tbl_names_list

131
gui.py
View File

@ -5,18 +5,29 @@ import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QFrame, from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QFrame,
QSplitter, QStyleFactory, QApplication) QSplitter, QStyleFactory, QApplication)
from PyQt5.QtCore import Qt 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.QtGui import QIcon
from PyQt5 import QtSql from PyQt5.QtSql import *
import pymysql
import dm import dm
conn = pymysql.connect(
db='ats',
user='dba',
passwd='AlsprofilinE',
host='kis',
charset='utf8')
c = conn.cursor()
class MainWin(QMainWindow): class MainWin(QMainWindow):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.initUI() self.initUI()
#заглушка
def qqqq(self):
print("ddddddddd")
def initUI(self): def initUI(self):
@ -25,27 +36,99 @@ class MainWin(QMainWindow):
self.setCentralWidget(splitter) self.setCentralWidget(splitter)
#self.setCentralWidget(textEdit) #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.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Выход') exitAction.setStatusTip('Выход')
exitAction.triggered.connect(self.close) 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() self.statusBar()
menubar = self.menuBar() menubar = self.menuBar()
fileMenu = menubar.addMenu('&Файл') fileMenu = menubar.addMenu('&Файл')
fileMenu.addAction(newAction)
fileMenu.addAction(deleteAction)
fileMenu.addAction(printAction)
fileMenu.addAction(exitAction) fileMenu.addAction(exitAction)
editMenu = menubar.addMenu('&Редактирование') editMenu = menubar.addMenu('&Редактирование')
editMenu.addAction(copyAction)
editMenu.addAction(cutAction)
editMenu.addAction(pasteAction)
editMenu.addAction(printAction)
helpMenu = menubar.addMenu('&Помощь') helpMenu = menubar.addMenu('&Помощь')
toolbar = self.addToolBar('Выход') #toolbar = self.addToolBar('Редактирование')
toolbar.addAction(exitAction)
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.setGeometry(300, 300, 850, 650)
self.setWindowTitle('Ацкый быдлокод') self.setWindowTitle('Ацкый быдлокод')
self.show() 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): class WorkArea(QWidget):
@ -81,22 +164,34 @@ class WorkArea(QWidget):
listTablesWidget.addItem(i) listTablesWidget.addItem(i)
# заполняем правый список данными из выбранной таблицы # заполняем правый список данными из выбранной таблицы
def addList(tbl_name): def addData(tbl_name):
# модель для таблицы qwery = "SELECT * FROM " + tbl_name
#model = QtSql.QSqlQueryModel(parent=None) c.execute(qwery)
#qwery = "SELECT * FROM " + tbl_name # удаляем предыдущий виджет таблицы
#model.setQuery(qwery) item = splitter1.widget(1)
#tablesDataWidget.setModel(model) if item is not None:
#print(item)
item.deleteLater()
#tablesDataWidget.setWindowTitle("ddd ddd") #tablesDataWidget.deleteLater()
#tablesDataWidget.show() # rows = message.count('id') # считает количество строк в таблице
for j in dm.selectData(tbl_name): # print(c.fetchall())
print(j) data = c.fetchall()
#tablesDataWidget.addItem(j) # проверка на наличие записей в таблице
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: 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): def onChanged(self, text):

BIN
img/archive.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

BIN
img/back.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

BIN
img/copy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

BIN
img/cut.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

BIN
img/delete.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
img/exit.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
img/find.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
img/forward.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

BIN
img/help.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

BIN
img/new.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

BIN
img/open.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

BIN
img/paste.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

BIN
img/pdf.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

BIN
img/pdf_preview.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
img/print.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

BIN
img/refresh.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/save.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

BIN
img/save_all.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
img/save_as.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

BIN
img/table.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

BIN
img/top.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
img/undo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

View File

@ -88,6 +88,47 @@
"autoIncrement": "no" "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"
}
]
} }
] ]
} }