def onSystemStarted(self): # predefined function scalled when the core is ready self.statusBar().showMessage('Ready...', 5000) # `<>` in the beginning of the string means to treat it as HTML self.printMessage('<><b><span style="color: green">System started.</span> Welcome!</b>', True, False) print('Application directory: %s' % appDir) global db db = orm.SqliteAdapter('papp/databases/mtc.sqlite') from .reports import phone_number_search forms.openForm(phone_number_search.Form)
def setupMenu(self): super().setupMenu() #Add actions for catalogs. # http://docs.python.org/library/pkgutil.html#pkgutil.walk_packages menu = self.menu.catalogs from wic import menus catalogs = ('persons', 'locations', 'districts', 'regions', 'streets') for catalog in catalogs: modelName = catalog.capitalize() modelPath = 'papp.catalogs.' + catalog + '.' + modelName menus.addActionsToMenu(menu, ( menus.createAction(menu, modelName, lambda *args, p = modelPath: forms.openCatalogForm(p, db), icon = ':/icons/fugue/cards-address.png'), )) menu = self.menu.reports reports = ('phone_number_search', 'test', 'lissajous', 'repayment_schedule') for report in reports: reportName = report.capitalize() reportPath = 'papp.reports.' + report + '.Form' menus.addActionsToMenu(menu, ( menus.createAction(menu, reportName, lambda *args, p = reportPath: forms.openForm(p), icon = ':/icons/fugue/application-form.png'), ))
def openCatalogForm(catalogModel, db, FormClass = None, **kwargs): if isinstance(catalogModel, str): catalogModel = wic.getObjectByPath(catalogModel) assert isinstance(catalogModel, orm.ModelMeta), 'Pass a model class.' catalogModel.checkTable(db) # before opening the form if not FormClass: formModulePath = catalogModel.__module__ FormClass = getattr(sys.modules[formModulePath], 'CatalogForm', CatalogForm) assert issubclass(FormClass, CatalogForm), 'This is not a CatalogForm' kwargs['catalogModel'] = catalogModel kwargs['db'] = db return forms.openForm(FormClass, **kwargs)
def openCatalogItemForm(catalogItem, FormClass = None, **kwargs): assert isinstance(catalogItem, orm.Model), 'Pass a catalog item (CatalogModel instance).' if FormClass is None: formModulePath = catalogItem.__class__.__module__ FormClass = getattr(sys.modules[formModulePath], 'Form', None) if FormClass is None: # if user form not present - take CatalogItemForm with autogenerated widgets FormClass = CatalogItemForm _uiFilePath = '' else: _uiFilePath = FormClass._uiFilePath kwargs['_uiFilePath'] = _uiFilePath kwargs['catalogItem'] = catalogItem if not isinstance(FormClass, type) and issubclass(FormClass, CatalogItemForm): raise forms.FormNotFoundError('This is not a CatalogItemForm') return forms.openForm(FormClass, **kwargs)
def helpAbout(self): from wic.forms import openForm, help_about openForm(help_about.Form, modal = True)
def editDbInfo(self): from wic.forms import openForm, db_info openForm(db_info.Form)