def open_db(self): self.openedDb = open_db_file(self) if (self.openedDb != ''): if createConnection(self, self.openedDb): if (self.fileIsOpened == False): self.loadWidgets() self.fileIsOpened = True
def main(): import sys app = QApplication(sys.argv) if not createConnection(): sys.exit(-1) editor = TableEditor("person") editor.show() sys.exit(app.exec_())
def main(): import sys app = QApplication(sys.argv) if not createConnection(): sys.exit(-1) view = View("items", "images") view.show() sys.exit(app.exec_())
def createInitialRecord(): sheet = connection.createConnection() studentNames = [ 'Abhishek', 'Aditya', 'Akansha', 'Akashnil', 'Akshay', 'Ameya', 'Anisha', 'Aravind', 'Basu', 'Divyanshu', 'Ganguly', 'Ghayathri', 'Hannan', 'Hitesh', 'Jay', 'Jayashree', 'Manral', 'Mayank', 'Mohan', 'Mohit', 'Moumi', 'Moumita', 'Prateek', 'Pratik C', 'Praveen', 'Priyanka', 'Rahul', 'Rajarshi', 'Satendra', 'Shikhar', 'Shiladitya', 'Soorma', 'Soumya Banerjee', 'Soumya Kartik', 'Souvick', 'Sreetama', 'Vipul', 'Vivek John', 'Vivek Kumar' ] index = 2 for i in range(len(studentNames)): raw_data = [studentNames[i], "0"] sheet.insert_row(raw_data, index) index += 1
#!/usr/bin/env python #coding=utf-8 ''' FileName : main.py ''' import sys from PyQt4.QtCore import QTextCodec from PyQt4.QtGui import QApplication from connection import createConnection from mainwindow import MainWindow if __name__ == "__main__": app = QApplication(sys.argv) # 这行代码要写在创建连接之前, 不然,数据库中文乱码 QTextCodec.setCodecForTr(QTextCodec.codecForName("UTF-8")) QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8")) if not createConnection(): raise Exception("createConnection faild") win = MainWindow() win.show() app.exec_()
query.exec_("create table city(id int, name varchar(20))") query.exec_("insert into city values(100, 'San Jose')") query.exec_("insert into city values(5000, 'Oslo')") query.exec_("insert into city values(80000, 'Munich')") query.exec_("create table country(id int, name varchar(20))") query.exec_("insert into country values(41, 'USA')") query.exec_("insert into country values(47, 'Norway')") query.exec_("insert into country values(49, 'Germany')") if __name__ == '__main__': import sys app = QApplication(sys.argv) if not connection.createConnection(): sys.exit(1) createRelationalTables() model = QSqlRelationalTableModel() initializeModel(model) view = createView("Relational Table Model", model) view.show() sys.exit(app.exec_())
if __name__ == "__main__": app = QtGui.QApplication(sys.argv) LANG = locale.getdefaultlocale ()[0][0:2] translator = QtCore.QTranslator () translator.load (":%s" % (os.path.join("resources", "lang", "kolombo_%s" % LANG))) app.installTranslator (translator) app.setOrganizationName ("AgarSoft") app.setOrganizationDomain ("kolombo.berlios.de") app.setApplicationName ("kolombo") settings = QtCore.QSettings () databaseConfigured = settings.value ("DataBase/config", QtCore.QVariant(False)).toBool() if not databaseConfigured: configDialog = firstRunDialog () configDialog.setSettings (settings) if configDialog.exec_() != QtGui.QDialog.Accepted: sys.exit(1) database = settings.value ("DataBase/database", QtCore.QVariant ("data.db")).toString() db_filename = os.path.abspath(str(database)) if not connection.createConnection(db_filename): sys.exit(1) mainWindow = kolomboMainWindow () mainWindow.show () sys.exit(app.exec_())
app = QtGui.QApplication(sys.argv) LANG = locale.getdefaultlocale()[0][0:2] translator = QtCore.QTranslator() translator.load(":%s" % (os.path.join("resources", "lang", "kolombo_%s" % LANG))) app.installTranslator(translator) app.setOrganizationName("AgarSoft") app.setOrganizationDomain("kolombo.berlios.de") app.setApplicationName("kolombo") settings = QtCore.QSettings() databaseConfigured = settings.value("DataBase/config", QtCore.QVariant(False)).toBool() if not databaseConfigured: configDialog = firstRunDialog() configDialog.setSettings(settings) if configDialog.exec_() != QtGui.QDialog.Accepted: sys.exit(1) database = settings.value("DataBase/database", QtCore.QVariant("data.db")).toString() db_filename = os.path.abspath(str(database)) if not connection.createConnection(db_filename): sys.exit(1) mainWindow = kolomboMainWindow() mainWindow.show() sys.exit(app.exec_())
import connection import json, ast import initialStudentRecord import faceRecognition initialStudentRecord.createInitialRecord() sheet = connection.createConnection() index = 2 allRecord = sheet.get_all_records() print('allrecord:', allRecord) allRecordWithoutUnicode = ast.literal_eval(json.dumps(allRecord)) studentComesIn = faceRecognition.fetchFaces() for student in allRecordWithoutUnicode: if (str(student["name"]) in studentComesIn): sheet.update_cell(index, 2, 1) index += 1 else: index += 1 index = 0 print(studentComesIn)
def __init__(self, parent=None): """ :type self: object """ self.UserId=0 QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) actions = QActionGroup(self.ui.toolBar) actions.addAction(self.ui.actionHome) actions.addAction(self.ui.actionNotify) actions.addAction(self.ui.actionUsers) actions.addAction(self.ui.actionSettings) actions.addAction(self.ui.actionEvents) mapper = QSignalMapper(self) self.connect(self.ui.actionHome, SIGNAL('triggered()'), mapper, SLOT('map()')) self.connect(self.ui.actionNotify, SIGNAL('triggered()'), mapper, SLOT('map()')) self.connect(self.ui.actionUsers, SIGNAL('triggered()'), mapper, SLOT('map()')) self.connect(self.ui.actionEvents, SIGNAL('triggered()'), mapper, SLOT('map()')) self.connect(self.ui.actionSettings, SIGNAL('triggered()'), mapper, SLOT('map()')) mapper.setMapping(self.ui.actionHome,0) mapper.setMapping(self.ui.actionNotify,1) mapper.setMapping(self.ui.actionEvents,2) mapper.setMapping(self.ui.actionUsers,3) mapper.setMapping(self.ui.actionSettings,4) self.connect(mapper,SIGNAL("mapped(int)"),self.ui.stackedWidget,SLOT("setCurrentIndex(int)")) self.ui.actionHome.setChecked(True) self.ui.stackedWidget.setCurrentIndex(0) self.timer_Widget() #----AudioPlayer- self.output = Phonon.AudioOutput(Phonon.MusicCategory,self) self.m_media = Phonon.MediaObject(self) self.ui.volumeSlider.setAudioOutput(self.output) self.ui.seekSlider.setMediaObject(self.m_media) Phonon.createPath(self.m_media,self.output) #--------------- if not connection.createConnection(): sys.exit(1) self.ui.frame_cs.hide() self.ui.graphicsView.horizontalScrollBar().setValue(900) self.initGraphics() self.CreateTableEvent() self.InitUserPage() self.ui.splitter.setStretchFactor(0,1) self.ui.splitter.setSizes([0]) #self.ui.groupBox.hide() self.SaveEvent('СТАРТ системы',-1,0,self.UserId,-1,-1) self.x305Read=x305Thread("COM7",1900,0.1) self.x305Read.notifyProgress.connect(self.setAlarm) self.x305Read.start()
def createView(title, model): view = QtGui.QTableView() view.setModel(model) view.setWindowTitle(title) return view if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) # if not connection.createConnection(): # sys.exit(1) db = connection.createConnection() if not db: sys.exit(1) model = QtSql.QSqlTableModel(None, db) initializeModel(model) view1 = createView("Table Model (View 1)", model) view2 = createView("Table Model (View 2)", model) view1.show() view2.move(view1.x() + view1.width() + 20, view1.y()) view2.show() sys.exit(app.exec_())
from connection import createConnection connector = createConnection()