def __init__(self, *args, **kwargs): wx.html.HtmlWindow.__init__(self, *args, **kwargs) self.Printer = HtmlEasyPrinting() self.Sections = Sections if "gtk2" in wx.PlatformInfo: self.SetStandardFonts() self.Header = ( """ <HTML> <BODY> <H1>A very simple HTML page</H1> <H2>A subheading</H2> <P>Just a tiny bit of text here</P> <P><BR> </P> <P>now a link: <A HREF="http://Any.link.will.do.com/">http://Any.link.will.do.com</A></P> <P>And a tiny bit more text.</P> <P> """) self.Footer ="\n</BODY>\n</HTML>" self.Reload()
def __init__(self): wx.Frame.__init__(self, None, title='Snapshot Printer', size=(650, 400)) self.panel = wx.Panel(self) self.printer = HtmlEasyPrinting(name='Printing', parentWindow=None) self.html = HtmlWindow(self.panel) self.html.SetRelatedFrame(self, self.GetTitle()) if not os.path.exists('screenshot.htm'): self.createHtml() self.html.LoadPage('screenshot.htm') pageSetupBtn = wx.Button(self.panel, label='page setup') printBtn = wx.Button(self.panel, label='Print') cancelBtn = wx.Button(self.panel, label='Cancel') self.Bind(wx.EVT_BUTTON, self.onSetup, pageSetupBtn) self.Bind(wx.EVT_BUTTON, self.onPrint, printBtn) self.Bind(wx.EVT_BUTTON, self.onCancel, cancelBtn) sizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.html, 1, wx.GROW) btnSizer.Add(pageSetupBtn, 0, wx.ALL, 5) btnSizer.Add(printBtn, 0, wx.ALL, 5) btnSizer.Add(cancelBtn, 0, wx.ALL, 5) sizer.Add(btnSizer) self.panel.SetSizer(sizer) self.panel.SetAutoLayout(True)
def on_initialize(self, event): # if you have any initialization # including sizer setup, do it here self.printer = HtmlEasyPrinting() # self.loadConfig() self.startTitle = self.title self.newFile()
def __init__(self, parent, ID, title): """ Constructor. @since 1.0 @author C.Dutoit """ # dialog box super().__init__(parent, ID, title, DefaultPosition, Size(720, 520)) self.Center(BOTH) self.html = HtmlWindow(self, -1, DefaultPosition, Size(720, 520)) htmlFileName = resource_filename(DlgHelp.HELP_PKG_NAME, 'index.html') self.html.LoadPage(htmlFileName) self.printer = HtmlEasyPrinting() self.box = BoxSizer(VERTICAL) self.box.Add(self.html, 1, GROW) subbox = BoxSizer(HORIZONTAL) btn = Button(self, ID_BACK, _("Back")) self.Bind(EVT_BUTTON, self.__OnBack, id=ID_BACK) subbox.Add(btn, 1, GROW | ALL, 2) btn = Button(self, ID_FORWARD, _("Forward")) self.Bind(EVT_BUTTON, self.__OnForward, id=ID_FORWARD) subbox.Add(btn, 1, GROW | ALL, 2) btn = Button(self, ID_PRINT, _("Print")) self.Bind(EVT_BUTTON, self.__OnPrint, id=ID_PRINT) subbox.Add(btn, 1, GROW | ALL, 2) btn = Button(self, ID_VIEW_SOURCE, _("View Source")) self.Bind(EVT_BUTTON, self.__OnViewSource, id=ID_VIEW_SOURCE) subbox.Add(btn, 1, GROW | ALL, 2) btn = Button(self, ID_OK, _("Exit")) subbox.Add(btn, 1, GROW | ALL, 2) self.box.Add(subbox, 0, GROW | BOTTOM) self.SetSizer(self.box) self.SetAutoLayout(True) subbox.Fit(self) self.box.Fit(self) self.OnShowDefault(None) self.Show(True)
def print_list(self, event=None): #html = '''<style type=\"text/css\">td{{font-family:Arial; color:black; font-size:8pt;}}</style> # {}<table border="1" cellspacing="0"><tr>\n'''.format(header) html = '''<table border="1" cellspacing="0"><tr>\n''' #write out headers for index, col in enumerate(range(self.GetColumnCount())): html += u'''<th align="left" valign="top">{}</th>\n'''.format( self.GetColumn(col).GetText()) html += '</tr>' #write out data for row in range(self.GetItemCount()): html += '<tr>' for index, col in enumerate(range(self.GetColumnCount())): html += '''<td align="left" valign="top" nowrap>{} </td>\n'''.format( self.GetItem(row, col).GetText()) html += '</tr>' html += '</table>' printer = HtmlEasyPrinting() printer.SetHeader( '{}, Printed on @DATE@, Page @PAGENUM@ of @PAGESCNT@'.format( self.printer_header).lstrip(', ')) printer.SetStandardFonts(self.printer_font_size) printer.GetPrintData().SetPaperId(self.printer_paper_type) printer.GetPrintData().SetOrientation(self.printer_paper_orientation) if self.printer_paper_margins: printer.GetPageSetupData().SetMarginTopLeft( (self.printer_paper_margins[0], self.printer_paper_margins[1])) printer.GetPageSetupData().SetMarginBottomRight( (self.printer_paper_margins[2], self.printer_paper_margins[3])) printer.PrintText(html)
def on_click_print_revisions(event): notebook = ctrl(General.app.main_frame, 'notebook:revisions') item_entries = [] for index in range(notebook.GetPageCount()): item_entries.append(notebook.GetPageText(index).strip().split(' ')[0]) cursor = Database.connection.cursor() for item in item_entries: column_names = Database.get_table_column_names('revisions', presentable=True) revisions = cursor.execute( 'SELECT * FROM revisions WHERE item = \'{}\''.format( item)).fetchall() if revisions == None: continue # Revisions for Item Number: {} # <hr> html_to_print = '''<style type=\"text/css\">td{{font-family:Arial; color:black; font-size:8pt;}}</style> <table border="1" cellspacing="0"><tr> '''.format(item) blacklisted_columns = ['dollars_reconciled', 'related_ecr'] for column_name in column_names: if column_name.replace(' ', '_').lower() not in blacklisted_columns: html_to_print += '<th align=\"right\" valign=\"top\">{}</th>'.format( column_name.replace(' ', ' ')) html_to_print += '</tr>' for revision in revisions: html_to_print += '<tr>' for index, column_value in enumerate(revision): if column_names[index].replace( ' ', '_').lower() not in blacklisted_columns: if column_names[index] == 'When Revised': column_value = General.format_date_nicely(column_value) if column_names[index] != 'Description': column_value = str(column_value).replace(' ', ' ') html_to_print += '<td align=\"left\" valign=\"top\">{}</td>'.format( column_value) html_to_print += '</tr>' html_to_print += '</table>' printer = HtmlEasyPrinting() printer.GetPrintData().SetPaperId(wx.PAPER_LETTER) printer.GetPrintData().SetOrientation(wx.LANDSCAPE) printer.SetStandardFonts(9) printer.GetPageSetupData().SetMarginTopLeft((0, 0)) printer.GetPageSetupData().SetMarginBottomRight((0, 0)) printer.PrintText(html_to_print)
def on_initialize(self, event): self.initSizers() self.setDefaultStyles() # KEA 2002-05-08 # wxFileHistory isn't wrapped, so use raw wxPython # the file history is not actually saved when you quit # or shared between windows right now # also the file list gets appended to the File menu # rather than going in front of the Exit menu # I suspect I have to add the Exit menu after the file history # which means changing how the menus in resources are loaded # so I'll do that later self.fileHistory = wx.FileHistory() fileMenu = self.GetMenuBar().GetMenu(0) self.fileHistory.UseMenu(fileMenu) wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.OnFileHistory) self.lastStatus = None self.lastPos = None #self.configPath = os.path.abspath(os.curdir) self.configPath = os.path.join(configuration.homedir, 'codeeditor') self.loadConfig() self.cmdLineArgs = { 'debugmenu': False, 'logging': False, 'messagewatcher': False, 'namespaceviewer': False, 'propertyeditor': False, 'shell': False, 'otherargs': '' } self.lastFind = { 'searchText': '', 'replaceText': '', 'wholeWordsOnly': False, 'caseSensitive': False } self.startTitle = self.title if len(sys.argv) > 1: # accept a file argument on the command-line filename = os.path.abspath(sys.argv[1]) log.info('codeEditor filename: ' + filename) if not os.path.exists(filename): filename = os.path.abspath( os.path.join(self.application.startingDirectory, sys.argv[1])) #print filename if os.path.isfile(filename): self.openFile(filename) # the second argument can be a line number to jump to # this is experimental, but a nice feature # KEA 2002-05-01 # gotoLine causes the Mac to segfault if (len(sys.argv) > 2): try: line = int(sys.argv[2]) self.gotoLine(line) except: pass else: self.newFile() else: self.newFile() self.printer = HtmlEasyPrinting() # KEA 2002-05-08 # wxSTC defaults will eventually be settable via a dialog # and saved in a user config, perhaps compatible with IDLE # or Pythonwin self.components.document.SetEdgeColumn(75) # KEA 2002-05-08 # the wxFindReplaceDialog is not wrapped # so this is an experiment to see how it works wx.EVT_COMMAND_FIND(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_REPLACE(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_REPLACE_ALL(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_CLOSE(self, -1, self.OnFindClose) self.visible = True self.loadShell()