def __init__(self, parent, **kwds): super(PDFViewer, self).__init__(parent, **kwds) self.SetSize((1140,700)) paneCont = self.GetContentsPane() self.buttonpanel = pdfButtonPanel(paneCont, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, 0) self.buttonpanel.SetSizerProps(expand=True) self.viewer = pdfViewer(paneCont, wx.NewId(), wx.DefaultPosition, wx.DefaultSize,wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER) self.viewer.UsePrintDirect = ``False`` self.viewer.SetSizerProps(expand=True, proportion=1) # introduce buttonpanel and viewer to each other self.buttonpanel.viewer = self.viewer self.viewer.buttonpanel = self.buttonpanel
def test_lib_pdfviewer_loadFile(self): paneCont = sc.SizedPanel(self.frame) self.buttonpanel = pdfButtonPanel(paneCont, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, 0) self.buttonpanel.SetSizerProps(expand=True) self.viewer = pdfViewer(paneCont, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER) self.viewer.SetSizerProps(expand=True, proportion=1) # introduce buttonpanel and viewer to each other self.buttonpanel.viewer = self.viewer self.viewer.buttonpanel = self.buttonpanel self.viewer.LoadFile(samplePdf) self.waitFor(500)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) hsizer = wx.BoxSizer( wx.HORIZONTAL ) vsizer = wx.BoxSizer( wx.VERTICAL ) self.buttonpanel = pdfButtonPanel(self, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, 0) vsizer.Add(self.buttonpanel, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT|wx.TOP, 5) self.viewer = pdfViewer( self, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER) vsizer.Add(self.viewer, 1, wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) loadbutton = wx.Button(self, wx.NewId(), "Load PDF file", wx.DefaultPosition, wx.DefaultSize, 0 ) vsizer.Add(loadbutton, 0, wx.ALIGN_CENTER|wx.ALL, 5) hsizer.Add(vsizer, 1, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) self.SetSizer(hsizer) self.SetAutoLayout(True) # introduce buttonpanel and viewer to each other self.buttonpanel.viewer = self.viewer self.viewer.buttonpanel = self.buttonpanel self.Bind(wx.EVT_BUTTON, self.OnLoadButton, loadbutton)
def __init__(self, parent): wx.Frame.__init__(self, parent) from wx.lib.pdfviewer import pdfViewer, pdfButtonPanel self.Maximize(True) self.parent = parent self.Bind(wx.EVT_CLOSE, self.OnCloseFrm) hsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) self.buttonpanel = pdfButtonPanel(self, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, 0) vsizer.Add(self.buttonpanel, 0, wx.GROW | wx.LEFT | wx.RIGHT | wx.TOP, 5) self.viewer = pdfViewer(self, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL | wx.SUNKEN_BORDER) vsizer.Add(self.viewer, 1, wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) loadbutton = wx.Button(self, wx.NewId(), "Load PDF file", wx.DefaultPosition, wx.DefaultSize, 0) loadbutton.SetForegroundColour((255, 0, 0)) vsizer.Add(loadbutton, 0, wx.ALIGN_CENTER | wx.ALL, 5) hsizer.Add(vsizer, 1, wx.GROW | wx.ALL, 5) self.SetSizer(hsizer) self.SetAutoLayout(True) # introduce buttonpanel and viewer to each other self.buttonpanel.viewer = self.viewer self.viewer.buttonpanel = self.buttonpanel self.Bind(wx.EVT_BUTTON, self.OnLoadButton, loadbutton) self.CenterOnParent() self.GetParent().Enable(False) self.Show(True) self.__eventLoop = wx.GUIEventLoop() self.__eventLoop.Run()
def test_lib_pdfviewer_pdfviewerButtonPanelCtor(self): bp = pdfButtonPanel(self.frame, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, 0)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Geochemical QAQC Program", pos=wx.DefaultPosition, size=wx.Size(700, 700), style=wx.DEFAULT_FRAME_STYLE) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) box = wx.BoxSizer(wx.VERTICAL) open_Proj = wx.Window.NewControlId() save_Proj = wx.Window.NewControlId() exp_Rep = wx.Window.NewControlId() std_db = wx.Window.NewControlId() open_Setting = wx.Window.NewControlId() exit_bot = wx.Window.NewControlId() self.rb = rb.RibbonBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.ribbon.RIBBON_BAR_DEFAULT_STYLE) self.Page1 = rb.RibbonPage(self.rb, wx.ID_ANY, u"MyRibbonPage", wx.NullBitmap, 0) self.file_panel = rb.RibbonPanel( self.Page1, wx.ID_ANY, wx.EmptyString, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.ribbon.RIBBON_PANEL_DEFAULT_STYLE) self.rbb1 = rb.RibbonButtonBar(self.file_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.rbb1.AddSimpleButton( open_Proj, u"Open Project", wx.Bitmap(u"img/open_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.rbb1.AddSimpleButton( save_Proj, u"Save Project", wx.Bitmap(u"img/save_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.rbb1.AddSimpleButton( exp_Rep, u"Print Report", wx.Bitmap(u"img/report_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.db_panel = rb.RibbonPanel( self.Page1, wx.ID_ANY, wx.EmptyString, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.ribbon.RIBBON_PANEL_DEFAULT_STYLE) self.rbb2 = rb.RibbonButtonBar(self.db_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.rbb2.AddSimpleButton( std_db, u"Standard Database", wx.Bitmap(u"img/database_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.exit_panel = rb.RibbonPanel( self.Page1, wx.ID_ANY, wx.EmptyString, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.lib.agw.ribbon.RIBBON_PANEL_DEFAULT_STYLE) self.rbb3 = rb.RibbonButtonBar(self.exit_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.rbb3.AddSimpleButton( open_Setting, u" Settings", wx.Bitmap(u"img/set_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.rbb3.AddSimpleButton( exit_bot, u" Exit", wx.Bitmap(u"img/exit_47.png", wx.BITMAP_TYPE_ANY), wx.EmptyString) self.rb.Realize() #Set buttom event in the Ribbon buttons self.rbb1.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.openProject, id=open_Proj) self.rbb1.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.SaveProject, id=save_Proj) self.rbb1.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.ExportReport, id=exp_Rep) self.rbb2.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.StandardDB, id=std_db) self.rbb3.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.open_Setting, None, id=open_Setting) self.rbb3.Bind(rb.EVT_RIBBONBUTTONBAR_CLICKED, self.Onclose, None, id=exit_bot) box.Add(self.rb, 0, wx.ALL | wx.EXPAND, 5) self.note = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.data_panel = wx.Panel(self.note, wx.ID_ANY, wx.DefaultPosition, wx.Size(-1, -1), 0) box1 = wx.BoxSizer(wx.HORIZONTAL) self.Datagrid = wx.grid.Grid(self.data_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) # Grid self.Datagrid.CreateGrid(100, 4) self.Datagrid.EnableEditing(True) self.Datagrid.EnableGridLines(True) self.Datagrid.EnableDragGridSize(False) self.Datagrid.SetMargins(50, 0) # Columns self.Datagrid.SetColSize(0, 100) self.Datagrid.SetColSize(1, 100) self.Datagrid.SetColSize(2, 100) self.Datagrid.SetColSize(3, 100) self.Datagrid.EnableDragColMove(False) self.Datagrid.EnableDragColSize(True) self.Datagrid.SetColLabelSize(30) self.Datagrid.SetColLabelValue(0, u"Sample ID") self.Datagrid.SetColLabelValue(1, u"Sample Type") self.Datagrid.SetColLabelValue(2, u"Duplicate") self.Datagrid.SetColLabelValue(3, u"Assay 01") #self.Datagrid.SetColLabelValue( 4, u"Assay 02" ) #self.Datagrid.SetColLabelValue( 5, u"Assay 03" ) self.Datagrid.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) # Rows self.Datagrid.EnableDragRowSize(True) self.Datagrid.SetRowLabelSize(50) self.Datagrid.SetRowLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) # Label Appearance # Cell Defaults self.Datagrid.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_TOP) box1.Add(self.Datagrid, 0, wx.ALL, 5) box2 = wx.BoxSizer(wx.VERTICAL) box2.Add((0, 0), 1, wx.EXPAND, 5) self.m_staticText2 = wx.StaticText(self.data_panel, wx.ID_ANY, u"Open Data File ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText2.Wrap(-1) box2.Add(self.m_staticText2, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.open_file = wx.BitmapButton(self.data_panel, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | 0) self.open_file.SetBitmap( wx.Bitmap(u"img/opendata_47.png", wx.BITMAP_TYPE_ANY)) box2.Add(self.open_file, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) #Set open file data function self.open_file.Bind(wx.EVT_BUTTON, self.LoadData) box2.Add((0, 0), 1, 0, 5) self.m_staticText2 = wx.StaticText(self.data_panel, wx.ID_ANY, u"Clear Data ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText2.Wrap(-1) box2.Add(self.m_staticText2, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.clear_datagrid = wx.BitmapButton(self.data_panel, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | 0) self.clear_datagrid.SetBitmap( wx.Bitmap(u"img/trash_47.png", wx.BITMAP_TYPE_ANY)) box2.Add(self.clear_datagrid, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) #Set open file data function self.clear_datagrid.Bind(wx.EVT_BUTTON, self.clear_DataGrid) box2.Add((0, 0), 1, 0, 5) self.m_sline = wx.StaticLine(self.data_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) box2.Add(self.m_sline, 0, wx.EXPAND | wx.ALL, 5) #set the Technical Manager self.m_st_technicalman = wx.StaticText(self.data_panel, wx.ID_ANY, u"Technical Manager:", wx.DefaultPosition, wx.DefaultSize, 0) self.m_st_technicalman.Wrap(-1) box2.Add(self.m_st_technicalman, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.m_Tech = wx.TextCtrl(self.data_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) box2.Add(self.m_Tech, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) #set the Batch name self.m_st_batch = wx.StaticText(self.data_panel, wx.ID_ANY, u"Batch Name:", wx.DefaultPosition, wx.DefaultSize, 0) self.m_st_batch.Wrap(-1) box2.Add(self.m_st_batch, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.m_Bath = wx.TextCtrl(self.data_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) box2.Add(self.m_Bath, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.m_staticText3 = wx.StaticText(self.data_panel, wx.ID_ANY, u"Run", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText3.Wrap(-1) box2.Add(self.m_staticText3, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) self.run_bot = wx.BitmapButton(self.data_panel, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | 0) self.run_bot.SetBitmap(wx.Bitmap(u"img/run_47.png", wx.BITMAP_TYPE_ANY)) box2.Add(self.run_bot, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5) #Set open file data function self.run_bot.Bind(wx.EVT_BUTTON, self.runProject) box2.Add((0, 0), 1, wx.EXPAND, 5) box1.Add(box2, 1, wx.EXPAND, 5) self.data_panel.SetSizer(box1) self.data_panel.Layout() box1.Fit(self.data_panel) self.note.AddPage(self.data_panel, u"DATA", True) #Set the report panel self.report_panel = wx.Panel(self.note, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) gs_report = wx.BoxSizer(wx.VERTICAL) self.buttonpanel = pdfButtonPanel(self.report_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) self.pdfViewer = pdfViewer(self.report_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL | wx.SUNKEN_BORDER) self.pdfViewer.UsePrintDirect = "False" # introduce buttonpanel and viewer to each other self.buttonpanel.viewer = self.pdfViewer self.pdfViewer.buttonpanel = self.buttonpanel #add the buutonpanel and pdfviewer to boxsizer gs_report.Add(self.buttonpanel, 1, wx.ALL, 5) gs_report.Add(self.pdfViewer, 100, wx.EXPAND | wx.ALL, 5) self.report_panel.SetSizer(gs_report) self.report_panel.Layout() gs_report.Fit(self.report_panel) self.note.AddPage(self.report_panel, u"Report", False) box.Add(self.note, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(box) self.Layout() self.Centre(wx.BOTH) #set the types self.type = ["SMP", "BLANK", "DUP"] #Load std for list self.Load_STD() #set the setting parameters self.Get_setting() #clear temporary files self.Clear_tempFiles() #set Datagrid cell Editor for fill with list self.type_editor = wx.grid.GridCellChoiceEditor(self.type, True) #set the editor cell for i in range(0, 100): self.Datagrid.SetCellEditor(i, 1, self.type_editor)