def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT): wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(640, 480)) i = wx.IconFromBitmap(bitmapLoader.getBitmap("graphs_small", "icons")) self.SetIcon(i) self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.CreateStatusBar() horSizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(horSizer) self.mainSizer = wx.BoxSizer(wx.VERTICAL) horSizer.Add(self.mainSizer, 1, wx.EXPAND) sFit = service.Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) self.fits = [fit] if fit is not None else [] self.fitList = FitList(self) self.fitList.SetMinSize((320, -1)) horSizer.Add(self.fitList, 0, wx.EXPAND) self.fitList.fitList.update(self.fits) self.graphSelection = wx.Choice(self, wx.ID_ANY, style=0) self.mainSizer.Add(self.graphSelection, 0, wx.EXPAND) self.figure = Figure(figsize=(4, 3)) self.canvas = Canvas(self, -1, self.figure) self.subplot = self.figure.add_subplot(111) self.subplot.grid(True) self.mainSizer.Add(self.canvas, 1, wx.EXPAND) self.gridPanel = wx.Panel(self) self.mainSizer.Add(self.gridPanel, 0, wx.EXPAND) dummyBox = wx.BoxSizer(wx.VERTICAL) self.gridPanel.SetSizer(dummyBox) self.gridSizer = wx.FlexGridSizer(0, 2) self.gridSizer.AddGrowableCol(1) dummyBox.Add(self.gridSizer, 0, wx.EXPAND) for view in Graph.views: view = view() self.graphSelection.Append(view.name, view) self.graphSelection.SetSelection(0) self.fields = {} self.select(0) self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) self.mainFrame.Bind(gui.fittingView.FIT_CHANGED, self.draw) self.Bind(wx.EVT_CLOSE, self.close)
def __init__(self, parent, dpi=None, **kwargs): wx.Panel.__init__(self, parent, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) self.canvas = Canvas(self, wx.ID_ANY, self.figure) self.check = wx.CheckBox(self, wx.ID_ANY, "Show contour") self.Bind(wx.EVT_CHECKBOX, self.OnChange, self.check) self.distMod = SinModulator(self, 'Amplitude modulator', cycles=(2, 100), phase=(0, 999)) self.Bind(EVT_UPDATE_EVENT, self.OnChange, self.distMod) sizerV = wx.BoxSizer(wx.VERTICAL) sizerV.Add(self.distMod) sizerV.Add(self.check, 0, wx.EXPAND) sizerH = wx.BoxSizer(wx.HORIZONTAL) sizerH.Add(self.canvas, 0, wx.SHAPED | wx.EXPAND) sizerH.Add(sizerV) self.SetSizer(sizerH) self.width, self.height = 256, 256
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) self.canvas = Canvas(self, -1, self.figure) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(sizer)
def __init__(self, graphFrame, parent): super().__init__(parent) self.graphFrame = graphFrame # Remove matplotlib font cache, see #234 try: cache_dir = mpl._get_cachedir() except: cache_dir = os.path.expanduser(os.path.join('~', '.matplotlib')) cache_file = os.path.join(cache_dir, 'fontList.cache') if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file): os.remove(cache_file) mainSizer = wx.BoxSizer(wx.VERTICAL) self.figure = Figure(figsize=(5, 3), tight_layout={'pad': 1.08}) rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() clr = [c / 255. for c in rgbtuple] self.figure.set_facecolor(clr) self.figure.set_edgecolor(clr) self.canvas = Canvas(self, -1, self.figure) self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple)) self.canvas.mpl_connect('button_press_event', self.OnMplCanvasClick) self.subplot = self.figure.add_subplot(111) self.subplot.grid(True) mainSizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL, 0) self.SetSizer(mainSizer) self.xMark = None self.mplOnDragHandler = None self.mplOnReleaseHandler = None
def __init__(self, parent, **kwargs): # bind the script to control: self.script = Test() xrcBANANA.__init__(self, parent, **kwargs) #self.PNL_PARAM_EDIT = NamedPanel(self,'Edit the script parameters below') #self.PNL_PARAM_EDIT.setup() #self.SriptsBase = ScriptsBase self.dataFilenamePath = None self.dataFilename = None self.dataDirectory = None # the controlling self.paramList = [] self.dataFilenameSet = False self.scriptSelected = True # self.load_sripts_tree() # create attributes for the named items in this container #self.MEN_BAR = self.GetMenuBar() #self.BTN_OUTPUT = self.getControl("BTN_OUTPUT") #self.BTN_RUN = self.getControl("BTN_RUN") # create place for the tprobe signal plot self.figure = mpl.figure.Figure(dpi=None, figsize=(2,2)) self.canvas = Canvas(self, -1, self.figure) self.axes = self.figure.gca() self.axes.set_title('Probe pulse shape',visible=True) self.axes.set_xlabel('Time, t (s)',visible=True) self.axes.set_ylabel('Voltage, U (V)',visible=True) mainVSizer = self.GetSizer() #mainVSizer = wx.Sizer() mainVSizer.Insert(2,self.canvas,0 , wx.GROW | wx.EXPAND) self.Layout() # important fields self.MEN_BAR = self.GetMenuBar() self.TXT_FILENAME = self.getControl("TXT_FILENAME") self.TXT_DIRECTORY = self.getControl("TXT_DIRECTORY") self.PNL_PARAM_EDIT = self.getControl("PNL_PARAM_EDIT") self.TXT_DESRIPTION = self.getControl("TXT_DESCRIPTION") self.SCOPE_POINTS = self.getControl("SCOPE_POINTS") #buttons self.BTN_SINGLE = self.getControl("BTN_SINGLE") self.BTN_REPEAT = self.getControl("BTN_REPEAT") self.BTN_RECORD = self.getControl("BTN_RECORD") self.BTN_OUTPUT = self.getControl("BTN_OUTPUT") # showMenu = wx.Menu() # showMenu.Append(ID_SHOWJOBS, 'Show list of test jobs')#, kind=wx.ITEM_CHECK) # #showMenu.Append(ID_SHOWGRAPH, 'Show graph')#, kind=wx.ITEM_CHECK) # self.MEN_BAR.Append(showMenu,'Show') # # show additional frames # self.joblist = JobListFrame(self) # self.joblist.Show() # #self.graph = Plot(self) self._create_bindings() self.load_parameters() return
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, size=(1000, 5000), **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2.9, 12.0), facecolor='w') self.canvas = Canvas(self, -1, self.figure) self.SetBackgroundColour('WHITE')
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(12, 10)) self.canvas = Canvas(self, -1, self.figure) self.l0 = wx.StaticText(self, -1, "Start at x=") self.t0 = wx.TextCtrl(self, 3, style=wx.TE_PROCESS_ENTER) #self.t0.SetRange(-1e10, 1e10) self.t0.Bind(wx.EVT_TEXT_ENTER, self.onUpdateT0, id=3) self.lv = wx.StaticText(self, -1, "") self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(self.l0) sizer1.Add(self.t0) sizer1.Add(self.lv) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(sizer1, 1, wx.EXPAND) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent): wx.Panel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL) self.afficher_valeurs = False self.panel = wx.Panel(self, -1, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER) self.figure = matplotlib.pyplot.figure() self.canvas = Canvas(self.panel, -1, self.figure) self.canvas.SetMinSize((20, 20)) self.SetColor((255, 255, 255)) # Boutons self.bouton_apercu = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Apercu.png"), wx.BITMAP_TYPE_ANY)) self.bouton_options = wx.BitmapButton( self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Mecanisme.png"), wx.BITMAP_TYPE_ANY)) # Binds self.Bind(wx.EVT_BUTTON, self.Apercu, self.bouton_apercu) self.Bind(wx.EVT_BUTTON, self.Options, self.bouton_options) # Properties self.bouton_apercu.SetToolTip( wx.ToolTip( _(u"Cliquez ici pour ouvrir le visualiseur de graphe pour accéder aux fonctions d'export et d'impression" ))) self.bouton_options.SetToolTip( wx.ToolTip(_(u"Cliquez ici pour accéder aux options du graphe"))) # Layout grid_sizer_base = wx.FlexGridSizer(1, 2, 5, 5) sizer_canvas = wx.BoxSizer(wx.VERTICAL) sizer_canvas.Add(self.canvas, 1, wx.EXPAND, 0) self.panel.SetSizer(sizer_canvas) grid_sizer_base.Add(self.panel, 1, wx.EXPAND | wx.TOP | wx.LEFT | wx.BOTTOM, 10) grid_sizer_boutons = wx.FlexGridSizer(5, 1, 5, 5) grid_sizer_boutons.Add(self.bouton_apercu, 0, 0, 0) grid_sizer_boutons.Add(self.bouton_options, 0, 0, 0) grid_sizer_base.Add(grid_sizer_boutons, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 10) grid_sizer_base.AddGrowableCol(0) grid_sizer_base.AddGrowableRow(0) self.SetSizer(grid_sizer_base) self.Layout()
def __init__(self, parent, figure=None): wx.Panel.__init__(self, parent, id=-1, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) self.figure = figure self.figure.set_size_inches(90, 90) self.canvas = Canvas(self, -1, figure) self.SetColor( (255,255,255) ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas,1,wx.EXPAND|wx.ALL, 0) self.SetSizer(sizer)
def __init__(self, parent, id=-1, dpi=None): ps = parent.GetSize() wx.Panel.__init__(self, parent, id=id, size=ps) self.SetBackgroundColour('WHITE') self.figure = mpl.figure.Figure(dpi=dpi, facecolor='w', figsize=(ps[0] * .09, ps[1] * .09)) #self.figure.SetBackgroundColour('WHITE') self.canvas = Canvas(self, -1, self.figure) self.canvas.SetBackgroundColour('WHITE') self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.doSave)
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = Figure(dpi=dpi, figsize=(2, 2)) self.canvas = Canvas(self, -1, self.figure) self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
def create_main_panel(self): self.panel = wx.Panel(self) self.init_plot() self.canvas = Canvas(self.panel, -1, self.fig) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW) self.panel.SetSizer(self.vbox) self.vbox.Fit(self)
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = Figure(dpi=dpi, figsize=(2, 2)) self.canvas = Canvas(self, -1, self.figure) self.figure.set_facecolor((1, 1, 1)) self.figure.set_edgecolor((1, 1, 1)) self.canvas.SetBackgroundColour('white') self.subplot = self.figure.add_subplot(111) self.plot_scores = None self.class_masks = None self.class_names = None self.Loadings = None self.object_opacity = None self.object_accuracies = None self.leg = None self.maskedPCA1 = None self.maskedPCA2 = None self.axes = None # If the script is loaded from ClassifierGUI, load the classification weaklearners try: self.classifier = classifier self.classifier_rules = classifier.algorithm.weak_learners except: self.classifier_rules = [('None', 0, np.array([0, 0]))] self.chMap = p.image_channel_colors self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.Realize() POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 6 self.toolbar.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN) self.statusBar = wx.StatusBar(self, -1) self.statusBar.SetFieldsCount(1) self.motion_event_active = False self.canvas.mpl_connect('motion_notify_event', self.update_status_bar) self.canvas.mpl_connect('button_press_event', self.on_open_image) self.hide_legend_btn = wx.Button(self, -1, " Hide legend ") wx.EVT_BUTTON(self.hide_legend_btn, -1, self.hide_show_legend) self.hide_legend = True tools_sizer = wx.BoxSizer(wx.HORIZONTAL) tools_sizer.Add(self.toolbar, 0, wx.RIGHT | wx.EXPAND) tools_sizer.AddSpacer(5) tools_sizer.Add(self.hide_legend_btn, 0, wx.LEFT | wx.EXPAND) tools_sizer.AddSpacer(5) tools_sizer.Add(self.statusBar, 0, wx.LEFT | wx.EXPAND) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(tools_sizer, 0, wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent, style=wx.TAB_TRAVERSAL): wx.Panel.__init__(self, parent, id=-1, style=style) self.IDcompte = None self.date_debut = None self.date_fin = None self.figure = matplotlib.pyplot.figure() self.canvas = Canvas(self, -1, self.figure) self.SetColor( (255,255,255) ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas,1,wx.EXPAND|wx.ALL, 0) self.SetSizer(sizer)
def __init__(self, parent, fig, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) fig.set_figheight(2) fig.set_figwidth(2) self.canvas = Canvas(self, -1, fig) self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent, ID, dpi = None, **kwargs): wx.Panel.__init__(self, parent, ID, **kwargs) self.id = ID plt.ion() self.fig = mpl.figure.Figure(dpi=dpi, figsize=(4,3)) self.canvas = Canvas(self, -1, self.fig) self.ax = self.fig.add_subplot(111) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.fig.canvas, 1, wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent, id=-1, dpi=None, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) self.canvas = Canvas(self, -1, self.figure) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(sizer) self.intensity = self.figure.add_subplot(211) mpl.pyplot.setp(self.intensity.get_xticklabels(), visible=False) self.efficiency = self.figure.add_subplot(212, sharex=self.intensity) self.raw = None self.smooth = None
def __init__(self, parent): wx.Panel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER) self.dictParametres = None self.afficher_valeurs = False # Init canvas self.figure = matplotlib.pyplot.figure() self.canvas = Canvas(self, -1, self.figure) self.canvas.SetMinSize((20, 20)) self.SetColor( (255,255,255) ) # Layout sizer_canvas = wx.BoxSizer(wx.VERTICAL) sizer_canvas.Add(self.canvas, 1, wx.EXPAND, 0) self.SetSizer(sizer_canvas) self.Layout()
def __init__(self, parent, id=-1, dpi=None, data=None, **kwargs): # TODO: inherit directly from Canvas --- it is after all a panel. self.data = data # Set up the panel parameters #style = wx.NO_FULL_REPAINT_ON_RESIZE wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = mpl.figure.Figure(dpi=dpi, figsize=(1, 1)) self.canvas = Canvas(self, -1, self.figure) self.toolbar = Toolbar(self.canvas) self.toolbar.set_status_bar(parent.GetStatusBar()) self.toolbar.Realize() self.canvas.mpl_connect('resize_event', self.onResize) self.canvas.mpl_connect('scroll_event', self.onWheel) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer)
def __init__(self, parent, id=-1, dpi=None, toolbar=True, **kwargs): wx.Panel.__init__(self, parent, id=id, **kwargs) self.figure = matplotlib.figure.Figure(dpi=dpi, facecolor=(0.9, 0.9, 0.9, 1)) self.canvas = Canvas(self, -1, self.figure) self.plot_sizer = wx.BoxSizer(wx.VERTICAL) if toolbar: self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() self.plot_sizer.Add(self.toolbar, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) self.plot_sizer.Add(self.canvas, 1, wx.EXPAND) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.plot_sizer, 1, wx.EXPAND) self.SetSizer(self.sizer) self.setup_events()
def __init__(self): wx.Frame.__init__(self, parent=None, title="Colourmap Selection") self.figure = Figure(dpi=80, figsize=(2, 2)) self.canvas = Canvas(self, -1, self.figure) self.axes = self.figure.gca() x = y = numpy.linspace(-3, 3, 80) X, Y = numpy.meshgrid(x, y) V = numpy.sin(Y**2 + X**2) self.mapper = FigureImage(self.figure) im = self.axes.pcolor(x, y, V, shading='flat') try: cb = self.mapper.callbacksSM.connect('changed', ChangeCM(im)) except AttributeError: # Using 0.91 style self.mapper.add_observer(im) #self.figure.colorbar(self.mapper) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(sizer) self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.OnContext)
def __init__(self, *args, **kw): wx.Panel.__init__(self, *args, **kw) # data model self.model = None # plot objects self.figure = Figure(None) self.axes = self.figure.add_subplot(111) self.canvas = Canvas(self, -1, self.figure) # make plot resizeable sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.canvas, flag=wx.EXPAND, proportion=1) self.SetSizer(sizer) self.Bind(wx.EVT_CHAR_HOOK, self.on_key) # subscribe to various redraw events pub.subscribe(self.plot_sp, 'plot_sp') # draw initial plot self.redraw()
def __init__(self): setBaseDB('dass.db') initializeBaseDB() def makeSP(name, labels, statictexts = None): panel = wx.Panel(self.sidePanel, -1) box = wx.StaticBox(panel,-1, name) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) panel.rangeValue = {} for name, min_value, value, max_value in labels: sp = SpinPanel(panel, name, min_value, value, max_value, self.OnSpinback) panel.rangeValue[name] = sp sizer.Add(sp, 0, wx.EXPAND) print "done" panel.SetSizer(sizer) return panel wx.Frame.__init__(self, None, title = "CLUSTERING ALGORITHM") ################ Adding Drawing Panel ################ self.displayPanel = DisplayPanel(self) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.axes.set_axis_bgcolor('white') self.canvas = Canvas(self.displayPanel, -1, self.figure) ################ Connecting the canvas to events for selecting intial centroid & nuclei ################### self.figure.canvas.mpl_connect('button_press_event', self.onGraphClick) self.figure.canvas.mpl_connect('pick_event', self.onNucleiPick) ################ Connecting the canvas to events for selecting intial centroid & nuclei ################### sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.canvas, 1, wx.EXPAND) self.displayPanel.SetSizer(sizer) self.displayPanel.Fit() self.toolbar = NavigationToolbar(self.canvas) self.SetToolBar(self.toolbar) self.toolbar.Realize() tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() self.toolbar.SetSize(wx.Size(fw, th)) self.toolbar.update() self.redraw_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer) self.stopStart = threading.Event() self.data = None self.centroids = [] self.clusterIds = None self.colors = None self.k = 0 self.iterTimer = 0 self.iterations = 20 self.sidePanel = wx.Panel(self) self.pointToPick = 0 self.selectedFeaturesCount = 0 self.isPickCentroids = False ################ Adding Drawing Panel ################ ################ defining features for clustering algorithm ################ self.dictionary = {'Area':'AREA', 'Perimeter':'PERIMETER', 'Roundness':'ROUNDNESS','Equi-Diameter':'EQUI_DIAMETER', 'Orientation':'ORIENTATION', 'Convex Area':'CONVEX_AREA', 'Solidity': 'SOLIDITY', 'Major Axis':'MAJOR_AXIS_LEN','Minor Axis': 'MINOR_AXIS_LEN', 'Eccentricity':'ECCENTRICITY', 'Min Enclosing Rad':'CIR_RADIUS', 'Shape Index':'SHAPE_INDEX','Border Index':'BORDER_INDEX','Aspect Ratio':'ASPECT_RATION', 'Mean Pixel Intensity':'MEAN_PIXEL_DEN', 'Max Pixel Intensity':'MAX_PIXEL_DEN','Min Pixel Intensity':'MIN_PIXEL_DEN' } featureList = ['Area', 'Perimeter', 'Roundness', 'Equi-Diameter','Orientation', 'Convex Area', 'Solidity', 'Major Axis', 'Minor Axis', 'Eccentricity','Min Enclosing Rad','Shape Index','Border Index','Aspect Ratio', 'Mean Pixel Intensity','Max Pixel Intensity', 'Min Pixel Intensity'] ################ defining features for clustering algorithm ################ ################ Adding File Open Dialog to Show the tiles Info ################ self.chooseImagePanel = wx.Panel(self.sidePanel, -1) box = wx.StaticBox(self.chooseImagePanel, -1, 'Choose Image') self.subPanel = wx.Panel(self.chooseImagePanel, -1) sizer = wx.BoxSizer(wx.VERTICAL) self.filebrowser = filebrowse.FileBrowseButtonWithHistory( self.subPanel, -1, size=(450, -1), changeCallback = self.updateHistory) button = wx.Button(self.subPanel, -1, "View Image") button.Bind(wx.EVT_BUTTON, self.viewImage) sizer.Add(self.filebrowser,0,wx.EXPAND) sizer.Add(button,0,wx.ALL|wx.RIGHT|wx.ALIGN_RIGHT,5) self.subPanel.SetSizer(sizer) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer.Add(self.subPanel) self.chooseImagePanel.SetSizer(sizer) ################ Adding File Open Dialog to Show the tiles Info ################ ################ Adding Algorithm Options Info ################ self.algorithmPanel = wx.Panel(self.sidePanel, -1) box = wx.StaticBox(self.algorithmPanel, -1, 'Algorithms') self.subPanel = wx.Panel(self.algorithmPanel, -1) sizer = wx.BoxSizer(wx.HORIZONTAL) self.algorithm1 = wx.RadioButton(self.subPanel, label="K-MEANS", style = wx.RB_GROUP) self.algorithm2 = wx.RadioButton(self.subPanel, label="OPTICS") self.algorithm1.Bind(wx.EVT_RADIOBUTTON, self.kmeansSelected) self.algorithm2.Bind(wx.EVT_RADIOBUTTON, self.opticsSelected) sizer.Add(self.algorithm1 ,0,wx.ALL|wx.RIGHT|wx.ALIGN_LEFT, 5) sizer.Add((1,1),1) sizer.Add((1,1),1) sizer.Add(self.algorithm2 ,1,wx.ALL|wx.RIGHT|wx.ALIGN_RIGHT,5) self.subPanel.SetSizer(sizer) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer.Add(self.subPanel) self.algorithmPanel.SetSizer(sizer) ################ Adding Algorithm Options Info ################ ################ Adding Features Panel ################ self.featuresPanel = wx.Panel(self.sidePanel, -1) box = wx.StaticBox(self.featuresPanel, -1, 'Features') self.subPanel = wx.Panel(self.featuresPanel, -1) sizer = wx.GridSizer(rows = 6, cols = 3) global featureCB for feature in featureList: cb = wx.CheckBox(self.subPanel, label=feature) cb.Bind(wx.EVT_CHECKBOX, self.featuresSelected) featureCB[feature] = cb sizer.Add(cb, 0, wx.BOTTOM|wx.LEFT, 2) self.subPanel.SetSizer(sizer) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer.Add(self.subPanel) self.featuresPanel.SetSizer(sizer) ################ Adding Features Panel ################ ################ Adding Feature1, Feature2 Range Value ################ self.feature1 = makeSP('FEATURE 1 RANGES', (('Minimum', 1, 1, 3600), ('Maximum', 1, 3600, 3600))) self.feature2 = makeSP('FEATURE 2 RANGES', (('Minimum', 1, 1, 3600), ('Maximum', 1, 3600, 3600))) ################ Adding Feature1, Feature2 Range Value ################ ################ Adding all the panels to the main window ################ self.optionPanel = OptionsPanel(self,self.sidePanel, self.displayPanel) self.buttonStart = wx.Button(self.sidePanel, -1, "Start") self.buttonStart.Bind(wx.EVT_BUTTON, self.startProcess) buttonClose = wx.Button(self.sidePanel, -1, "Close") buttonClose.Bind(wx.EVT_BUTTON, self.stopProcess) self.buttonGenerate = wx.Button(self.sidePanel, -1, "Generate Image") self.buttonGenerate.Bind(wx.EVT_BUTTON, self.generateImage) self.buttonReset = wx.Button(self.sidePanel, -1, "Show Image/Reset") self.buttonReset.Bind(wx.EVT_BUTTON, self.resetProcess) self.feature1.Enable(False) self.feature2.Enable(False) self.buttonStart.Enable(False) self.buttonGenerate.Enable(False) self.algorithmPanel.Enable(False) self.optionPanel.Enable(False) self.buttonReset.Enable(False) panelSizer = wx.BoxSizer(wx.VERTICAL) panelSizer.Add(self.chooseImagePanel, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) panelSizer.Add(self.featuresPanel, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) panelSizer.Add(self.feature1, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) panelSizer.Add(self.feature2, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) panelSizer.Add(self.algorithmPanel, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) panelSizer.Add(self.optionPanel, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.buttonStart ,0,wx.ALL|wx.RIGHT|wx.ALIGN_LEFT, 5) # sizer.Add((1,1),1) sizer.Add(self.buttonGenerate ,0,wx.ALL|wx.RIGHT|wx.ALIGN_CENTER,5) # sizer.Add((1,1),1) sizer.Add(self.buttonReset,0,wx.ALL|wx.RIGHT|wx.ALIGN_CENTER,5) sizer.Add(buttonClose ,0,wx.ALL|wx.RIGHT|wx.ALIGN_RIGHT,5) panelSizer.Add(sizer,0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) # panelSizer.Add(buttonStart, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) # panelSizer.Add(buttonClose, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5) self.sidePanel.SetSizer(panelSizer) mainSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer.Add(self.displayPanel, 1, wx.EXPAND) mainSizer.Add(self.sidePanel, 0, wx.EXPAND) self.SetSizer(mainSizer) mainSizer.Fit(self) rw, rh = self.displayPanel.GetSize() sw, sh = self.sidePanel.GetSize() fw, fh = self.GetSize() h = max(600, fh) w = h + fw - rw if verbose: print 'Display Panel Size', (rw, rh) print 'Side Panel Size', (sw, sh) print 'Frame Size', (fw, fh) self.SetSize((w,h)) self.Show()
def __init__(self, images, parent=None, id=wx.ID_ANY, title='CellStar explorer', x=900, y=600): """ @type images: ImageRepo """ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX wx.Dialog.__init__(self, parent, id, title, style=style) self.Size = (x, y) self.figure = mpl.figure.Figure(dpi=300, figsize=(1, 1)) self.axes = self.figure.add_subplot(111) self.axes.margins(0, 0) self.canvas = Canvas(self, -1, self.figure) self.toolbar = Toolbar(self.canvas) self.toolbar.Realize() self.abort = False sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer) self.layer0 = self.axes.imshow(images.image, cmap=mpl.cm.gray) def onclick_internal(event): if event.ydata is None: return print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % ( event.button, event.x, event.y, event.xdata, event.ydata) if event.button != 1: self.onclick(event.button, event.xdata, event.ydata) self.figure.canvas.draw() def press_internal(event): print('press', event.key) if event.key == 'b': # abort self.EndModal(ExplorerFrame.ABORTED) if event.key in 'qwerxcv': self.layer0.remove() if event.key == 'q': # input self.layer0 = self.axes.imshow(images.image, cmap=mpl.cm.gray) elif event.key == 'w': # image clean self.layer0 = self.axes.imshow( images.image_back_difference, cmap=mpl.cm.gray) elif event.key == 'x': # image clean self.layer0 = self.axes.imshow( images.image_back_difference_blurred, cmap=mpl.cm.gray) elif event.key == 'c': # image clean self.layer0 = self.axes.imshow(images.foreground_mask, cmap=mpl.cm.gray) elif event.key == 'v': # image clean self.layer0 = self.axes.imshow(images.background_mask, cmap=mpl.cm.gray) elif event.key == 'e': # brighter self.layer0 = self.axes.imshow(images.brighter, cmap=mpl.cm.gray) elif event.key == 'r': # darker self.layer0 = self.axes.imshow(images.darker, cmap=mpl.cm.gray) self.figure.canvas.draw() else: self.press(event.key) self.figure.canvas.draw() self.figure.canvas.mpl_connect('button_press_event', onclick_internal) self.figure.canvas.mpl_connect('key_press_event', press_internal) self.Show(True)
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT): global graphFrame_enabled global mplImported global mpl_version self.legendFix = False if not graphFrame_enabled: pyfalog.warning( "Matplotlib is not enabled. Skipping initialization.") return try: cache_dir = mpl._get_cachedir() except: cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib")) cache_file = os.path.join(cache_dir, 'fontList.cache') if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file): # remove matplotlib font cache, see #234 os.remove(cache_file) if not mplImported: mpl.use('wxagg') graphFrame_enabled = True if int(mpl.__version__[0]) < 1: pyfalog.warning( "pyfa: Found matplotlib version {} - activating OVER9000 workarounds" .format(mpl.__version__)) pyfalog.warning( "pyfa: Recommended minimum matplotlib version is 1.0.0") self.legendFix = True mplImported = True wx.Frame.__init__(self, parent, title="pyfa: Graph Generator", style=style, size=(520, 390)) i = wx.Icon(BitmapLoader.getBitmap("graphs_small", "gui")) self.SetIcon(i) self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.CreateStatusBar() self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.mainSizer) sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) self.fits = [fit] if fit is not None else [] self.fitList = FitList(self) self.fitList.SetMinSize((270, -1)) self.fitList.fitList.update(self.fits) self.targets = [] # self.targetList = TargetList(self) # self.targetList.SetMinSize((270, -1)) # self.targetList.targetList.update(self.targets) self.graphSelection = wx.Choice(self, wx.ID_ANY, style=0) self.mainSizer.Add(self.graphSelection, 0, wx.EXPAND) self.figure = Figure(figsize=(5, 3), tight_layout={'pad': 1.08}) rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() clr = [c / 255. for c in rgbtuple] self.figure.set_facecolor(clr) self.figure.set_edgecolor(clr) self.canvas = Canvas(self, -1, self.figure) self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple)) self.subplot = self.figure.add_subplot(111) self.subplot.grid(True) self.mainSizer.Add(self.canvas, 1, wx.EXPAND) self.mainSizer.Add( wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND) self.graphCtrlPanel = wx.Panel(self) self.mainSizer.Add(self.graphCtrlPanel, 0, wx.EXPAND | wx.ALL, 0) self.showY0 = True self.selectedY = None self.selectedYRbMap = {} ctrlPanelSizer = wx.BoxSizer(wx.HORIZONTAL) viewOptSizer = wx.BoxSizer(wx.VERTICAL) self.showY0Cb = wx.CheckBox(self.graphCtrlPanel, wx.ID_ANY, "Always show Y = 0", wx.DefaultPosition, wx.DefaultSize, 0) self.showY0Cb.SetValue(self.showY0) self.showY0Cb.Bind(wx.EVT_CHECKBOX, self.OnShowY0Update) viewOptSizer.Add(self.showY0Cb, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5) self.graphSubselSizer = wx.BoxSizer(wx.VERTICAL) viewOptSizer.Add(self.graphSubselSizer, 0, wx.ALL | wx.EXPAND, 5) ctrlPanelSizer.Add(viewOptSizer, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.BOTTOM, 5) self.inputsSizer = wx.FlexGridSizer(0, 4, 0, 0) self.inputsSizer.AddGrowableCol(1) ctrlPanelSizer.Add(self.inputsSizer, 1, wx.EXPAND | wx.RIGHT | wx.TOP | wx.BOTTOM, 5) self.graphCtrlPanel.SetSizer(ctrlPanelSizer) self.drawTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.draw, self.drawTimer) for view in Graph.views: view = view() self.graphSelection.Append(view.name, view) self.graphSelection.SetSelection(0) self.fields = {} self.updateGraphWidgets() self.sl1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) self.mainSizer.Add(self.sl1, 0, wx.EXPAND) fitSizer = wx.BoxSizer(wx.HORIZONTAL) fitSizer.Add(self.fitList, 1, wx.EXPAND) #fitSizer.Add(self.targetList, 1, wx.EXPAND) self.mainSizer.Add(fitSizer, 0, wx.EXPAND) self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.fitList.fitList.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) self.mainFrame.Bind(GE.FIT_CHANGED, self.OnFitChanged) self.mainFrame.Bind(GE.FIT_REMOVED, self.OnFitRemoved) self.Bind(wx.EVT_CLOSE, self.closeEvent) self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent) self.Bind(wx.EVT_CHOICE, self.graphChanged) from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED # Grr crclar gons self.mainFrame.Bind(EFFECTIVE_HP_TOGGLED, self.OnEhpToggled) self.contextMenu = wx.Menu() removeItem = wx.MenuItem(self.contextMenu, 1, 'Remove Fit') self.contextMenu.Append(removeItem) self.contextMenu.Bind(wx.EVT_MENU, self.ContextMenuHandler, removeItem) self.Fit() self.SetMinSize(self.GetSize())
def __init__(self, data, extent, caller = None, scale = 'log', window_title = 'log plot', pixel_mask = None, plot_title = "data plot", x_label = "x", y_label = "y", parent=None): wx.Frame.__init__(self, parent=None, title=window_title, pos = wx.DefaultPosition, size=wx.Size(800,600)) print parent self.extent = extent self.data = data self.caller = caller self.window_title = window_title x_range = extent[0:2] #x_range.sort() self.x_min, self.x_max = x_range y_range = extent[2:4] #y_range.sort() self.y_min, self.y_max = y_range self.plot_title = plot_title self.x_label = x_label self.y_label = y_label self.slice_xy_range = (x_range, y_range) self.ID_QUIT = wx.NewId() self.ID_LOGLIN = wx.NewId() self.ID_UPCOLLIM = wx.NewId() self.ID_LOWCOLLIM = wx.NewId() menubar = wx.MenuBar() filemenu = wx.Menu() quit = wx.MenuItem(filemenu, 1, '&Quit\tCtrl+Q') #quit.SetBitmap(wx.Bitmap('icons/exit.png')) filemenu.AppendItem(quit) plotmenu = wx.Menu() self.menu_log_lin_toggle = plotmenu.Append(self.ID_LOGLIN, 'Plot 2d data with log color scale', 'plot 2d on log scale', kind=wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.toggle_2d_plot_scale, id=self.ID_LOGLIN) menu_upper_colormap_limit = plotmenu.Append(self.ID_UPCOLLIM, 'Set upper limit of color map', 'Set upper limit of color map') self.Bind(wx.EVT_MENU, self.set_new_upper_color_limit, id=self.ID_UPCOLLIM) menu_lower_colormap_limit = plotmenu.Append(self.ID_LOWCOLLIM, 'Set lower limit of color map', 'Set lower limit of color map') self.Bind(wx.EVT_MENU, self.set_new_lower_color_limit, id=self.ID_LOWCOLLIM) #live_on_off = wx.MenuItem(live_update, 1, '&Live Update\tCtrl+L') #quit.SetBitmap(wx.Bitmap('icons/exit.png')) #live_update.AppendItem(self.live_toggle) #self.menu_log_lin_toggle.Check(True) menubar.Append(filemenu, '&File') menubar.Append(plotmenu, '&Plot') self.SetMenuBar(menubar) self.Centre() if pixel_mask == None: pixel_mask = ones(data.shape) if pixel_mask.shape != data.shape: print "Warning: pixel mask shape incompatible with data" pixel_mask = ones(data.shape) self.pixel_mask = pixel_mask self.show_data = transpose(data.copy()) #self.minimum_intensity = self.data[pixel_mask.nonzero()].min() # correct for floating-point weirdness: self.minimum_intensity = self.data[self.data > 1e-17].min() #if scale == 'log': #self.show_data = log ( self.data.copy().T + self.minimum_intensity/2.0 ) #self._scale = 'log' #self.menu_log_lin_toggle.Check(True) #elif (scale =='lin' or scale == 'linear'): #self._scale = 'lin' #self.menu_log_lin_toggle.Check(True) #self.bin_data = caller.bin_data #self.params = caller.params #fig = figure() self.fig = Figure(dpi=80, figsize=(5,5)) #self.fig = figure() fig = self.fig self.canvas = Canvas(self, -1, self.fig) self.show_sliceplots = False # by default, sliceplots on self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND) #self.toolbar = Toolbar(self.canvas) self.toolbar = MyNavigationToolbar(self.canvas, True, self) self.toolbar.Realize() if wx.Platform == '__WXMAC__': # Mac platform (OSX 10.3, MacPython) does not seem to cope with # having a toolbar in a sizer. This work-around gets the buttons # back, but at the expense of having the toolbar at the top self.SetToolBar(self.toolbar) else: # On Windows platform, default window size is incorrect, so set # toolbar width to figure width. tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() # By adding toolbar in sizer, we are able to put it at the bottom # of the frame - so appearance is closer to GTK version. # As noted above, doesn't work for Mac. self.toolbar.SetSize(wx.Size(fw, th)) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.statusbar = self.CreateStatusBar() self.statusbar.SetFieldsCount(2) self.statusbar.SetStatusWidths([-1, -2]) self.statusbar.SetStatusText("Current Position:", 0) self.canvas.mpl_connect('motion_notify_event', self.onmousemove) #self.canvas.mpl_connect('button_press_event', self.right_click_handler) #self.axes = fig.add_subplot(111) #self.axes = self.fig.gca() #ax = self.axes self.mapper = FigureImage(self.fig) #im = self.axes.pcolor(x,y,V,shading='flat') #self.mapper.add_observer(im) #self.show_data = transpose(log(self.show_data + self.minimum_intensity / 2.0)) #self.canvas.mpl_connect('pick_event', self.log_lin_select) ax = fig.add_subplot(221, label='2d_plot') fig.sx = fig.add_subplot(222, label='sx', picker=True) fig.sx.xaxis.set_picker(True) fig.sx.yaxis.set_picker(True) fig.sx.yaxis.set_ticks_position('right') fig.sx.set_zorder(1) fig.sz = fig.add_subplot(223, label='sz', picker=True) fig.sz.xaxis.set_picker(True) fig.sz.yaxis.set_picker(True) fig.sz.set_zorder(1) self.RS = RectangleSelector(ax, self.onselect, drawtype='box', useblit=True) fig.slice_overlay = None ax.set_position([0.125,0.1,0.7,0.8]) fig.cb = fig.add_axes([0.85,0.1,0.05,0.8]) fig.cb.set_zorder(2) fig.ax = ax fig.ax.set_zorder(2) self.axes = ax ax.set_title(plot_title) #connect('key_press_event', self.toggle_selector) if scale == 'log': self.show_data = log ( self.data.copy().T + self.minimum_intensity/2.0 ) self.__scale = 'log' self.fig.cb.set_xlabel('$\log_{10}I$') self.menu_log_lin_toggle.Check(True) elif (scale =='lin' or scale == 'linear'): self.__scale = 'lin' self.fig.cb.set_xlabel('$I$') self.menu_log_lin_toggle.Check(False) im = self.axes.imshow(self.show_data, interpolation='nearest', aspect='auto', origin='lower',cmap=cm.jet, extent=extent) #im = ax.imshow(data, interpolation='nearest', aspect='auto', origin='lower',cmap=cm.jet, extent=extent) fig.im = im ax.set_xlabel(x_label, size='large') ax.set_ylabel(y_label, size='large') self.toolbar.update() #zoom_colorbar(im) #fig.colorbar(im, cax=fig.cb) zoom_colorbar(im=im, cax=fig.cb) #figure(fig.number) #fig.canvas.draw() #return self.SetSizer(self.sizer) self.Fit() self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.OnContext) self.Bind(wx.EVT_CLOSE, self.onExit) self.sliceplots_off() self.SetSize(wx.Size(800,600)) self.canvas.draw() return
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT): global graphFrame_enabled global mplImported global mpl_version self.legendFix = False if not graphFrame_enabled: pyfalog.warning( "Matplotlib is not enabled. Skipping initialization.") return try: cache_dir = mpl._get_cachedir() except: cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib")) cache_file = os.path.join(cache_dir, 'fontList.cache') if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file): # remove matplotlib font cache, see #234 os.remove(cache_file) if not mplImported: mpl.use('wxagg') graphFrame_enabled = True if int(mpl.__version__[0]) < 1: pyfalog.warning( "pyfa: Found matplotlib version {} - activating OVER9000 workarounds" .format(mpl.__version__)) pyfalog.warning( "pyfa: Recommended minimum matplotlib version is 1.0.0") self.legendFix = True mplImported = True wx.Frame.__init__(self, parent, title="pyfa: Graph Generator", style=style, size=(520, 390)) i = wx.Icon(BitmapLoader.getBitmap("graphs_small", "gui")) self.SetIcon(i) self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.CreateStatusBar() self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.mainSizer) sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) self.fits = [fit] if fit is not None else [] self.fitList = FitList(self) self.fitList.SetMinSize((270, -1)) self.fitList.fitList.update(self.fits) self.graphSelection = wx.Choice(self, wx.ID_ANY, style=0) self.mainSizer.Add(self.graphSelection, 0, wx.EXPAND) self.figure = Figure(figsize=(4, 3)) rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() clr = [c / 255. for c in rgbtuple] self.figure.set_facecolor(clr) self.figure.set_edgecolor(clr) self.canvas = Canvas(self, -1, self.figure) self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple)) self.subplot = self.figure.add_subplot(111) self.subplot.grid(True) self.mainSizer.Add(self.canvas, 1, wx.EXPAND) self.mainSizer.Add( wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND) self.gridPanel = wx.Panel(self) self.mainSizer.Add(self.gridPanel, 0, wx.EXPAND) dummyBox = wx.BoxSizer(wx.VERTICAL) self.gridPanel.SetSizer(dummyBox) self.gridSizer = wx.FlexGridSizer(0, 4, 0, 0) self.gridSizer.AddGrowableCol(1) dummyBox.Add(self.gridSizer, 0, wx.EXPAND) for view in Graph.views: view = view() self.graphSelection.Append(view.name, view) self.graphSelection.SetSelection(0) self.fields = {} self.select(0) self.sl1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) self.mainSizer.Add(self.sl1, 0, wx.EXPAND) self.mainSizer.Add(self.fitList, 0, wx.EXPAND) self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) self.mainFrame.Bind(GE.FIT_CHANGED, self.draw) self.Bind(wx.EVT_CLOSE, self.closeEvent) self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent) self.Fit() self.SetMinSize(self.GetSize())
def __init__(self, parent, id=-1, dpi=None, color=None, **kwargs): # TODO: inherit directly from Canvas --- it is after all a panel. # Set up the panel parameters #style = wx.NO_FULL_REPAINT_ON_RESIZE wx.Panel.__init__(self, parent, id=id, **kwargs) self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) # Create the figure self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2)) #self.canvas = NoRepaintCanvas(self, -1, self.figure) self.canvas = Canvas(self, -1, self.figure) self.canvas.mpl_connect('key_press_event', self.onKeyPress) self.canvas.mpl_connect('button_press_event', self.onButtonPress) self.canvas.mpl_connect('scroll_event', self.onWheel) # TODO use something for pan events sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(sizer) # Construct an idle timer. This won't be needed when matplotlib # supports draw for wx. #self.idle_timer = wx.CallLater(1,self.onDrawIdle) #self.Fit() # Create four subplots with no space between them. # Leave space for the colorbar. # Use a common set of axes. self.pp = self.figure.add_subplot(221) self.mm = self.figure.add_subplot(222, sharex=self.pp, sharey=self.pp) self.pm = self.figure.add_subplot(223, sharex=self.pp, sharey=self.pp) self.mp = self.figure.add_subplot(224, sharex=self.pp, sharey=self.pp) self.figure.subplots_adjust(left=.1, bottom=.1, top=.9, right=0.85, wspace=0.0, hspace=0.0) self.axes = [self.pp, self.mm, self.pm, self.mp] self.grid = True # Create the colorbar # Provide an empty handle to attach colormap properties self.coloraxes = self.figure.add_axes([0.88, 0.2, 0.04, 0.6]) self.colormapper = mpl.image.FigureImage(self.figure) self.colormapper.set_array(np.ones(1)) self.colorbar = self.figure.colorbar(self.colormapper, self.coloraxes) # Provide slots for the graph labels self.tbox = self.figure.text(0.5, 0.95, '', horizontalalignment='center', fontproperties=FontProperties(size=16)) self.xbox = self.figure.text(0.5, 0.01, '', verticalalignment='bottom', horizontalalignment='center', rotation='horizontal') self.ybox = self.figure.text(0.01, 0.5, '', horizontalalignment='left', verticalalignment='center', rotation='vertical') self.zbox = self.figure.text(0.99, 0.5, '', horizontalalignment='right', verticalalignment='center', rotation='vertical') self.xscale = 'linear' self.yscale = 'linear' self.zscale = 'linear' self.set_vscale('log') # Set up the default plot self.clear() self._sets = {} # Container for all plotted objects
def __init__(self, parent): global graphFrame_enabled global mplImported global mpl_version if not graphFrame_enabled: pyfalog.warning( "Matplotlib is not enabled. Skipping initialization.") raise Exception() try: cache_dir = mpl._get_cachedir() except: cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib")) cache_file = os.path.join(cache_dir, 'fontList.cache') if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file): # remove matplotlib font cache, see #234 os.remove(cache_file) if not mplImported: mpl.use('wxagg') graphFrame_enabled = True self.legendFix = False if int(mpl.__version__[0]) < 1: print("pyfa: Found matplotlib version ", mpl.__version__, " - activating OVER9000 workarounds") print("pyfa: Recommended minimum matplotlib version is 1.0.0") self.legendFix = True mplImported = True wx.Panel.__init__(self, parent) self.sizer = wx.FlexGridSizer(2, 2) self.sizer.AddGrowableRow(0) self.sizer.AddGrowableCol(1) self.SetSizer(self.sizer) self.labelY = wx.StaticText( self, label="") # TODO custom control for rotated text? self.sizer.Add(self.labelY, flag=wx.ALIGN_CENTER | wx.ALL, border=3) self.figure = Figure(figsize=(4, 3)) colorByte = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() colorFloat = [c / 255. for c in colorByte] self.figure.set_facecolor(colorFloat) self.figure.set_edgecolor(colorFloat) self.subplot = self.figure.add_axes([0, 0, 1, 1]) self.canvas = Canvas(self, -1, self.figure) self.canvas.SetBackgroundColour(wx.Colour(*colorByte)) self.canvas.mpl_connect('pick_event', lambda event: self.onPick(event)) self.canvas.mpl_connect('button_press_event', lambda event: self.onPlotClick(event)) self.sizer.Add(self.canvas, proportion=1, flag=wx.EXPAND) self.sizer.Add(wx.StaticText(self, label=""), flag=wx.ALIGN_CENTER | wx.ALL, border=3) self.labelX = wx.StaticText(self, label="") self.sizer.Add(self.labelX, flag=wx.ALIGN_CENTER | wx.ALL, border=3) self._parent = parent self._lines = {} self.ondrag = None self.onrelease = None
def __do_layout(self): """ fill the dialog window . """ sizer_main = wx.BoxSizer(wx.VERTICAL) sizer_button = wx.BoxSizer(wx.HORIZONTAL) sizer_params = wx.GridBagSizer(5, 5) sizer_colormap = wx.BoxSizer(wx.VERTICAL) sizer_selection = wx.BoxSizer(wx.HORIZONTAL) iy = 0 sizer_params.Add(self.label_xnpts, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.xnpts_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 sizer_params.Add(self.label_ynpts, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.ynpts_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 sizer_params.Add(self.label_qmax, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.qmax_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 sizer_params.Add(self.label_beam, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.beam_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 sizer_params.Add(self.label_zmin, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.zmin_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 sizer_params.Add(self.label_zmax, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) sizer_params.Add(self.zmax_ctl, (iy, 1), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) iy += 1 self.fig = mpl.figure.Figure(dpi=self.dpi, figsize=(4, 1)) self.ax1 = self.fig.add_axes([0.05, 0.65, 0.9, 0.15]) self.norm = mpl.colors.Normalize(vmin=0, vmax=100) self.cb1 = mpl.colorbar.ColorbarBase(self.ax1, cmap=self.cmap, norm=self.norm, orientation='horizontal') self.cb1.set_label('Detector Colors') self.canvas = Canvas(self, -1, self.fig) sizer_colormap.Add(self.canvas, 0, wx.LEFT | wx.EXPAND, 5) self.cmap_selector = wx.ComboBox(self, -1) self.cmap_selector.SetValue(str(self.cmap.name)) maps = sorted(m for m in pylab.cm.datad if not m.endswith("_r")) for i, m in enumerate(maps): self.cmap_selector.Append(str(m), pylab.get_cmap(m)) wx.EVT_COMBOBOX(self.cmap_selector, -1, self._on_select_cmap) sizer_selection.Add(wx.StaticText(self, -1, "Select Cmap: "), 0, wx.LEFT | wx.ADJUST_MINSIZE, 5) sizer_selection.Add(self.cmap_selector, 0, wx.EXPAND | wx.ALL, 10) sizer_main.Add(sizer_params, 0, wx.EXPAND | wx.ALL, 5) sizer_main.Add(sizer_selection, 0, wx.EXPAND | wx.ALL, 5) note = " Note: This is one time option. " + \ "It will be reset on updating the image." note_txt = wx.StaticText(self, -1, note) sizer_main.Add(note_txt, 0, wx.EXPAND | wx.ALL, 5) sizer_main.Add(sizer_colormap, 1, wx.EXPAND | wx.ALL, 5) sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0) sizer_button.Add(self.button_reset, 0, wx.LEFT | wx.ADJUST_MINSIZE, 100) sizer_button.Add(self.button_ok, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10) sizer_button.Add(self.button_cancel, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) sizer_main.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10) self.SetAutoLayout(True) self.SetSizer(sizer_main) self.Layout() self.Centre()