def import_xrc(self, event): import xrc2wxg, cStringIO if not self.ask_save(): return infile = misc.FileSelector(_("Import file"), wildcard="XRC files (*.xrc)" "|*.xrc|All files|*", flags=wx.OPEN | wx.FILE_MUST_EXIST, default_path=self.cur_dir) if infile: buf = cStringIO.StringIO() try: xrc2wxg.convert(infile, buf) buf.seek(0) self._open_app(buf, is_filelike=True) common.app_tree.app.saved = False except Exception, msg: import traceback traceback.print_exc() wx.MessageBox(_("An exception occurred while importing file " "\"%s\".\nThis is the error message associated " "with it:\n %s\n" "For more details, look at the full traceback " "on the console.\nIf you think this is a " "wxGlade bug, please report it.") % \ (infile, msg), _("Error"), wx.OK|wx.CENTRE|wx.ICON_ERROR)
def import_xrc(self, event): import xrc2wxg, cStringIO if not self.ask_save(): return infile = misc.FileSelector(_("Import file"), wildcard="XRC files (*.xrc)" "|*.xrc|All files|*", flags=wx.OPEN|wx.FILE_MUST_EXIST, default_path=self.cur_dir) if infile: buf = cStringIO.StringIO() try: xrc2wxg.convert(infile, buf) buf.seek(0) self._open_app(buf, is_filelike=True) common.app_tree.app.saved = False except Exception, msg: import traceback; traceback.print_exc() wx.MessageBox(_("An exception occurred while importing file " "\"%s\".\nThis is the error message associated " "with it:\n %s\n" "For more details, look at the full traceback " "on the console.\nIf you think this is a " "wxGlade bug, please report it.") % \ (infile, msg), _("Error"), wx.OK|wx.CENTRE|wx.ICON_ERROR)
def import_xrc(self, infilename=None): import xrc2wxg if not self.ask_save(): return if not infilename: infilename = wx.FileSelector(_("Import file"), wildcard="XRC files (*.xrc)" "|*.xrc|All files|*", flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_path=self.cur_dir) if infilename: ibuffer = [] try: xrc2wxg.convert(infilename, ibuffer) # Convert UTF-8 returned by xrc2wxg.convert() to Unicode tmp = b"".join(ibuffer).decode('UTF-8') ibuffer = ['%s\n' % line for line in tmp.split('\n')] self._open_app(ibuffer) common.app_tree.app.saved = False except Exception as inst: fn = os.path.basename(infilename).encode('ascii', 'replace') bugdialog.Show(_('Import File "%s"') % fn, inst)
def test_missing_application_attributes(self): #"Test load wxg file w/ missing <application> attributes and generate code" "convert .xrc file with missing <application> attributes to .wxg and load it" # convert .xrc to .wxg infilename = self._get_casefile_path('app_wo_attrs_gui.xrc') generated_filename = self._get_outputfile_path('app_wo_attrs_gui.wxg') xrc2wxg.convert(infilename, generated_filename) # compare expected_filename = self._get_casefile_path('app_wo_attrs_gui.wxg') self._compare_files(expected_filename, generated_filename) # open the .wxg file; there should be no problem self._messageBox = None self.frame._open_app(generated_filename, use_progress_dialog=False, add_to_history=False) self.assertFalse(self._messageBox,'Loading test wxg file caused an error message: %s'%self._messageBox)
def test_missing_application_attributes(self): """\ Test load wxg file w/ missing <application> attributes and generate code """ fullpath = os.path.join(self.caseDirectory, 'app_wo_attrs_gui.xrc') obuffer = compat.StringIO() xrc2wxg.convert(fullpath, obuffer) generated = obuffer.getvalue().decode('UTF-8') expected = self._load_file('app_wo_attrs_gui.wxg') self._compare(expected, generated, "wxg") self._messageBox = None self._open_wxg_file(generated) self.failIf( self._messageBox, 'Loading test wxg file caused an error message: %s' % self._messageBox)