def c_convert(): c = make_page_context("/convert", "AGS4 Convert") c['err_mess'] = None if request.method == "POST": if 'ags_file' not in request.files: c['err_mess'] = "Need a file" else: file = request.files['ags_file'] # if user does not select file, browser also # submit a empty part without filename if file.filename == '': c['err_mess'] = "Need a file" else: if file and allowed_file(file.filename): doc = ogt_doc.OGTDocument() doc.source_file_path = secure_filename(file.filename) err = doc.load_ags4_string(file.read()) return jsonify(doc.to_dict()) ## convert example """ if request.method == "GET": ex_name = request.args.get('example') if ex_name: ex = ags4.example(ex_name) #print "EX=", ex doc = ogt_doc.OGTDocument() doc.source_file_path = ex_name err = doc.load_ags4_string(ex['contents']) if request.args.get('format') == "json": return jsonify(doc.to_dict()) """ return render_template('convert.html', c=c)
def ags4_example(ext="html"): file_name = request.args.get('file_name') if not file_name: panic ex = ags4.example(file_name) if ex: #print "EX=", ex doc = ogt_doc.OGTDocument() doc.source_file_path = ex['file_name'] err = doc.load_ags4_string(ex['contents']) doc.edit_mode = True doc.include_stats = True doc.include_source = True #if request.args.get('format') == "json": # return jsonify(doc.to_dict()) if ext == "json": return jsonify({"document": doc.to_dict(), "success": True}) c = make_page_context("/ags4/examples", "AGS4 Widget") return render_template('ags4_example.html', c=c)
def __init__(self, parent=None, empty=False): QtGui.QWidget.__init__(self, parent) self.debug = False self.ogtDoc = None if empty: self.ogtDoc = ogt_doc.OGTDocument() self.mainLayout = xwidgets.vlayout() self.setLayout(self.mainLayout) ##====== Top Bar === self.topLay = xwidgets.hlayout() self.mainLayout.addLayout(self.topLay) ## Header Label self.lblHeader = QtGui.QLabel() self.lblHeader.setStyleSheet( "background-color: #444444; color: #dddddd; font-size: 14pt; padding: 3px 5px;" ) self.topLay.addWidget(self.lblHeader, 100) ## Add button self.buttActAdd = xwidgets.XToolButton(text="Add..", ico=Ico.Add, menu=True, popup=True) self.topLay.addWidget(self.buttActAdd) ## Import button self.buttImport = xwidgets.XToolButton(text="Import", ico=Ico.Import, menu=True, popup=True) self.topLay.addWidget(self.buttImport) self.buttImport.menu().addAction("Add default PROJ, UNIT, etc groups", self.on_add_default_groups) ## Export button self.buttExport = xwidgets.XToolButton(text="Export", ico=Ico.Export, menu=True, popup=True) self.topLay.addWidget(self.buttExport) for a in FORMATS: self.buttExport.menu().addAction("%s - TODO" % a) ## Reload button self.buttReload = xwidgets.XToolButton(text="Reload", ico=Ico.Refresh, popup=True, callback=self.on_reload) self.topLay.addWidget(self.buttReload) self.mainLayout.addSpacing(5) ##========= Content =============== ## tabar + Stack self.tabBar = QtGui.QTabBar() f = self.tabBar.font() f.setBold(True) self.tabBar.setFont(f) self.mainLayout.addWidget(self.tabBar) self.stackWidget = XStackedWidget() #QtGui.QStackedWidget() self.mainLayout.addWidget(self.stackWidget) ## Summary Tab self.tabBar.addTab(Ico.icon(Ico.Summary), "Summary") self.ogtProjSummaryWidget = OGTProjectSummaryWidget() self.stackWidget.addWidget(self.ogtProjSummaryWidget, "Project Summary") self.ogtProjSummaryWidget.sigGoto.connect(self.on_goto) self.ogtProjSummaryWidget.sigGotoSource.connect(self.on_goto_source) ## Groups Tab self.tabBar.addTab(Ico.icon(Ico.Groups), "Groups") self.ogtDocWidget = ogtgui_doc.OGTDocumentWidget() nidx = self.stackWidget.addWidget(self.ogtDocWidget, "Groups") chk = QtGui.QCheckBox() chk.setText("Show Data Count") self.stackWidget.addHeaderWidget(nidx, chk) ## Schedule Tab self.tabBar.addTab(Ico.icon(Ico.Schedule), "Schedule") self.ogtScheduleWidget = ogtgui_widgets.OGTScheduleWidget() self.stackWidget.addWidget(self.ogtScheduleWidget, "Schedule") ## Source tab self.tabBar.addTab(Ico.icon(Ico.Source), "Source") self.ogtSourceViewWidget = ogtgui_widgets.OGTSourceViewWidget() self.stackWidget.addWidget(self.ogtSourceViewWidget, "Sources") if False: self.tabBar.addTab(Ico.icon(Ico.Map), "Map") self.mapOverviewWidget = map_widgets.MapOverviewWidget() self.stackWidget.addWidget(self.mapOverviewWidget) self.tabBar.currentChanged.connect(self.on_tab_changed) if G.args.dev: self.tabBar.setCurrentIndex(1) pass