Added PyQt6 script to List Archived Channels
Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
101
epics/css/pyQt/getChannels.py
Normal file
101
epics/css/pyQt/getChannels.py
Normal file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
PyQt6 SQL App for Esther Reports
|
||||
Python version of http://esther.tecnico.ulisboa.pt/esther-php/show_report.php
|
||||
|
||||
ssh -X -t golem 'cd /home/esther/git-repos/esther-python/sql; zsh -l'
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PyQt6.QtCore import QSize, QDate, Qt
|
||||
# from PyQt6 import QtCore
|
||||
|
||||
from PyQt6.QtGui import QAction, QIcon, QPixmap # QFont
|
||||
|
||||
from PyQt6.QtSql import (
|
||||
QSqlDatabase,
|
||||
QSqlRelation,
|
||||
# QSqlRelationalDelegate,
|
||||
QSqlRelationalTableModel,
|
||||
QSqlTableModel,
|
||||
QSqlQuery,
|
||||
QSqlQueryModel,
|
||||
)
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget,
|
||||
QApplication,
|
||||
QLineEdit, QDateEdit,
|
||||
QMainWindow,
|
||||
QTableView,
|
||||
QVBoxLayout, QHBoxLayout, QGridLayout, QFormLayout,
|
||||
QDialog,
|
||||
QDialogButtonBox, QPushButton,
|
||||
QCheckBox,
|
||||
QComboBox,
|
||||
QSpinBox,
|
||||
QRadioButton,
|
||||
QLabel,
|
||||
QTableWidget, QTableWidgetItem,
|
||||
QStatusBar,
|
||||
QSlider,
|
||||
QToolBar,
|
||||
QTabWidget,
|
||||
# QSizePolicy,
|
||||
QAbstractScrollArea,
|
||||
)
|
||||
|
||||
import config as cfg
|
||||
|
||||
|
||||
db = QSqlDatabase("QPSQL")
|
||||
db.setHostName(cfg.host)
|
||||
db.setDatabaseName(cfg.database)
|
||||
db.setUserName(cfg.username)
|
||||
db.setPassword(cfg.password)
|
||||
"""
|
||||
db.open()
|
||||
|
||||
query = QSqlQuery(db=db)
|
||||
query.exec("SELECT * FROM channel")
|
||||
while (query.next()):
|
||||
print(query.value(0))
|
||||
print(query.value(1))
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
container = QWidget()
|
||||
layoutMain = QHBoxLayout()
|
||||
if not db.open():
|
||||
print("DB not openned")
|
||||
sys.exit(-1)
|
||||
|
||||
model = QSqlTableModel(db=db)
|
||||
model.setTable('channel')
|
||||
model.select()
|
||||
self.tableViewReports = QTableView()
|
||||
self.tableViewReports.setModel(model)
|
||||
layoutMain.addWidget(self.tableViewReports)
|
||||
|
||||
self.setStatusBar(QStatusBar(self))
|
||||
|
||||
container.setLayout(layoutMain)
|
||||
self.setMinimumSize(QSize(1200, 700))
|
||||
self.setCentralWidget(container)
|
||||
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
# sys.exit(app.exec())
|
||||
app.exec()
|
||||
|
||||
# vim: syntax=python ts=4 sw=4 sts=4 sr exit
|
||||
Reference in New Issue
Block a user