def __init__(self, parent, counter, modelid, active_parms, tau=None): """ Initialize with given parameters. """ wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) self.parent = parent self.corr = Correlation(fit_model=modelid) if tau is not None: self.corr.lag_time = tau # active_parameters: # [0] labels # [1] values # [2] bool values to fit self.corr.fit_parameters = active_parms[1] self.corr.fit_parameters_variable = active_parms[2] self._bgselected = None self._bg2selected = None self.FitKnots = 5 # number of knots for spline fit or similiars self.weighted_fittype_id = 0 # integer (drop down item) self.weighted_nuvar = 3 # bins for std-dev. (left and rigth) # The weights that are plotted in the page # This is set by the PlotAll function self.weights_plot_fill_area = None # A list containing page numbers that share parameters with this page. # This parameter is defined by the global fitting tool and is saved in # sessions. self.GlobalParameterShare = list() # Counts number of Pages already created: self.counter = counter # Has inital plot been performed? # Call PlotAll("init") to set this to true. If it is true, then # nothing will be plotted if called with "init" self.InitialPlot = False # Model we are using # Tool statistics uses this list: self.StatisticsCheckboxes = None ### Splitter window # Sizes size = parent.notebook.GetSize() tabsize = 33 size[1] = size[1] - tabsize self.sizepanelx = 270 canvasx = size[0]-self.sizepanelx+5 sizepanel = (self.sizepanelx, size[1]) sizecanvas = (canvasx, size[1]) self.sp = wx.SplitterWindow(self, size=size, style=wx.SP_3DSASH) # This is necessary to prevent "Unsplit" of the SplitterWindow: self.sp.SetMinimumPaneSize(1) ## Settings Section (left side) #self.panelsettings = wx.Panel(self.sp, size=sizepanel) self.panelsettings = scrolled.ScrolledPanel(self.sp, size=sizepanel) self.panelsettings.SetupScrolling(scroll_x=False) ## Setting up Plot (correlation + chi**2) self.spcanvas = wx.SplitterWindow(self.sp, size=sizecanvas, style=wx.SP_3DSASH) # This is necessary to prevent "Unsplit" of the SplitterWindow: self.spcanvas.SetMinimumPaneSize(1) # y difference in pixels between Auocorrelation and Residuals cupsizey = size[1]*4/5 # Calculate initial data self.calculate_corr() # Draw the settings section self.settings() # Load default values self.apply_parameters_reverse() # Upper Plot for plotting of Correlation Function self.canvascorr = plot.PlotCanvas(self.spcanvas) self.canvascorr.setLogScale((True, False)) self.canvascorr.SetEnableZoom(True) self.PlotAll(event="init", trigger="tab_init") self.canvascorr.SetSize((canvasx, cupsizey)) # Lower Plot for plotting of the residuals self.canvaserr = plot.PlotCanvas(self.spcanvas) self.canvaserr.setLogScale((True, False)) self.canvaserr.SetEnableZoom(True) self.canvaserr.SetSize((canvasx, size[1]-cupsizey)) self.spcanvas.SplitHorizontally(self.canvascorr, self.canvaserr, cupsizey) self.sp.SplitVertically(self.panelsettings, self.spcanvas, self.sizepanelx) # Bind resizing to resizing function. wx.EVT_SIZE(self, self.OnSize)
def __init__(self, parent, group, on_ok=None): self.parent = parent self.group = group self.on_ok = on_ok wx.Frame.__init__(self, None, -1, 'Edit Array Names', style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetFont(Font(10)) sizer = wx.GridBagSizer(2, 2) panel = scrolled.ScrolledPanel(self) self.SetMinSize((675, 450)) self.wids = {} ir = 0 sizer.Add( Button(panel, 'Apply Changes', size=(200, -1), action=self.onOK), (0, 1), (1, 2), LEFT, 3) sizer.Add( Button(panel, 'Use Column Number', size=(200, -1), action=self.onColNumber), (0, 3), (1, 2), LEFT, 3) sizer.Add(HLine(panel, size=(550, 2)), (1, 1), (1, 5), LEFT, 3) cind = SimpleText(panel, label='Column') cold = SimpleText(panel, label='Current Name') cnew = SimpleText(panel, label='Enter New Name') cret = SimpleText(panel, label=' Result ', size=(150, -1)) cinfo = SimpleText(panel, label=' Data Range') cplot = SimpleText(panel, label=' Plot') ir = 2 sizer.Add(cind, (ir, 0), (1, 1), LEFT, 3) sizer.Add(cold, (ir, 1), (1, 1), LEFT, 3) sizer.Add(cnew, (ir, 2), (1, 1), LEFT, 3) sizer.Add(cret, (ir, 3), (1, 1), LEFT, 3) sizer.Add(cinfo, (ir, 4), (1, 1), LEFT, 3) sizer.Add(cplot, (ir, 5), (1, 1), LEFT, 3) for i, name in enumerate(group.array_labels): ir += 1 cind = SimpleText(panel, label=' %i ' % (i + 1)) cold = SimpleText(panel, label=' %s ' % name) cret = SimpleText(panel, label=fix_varname(name), size=(150, -1)) cnew = wx.TextCtrl(panel, value=name, size=(150, -1)) cnew.Bind(wx.EVT_KILL_FOCUS, partial(self.update, index=i)) cnew.Bind(wx.EVT_CHAR, partial(self.update_char, index=i)) cnew.Bind(wx.EVT_TEXT_ENTER, partial(self.update, index=i)) arr = group.data[i, :] info_str = " [ %8g : %8g ] " % (arr.min(), arr.max()) cinfo = SimpleText(panel, label=info_str) cplot = Button(panel, 'Plot', action=partial(self.onPlot, index=i)) self.wids["%d" % i] = cnew self.wids["ret_%d" % i] = cret sizer.Add(cind, (ir, 0), (1, 1), LEFT, 3) sizer.Add(cold, (ir, 1), (1, 1), LEFT, 3) sizer.Add(cnew, (ir, 2), (1, 1), LEFT, 3) sizer.Add(cret, (ir, 3), (1, 1), LEFT, 3) sizer.Add(cinfo, (ir, 4), (1, 1), LEFT, 3) sizer.Add(cplot, (ir, 5), (1, 1), LEFT, 3) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, wx.GROW | wx.ALL, 1) pack(self, mainsizer) self.Show() self.Raise()
def __init__(self, workgroup, parent, id, title\ , pos \ , size): '''Initialize our window ''' wx.Frame.__init__(self, parent, id, title, pos, size) self.parent = parent self.WorkGroup = workgroup self.currentField = None self.currentFieldItem = None # Create a splitter window self.splitter = wx.SplitterWindow(self, -1) # Create the left panel self.leftPanel = wx.Panel(self.splitter, -1) # Create a box sizer that will contain the left panel contents self.leftBox = wx.BoxSizer(wx.VERTICAL) # Create our tree and put it into the left panel self.tree = fieldsTree( self, self.leftPanel, 1, wx.DefaultPosition, (-1, -1), wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE) # Add the tree to the box sizer self.leftBox.Add(self.tree, 1, wx.EXPAND) # Bind the OnSelChanged method to the tree self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.tree.OnSelChanged, id=1) # Set the size of the right panel to that required by the tree self.leftPanel.SetSizer(self.leftBox) # Create the right panel self.rightPanel = scrolled.ScrolledPanel(self.splitter, -1) # Create the right box sizer that will contain the panel's contents self.displayBox = wx.BoxSizer(wx.VERTICAL) # Create a widget to display static text and store it in the right # panel self.display = wx.StaticText(self.rightPanel, -1, '', (10, 10), style=wx.ALIGN_LEFT) # Add the display widget to the right panel self.displayBox.Add(self.display, 1, wx.EXPAND) # the rightBox is a container for buttonFieldBox and displayBox self.rightBox = wx.BoxSizer(wx.HORIZONTAL) self.rightBox.Add(self.displayBox, 1, wx.EXPAND) self.actionsPanel = self.rightPanel self.actionsBox = self.rightBox self.list_actions = [] # self.fieldActions = FieldActions(self, self.actionsPanel, self.actionsBox) # self.list_actions.append(self.fieldActions) self.actionsPanel.SetSizer(self.actionsBox) self.rightPanel.SetSizer(self.rightBox) self.rightPanel.SetupScrolling() # Set the size of the right panel to that required by the # display widget # Put the left and right panes into the split window self.splitter.SplitVertically(self.leftPanel, self.rightPanel, sashPosition=160) # Create the window in the centre of the screen self.Centre() # Hide all actions self.HideAllActions() # keyboard handlers self.Bind(wx.EVT_KEY_UP, self.onKeyPressUp) # Bind the right mouse click self.tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.tree.OnRightMouseClick, id=1)
def __init__( self, *args, **kw, ): super(FileSelectScreen, self).__init__(*args, **kw, size=(self.screenWidth + 10, 500)) self.panel = wx.Panel(self) self.continueButton = wx.Button(self.panel, label="Continue") clearButton = wx.Button(self.panel, label="Clear") buttonHolder = wx.BoxSizer(wx.HORIZONTAL) buttonHolder.Add(self.continueButton, proportion=1) buttonHolder.Add(clearButton, proportion=1) self.instructions = wx.StaticText( self.panel, size=(self.screenWidth, 25), label="Use file chooser to select CSVs, click clear to start over." ) listHolder = wx.BoxSizer(wx.VERTICAL) self.listScrolled = scrolled.ScrolledPanel(self.panel, size=(self.screenWidth, 200), style=wx.SIMPLE_BORDER) self.listScrolled.SetupScrolling() self.listScrolledSizer = wx.BoxSizer(wx.VERTICAL) selectFilesButton = wx.Button(self.panel, size=(self.screenWidth, 25), label="Select File") self.listScrolled.SetSizer(self.listScrolledSizer) listHolder.AddMany([selectFilesButton, self.listScrolled]) titleHolder = wx.BoxSizer(wx.HORIZONTAL) titleHolder.Add( wx.StaticText(self.panel, size=(100, 25), label="Experiment Title")) self.titleEntry = wx.TextCtrl(self.panel, size=(275, 25), id=wx.ID_ANY) titleHolder.Add(self.titleEntry) self.electrodeSelectionHolder = wx.BoxSizer(wx.HORIZONTAL) magnitudeSelectionHolder = wx.BoxSizer(wx.HORIZONTAL) self.magnitudeBox = wx.RadioBox(self.panel, label='Current Magnitude', pos=(0, 0), choices=["Milliamp", "Microamps"], majorDimension=1, style=wx.RA_SPECIFY_ROWS) magnitudeSelectionHolder.Add(self.magnitudeBox) directorySelectionHolder = wx.BoxSizer(wx.VERTICAL) directorySelect = wx.Button(self.panel, label="Select directory for image folders") self.dirText = wx.StaticText(self.panel, label="No directory selected") directorySelectionHolder.AddMany([directorySelect, self.dirText]) self.mainBox = wx.BoxSizer(wx.VERTICAL) self.mainBox.AddMany([ self.instructions, titleHolder, magnitudeSelectionHolder, self.electrodeSelectionHolder, directorySelectionHolder, listHolder, buttonHolder ]) self.panel.SetSizerAndFit(self.mainBox) self.Bind(wx.EVT_BUTTON, self.dirSelectClicked, directorySelect) self.Bind(wx.EVT_BUTTON, self.fileSelectClicked, selectFilesButton) self.Bind(wx.EVT_BUTTON, self.continueClicked, self.continueButton) self.Bind(wx.EVT_BUTTON, self.clearClicked, clearButton)
def __init__(self, parent=None, pos=(-1, -1), inst=None, db=None, epics_pvs=None): self.epics_pvs = epics_pvs if self.epics_pvs is None: self.epics_pvs = {} title = 'Add New Instrument' if inst is not None: title = 'Edit Instrument %s ' % inst.name style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL wx.Frame.__init__(self, None, -1, title, style=style, pos=pos) self.Handle_FocusEvents() panel = scrolled.ScrolledPanel(self, size=(500, 650), style=wx.GROW|wx.TAB_TRAVERSAL, name='p1') self.colors = GUIColors() font = self.GetFont() if parent is not None: font = parent.GetFont() titlefont = font titlefont.PointSize += 1 titlefont.SetWeight(wx.BOLD) panel.SetBackgroundColour(self.colors.bg) self.parent = parent self.db = db self.inst = db.get_instrument(inst) self.connecting_pvs = {} STY = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL RSTY = wx.ALIGN_RIGHT|STY CSTY = wx.ALIGN_CENTER|STY CEN = wx.ALIGN_CENTER|wx.GROW|wx.ALL LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL self.etimer = wx.Timer(self) self.etimer_count = 0 self.Bind(wx.EVT_TIMER, self.onTimer, self.etimer) sizer = wx.GridBagSizer(12, 3) # Name row label = SimpleText(panel, 'Instrument Name: ', minsize=(150, -1), style=LSTY) self.name = wx.TextCtrl(panel, value='', size=(260, -1)) sizer.Add(label, (0, 0), (1, 1), LSTY, 2) sizer.Add(self.name, (0, 1), (1, 2), LSTY, 2) sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL), (1, 0), (1, 3), CEN, 2) irow = 2 self.curpvs, self.newpvs = [], {} if inst is not None: self.name.SetValue(inst.name) sizer.Add(SimpleText(panel, 'Current PVs:', font=titlefont, colour=self.colors.title, style=LSTY), (2, 0), (1, 1), LSTY, 2) sizer.Add(SimpleText(panel, 'Display Type:', colour=self.colors.title, style=CSTY), (2, 1), (1, 1), LSTY, 2) sizer.Add(SimpleText(panel, 'Remove?:', colour=self.colors.title, style=CSTY), (2, 2), (1, 1), RSTY, 2) opvs = db.get_ordered_instpvs(inst) for instpvs in self.db.get_ordered_instpvs(inst): pv = instpvs.pv irow += 1 if pv.name in self.epics_pvs: pvchoices = get_pvtypes(self.epics_pvs[pv.name], instrument) else: pvchoices = get_pvtypes(pv, instrument) label= SimpleText(panel, pv.name, minsize=(175, -1), style=LSTY) try: itype = pvchoices.index(pv.pvtype.name) except ValueError: itype = 0 pvtype = PVTypeChoice(panel, choices=pvchoices) pvtype.SetSelection(itype) pvtype.SetStringSelection(pv.pvtype.name) del_pv = YesNo(panel, defaultyes=False) self.curpvs.append((pv.name, label, pvtype, del_pv)) sizer.Add(label, (irow, 0), (1, 1), LSTY, 3) sizer.Add(pvtype, (irow, 1), (1, 1), CSTY, 3) sizer.Add(del_pv, (irow, 2), (1, 1), RSTY, 3) irow += 1 sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL), (irow, 0), (1, 3), CEN, 0) irow += 1 txt =SimpleText(panel, 'New PVs:', font=titlefont, colour=self.colors.title, style=LSTY) sizer.Add(txt, (irow, 0), (1, 1), LEFT, 3) sizer.Add(SimpleText(panel, 'Display Type', colour=self.colors.title, style=CSTY), (irow, 1), (1, 1), LSTY, 2) sizer.Add(SimpleText(panel, 'Remove?', colour=self.colors.title, style=CSTY), (irow, 2), (1, 1), RSTY, 2) # New PVs for npv in range(5): irow += 1 name = pvNameCtrl(self, panel, value='', size=(175, -1)) pvtype = PVTypeChoice(panel) del_pv = YesNo(panel, defaultyes=False) pvtype.Disable() del_pv.Disable() sizer.Add(name, (irow, 0), (1, 1), LSTY, 3) sizer.Add(pvtype, (irow, 1), (1, 1), CSTY, 3) sizer.Add(del_pv, (irow, 2), (1, 1), RSTY, 3) self.newpvs[name.GetId()] = dict(index=npv, name=name, type=pvtype, delpv=del_pv) btn_panel = wx.Panel(panel, size=(75, -1)) btn_sizer = wx.BoxSizer(wx.HORIZONTAL) btn_ok = add_button(btn_panel, 'Done', size=(70, -1), action=self.OnDone) btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel) btn_sizer.Add(btn_ok, 0, wx.ALIGN_LEFT, 2) btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT, 2) pack(btn_panel, btn_sizer) irow += 1 sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL), (irow, 0), (1, 3), CEN, 2) sizer.Add(btn_panel, (irow+1, 1), (1, 2), CEN, 2) sizer.Add(wx.StaticLine(panel, size=(150, -1), style=wx.LI_HORIZONTAL), (irow+2, 0), (1, 3), CEN, 2) set_font_with_children(self, font) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, LSTY) pack(self, mainsizer) self.Layout() self.Show() self.Raise()
def __init__(self, *args, **kw): # ensure the parent's __init__ is called super(MainFrame, self).__init__(*args, style=wx.CAPTION ^ wx.RESIZE_BORDER) self.image = image.Image(self, 50, 50, 5, 'Von Neumann', 'non-periodical') self.is_animation_running = False self.SetSize(size=(300, 440)) # create a panel in the frame self.panel = scrolled.ScrolledPanel(self, -1, size=(300, 400)) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.AddMany([((10, 10), 0)]) # Width input label_width = wx.StaticText(self.panel, -1, "Width") self.input_width = wx.TextCtrl(self.panel, -1, "50", size=(45, -1)) # Height input label_height = wx.StaticText(self.panel, wx.ID_ANY, u"Height") self.input_height = wx.TextCtrl(self.panel, -1, "50", size=(45, -1)) # Box size label_box_size = wx.StaticText(self.panel, -1, "Box size") self.input_box_size = wx.TextCtrl(self.panel, -1, "5", size=(45, -1)) hbox_size = wx.BoxSizer(wx.HORIZONTAL) hbox_size.AddMany([((2, 2), 0), (label_width, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (self.input_width, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (label_height, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (self.input_height, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (label_box_size, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (self.input_box_size, 0), ((2, 2), 0)]) self.vbox.AddMany([((2, 2), 0), (hbox_size, 0), ((2, 2), 0)]) # Change size button self.btn_set_size = wx.Button(self.panel, -1, "Update (and clean) grid") self.btn_set_size.Bind(wx.EVT_BUTTON, self.on_set_size_clicked) self.vbox.Add(self.btn_set_size, 0, wx.CENTER | wx.EXPAND) self.vbox.AddMany([((10, 10), 0)]) # Neighbourhood label_neighbourhood = wx.StaticText(self.panel, -1, "Neighbourhood type ") neighbourhood = [ 'Von Neumann', 'Moore', 'Hexagonal left', 'Hexagonal right', 'Hexagonal random', 'Pentagonal random' ] self.combo = wx.ComboBox(self.panel, choices=neighbourhood) self.combo.Bind(wx.EVT_COMBOBOX, self.on_neighbourhood_selected) self.combo.SetValue('Von Neumann') hbox_neighbourhood = wx.BoxSizer(wx.HORIZONTAL) hbox_neighbourhood.AddMany([((5, 5), 0), (label_neighbourhood, 0), ((5, 5), 0)]) hbox_neighbourhood.AddMany([((5, 5), 0), (self.combo, 0), ((5, 5), 0)]) self.vbox.AddMany([((5, 5), 0), (hbox_neighbourhood, 0), ((5, 5), 0)]) # Boundary conditions label_conditions = wx.StaticText(self.panel, -1, "Boundary conditions ") conditions = ['periodical', 'non-periodical'] self.combo_conditions = wx.ComboBox(self.panel, choices=conditions) self.combo_conditions.Bind(wx.EVT_COMBOBOX, self.on_conditions_selected) self.combo_conditions.SetValue('non-periodical') hbox_conditions = wx.BoxSizer(wx.HORIZONTAL) hbox_conditions.AddMany([((5, 5), 0), (label_conditions, 0), ((5, 5), 0)]) hbox_conditions.AddMany([((6, 5), 0), (self.combo_conditions, 0), ((5, 5), 0)]) self.vbox.AddMany([((5, 5), 0), (hbox_conditions, 0), ((5, 5), 0)]) self.vbox.AddMany([((10, 10), 0)]) # Add seeds label_number_of_seeds = wx.StaticText(self.panel, -1, "Number of seeds to add") self.input_number_of_seeds = wx.TextCtrl(self.panel, -1, "10", size=(45, -1)) label_r = wx.StaticText(self.panel, -1, "R") self.input_radius = wx.TextCtrl(self.panel, -1, "10", size=(45, -1)) hbox_size = wx.BoxSizer(wx.HORIZONTAL) hbox_size.AddMany([((2, 2), 0), (label_number_of_seeds, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (self.input_number_of_seeds, 0), ((2, 2), 0)]) hbox_size.AddMany([((10, 2), 0), (label_r, 0), ((2, 2), 0)]) hbox_size.AddMany([((2, 2), 0), (self.input_radius, 0), ((2, 2), 0)]) self.vbox.AddMany([((2, 2), 0), (hbox_size, 0), ((2, 2), 0)]) self.vbox.AddMany([((10, 10), 0)]) # Add randomly self.btn_add_randomly = wx.Button(self.panel, -1, "Add randomly") self.btn_add_randomly.Bind(wx.EVT_BUTTON, self.on_add_randomly_clicked) # Add evenly self.btn_add_evenly = wx.Button(self.panel, -1, "Add evenly") self.btn_add_evenly.Bind(wx.EVT_BUTTON, self.on_add_evenly_clicked) # Add randomly with radius self.btn_add_radius = wx.Button(self.panel, -1, "Add with R") self.btn_add_radius.Bind(wx.EVT_BUTTON, self.on_add_radius_clicked) hbox_seeds_buttons = wx.BoxSizer(wx.HORIZONTAL) hbox_seeds_buttons.Add(self.btn_add_randomly) hbox_seeds_buttons.Add(self.btn_add_evenly) hbox_seeds_buttons.Add(self.btn_add_radius) self.vbox.Add(hbox_seeds_buttons, 0, wx.CENTER) self.vbox.AddMany([((10, 10), 0)]) self.st = wx.StaticLine(self.panel, wx.ID_ANY, style=wx.LI_HORIZONTAL) self.vbox.Add(self.st, 0, wx.ALL | wx.EXPAND, 5) # Buttons # Play self.btn_play = wx.Button(self.panel, -1, "Play") # ▶ font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.btn_play.SetFont(font) self.btn_play.Bind(wx.EVT_BUTTON, self.on_play_clicked) self.vbox.Add(self.btn_play, 0, wx.CENTER) # Pause self.btn_pause = wx.Button(self.panel, -1, "Pause") # ❚❚ self.btn_pause.Bind(wx.EVT_BUTTON, self.on_pause_clicked) self.vbox.Add(self.btn_pause, 0, wx.CENTER) # Reset self.btn_reset = wx.Button(self.panel, -1, "Reset") self.btn_reset.Bind(wx.EVT_BUTTON, self.on_reset_clicked) self.vbox.Add(self.btn_reset, 0, wx.CENTER) # Clean self.btn_clean = wx.Button(self.panel, -1, "Clean") self.btn_clean.Bind(wx.EVT_BUTTON, self.on_clean_clicked) self.vbox.Add(self.btn_clean, 0, wx.CENTER) # Animation step time self.st = wx.StaticLine(self.panel, wx.ID_ANY, style=wx.LI_HORIZONTAL) self.vbox.Add(self.st, 0, wx.ALL | wx.EXPAND, 5) hbox_time = wx.BoxSizer(wx.HORIZONTAL) label_time = wx.StaticText(self.panel, -1, "Time step") conditions = [ '0.1 sec', '0.2 sec', '0.3 sec', '0.4 sec', '0.5 sec', '0.6 sec', '0.7 sec', '0.8 sec', '0.9 sec', '1.0 sec' ] self.combo_time = wx.ComboBox(self.panel, choices=conditions) self.combo_time.Bind(wx.EVT_COMBOBOX, self.on_time_step_clicked) self.combo_time.SetValue('1.0 sec') hbox_time.Add(label_time, 0, wx.CENTER) hbox_time.Add(self.combo_time, 0, wx.CENTER) self.vbox.Add(hbox_time, 0, wx.CENTER) self.panel.SetSizer(self.vbox) self.CreateStatusBar() self.SetStatusText("Welcome!") self.Centre() self.Show() self.Fit() self.image.start()
def __init__(self): if DEBUG: print("FlexTilesFrame.__init__()") ### init wPos = (0, 20) wg = wx.Display(0).GetGeometry() wSz = (wg[2], int(wg[3] * 0.9)) wx.Frame.__init__( self, None, -1, "FlexTiles-K v.%s" % (__version__), pos=tuple(wPos), size=tuple(wSz), style=wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX), ) self.SetBackgroundColour('#AAAABB') ### set app icon self.tbIcon = wx.adv.TaskBarIcon(iconType=wx.adv.TBI_DOCK) icon = wx.Icon("icon.ico") self.tbIcon.SetIcon(icon) ##### [begin] setting up attributes ----- self.wSz = wSz # window size self.fonts = getWXFonts() self.flagBlockUI = False # flag to determine temporary UI block pi = self.setPanelInfo() # set panel info self.pi = pi # panel information self.gbs = {} # for GridBagSizer self.panel = {} # panels self.timer = {} # timers self.csvFP = "" # CSV file path self.outputPath = path.join(CWD, "output") # output file path if not path.isdir(self.outputPath): mkdir(self.outputPath) self.ani = None # to store animation info. to run self.kD = None # to store drawing info. (used when in Kandinsky mode) self.colors = {} # some preset colors self.colors[ "ftBGCol"] = "#111111" # background color of FlexTiles panel self.colors["highlightedTile"] = "#eeee33" # for highlighting a tile self.nRows = 8 # number of rows in FlexTiles self.nCols = 8 # number of columns in FlexTiles self.tileSz = 75 # size in pixels ### resize tile-size if it bigger than window size if self.nCols * self.tileSz > wSz[0]: self.tileSz *= int(wSz[0] / (self.nCols * self.tileSz)) if self.nRows * self.tileSz > wSz[1]: self.tileSz = int(self.tileSz * (wSz[1] / (self.nRows * self.tileSz))) ### load initial tile image initTileImg = "tile_init.png" self.initTileImg = load_img(initTileImg) # store initial (large) image for Kandinsky mode self.tileImgLarge = self.initTileImg.Copy() # store image for FlexTiles mode self.tileImg = self.initTileImg.Copy() ### if size doesn't match with desired size, rescale it. imgSz = self.tileImg.GetSize() if imgSz[0] != self.tileSz or imgSz[1] != self.tileSz: self.tileImg = self.tileImg.Rescale(self.tileSz, self.tileSz, wx.IMAGE_QUALITY_HIGH) lX = int(self.wSz[0] / 2 - (self.tileSz * self.nCols) / 2) tY = int(self.wSz[1] / 2 - (self.tileSz * self.nRows) / 2) # store rect of entire FlexTiles self.ftR = [ lX, # x1 tY, # y1 lX + self.tileSz * self.nCols, # x2 tY + self.tileSz * self.nRows ] # y2 self.idxMouseOn = (None, None) # row, column indices of tile, where # mouse pointer is currently on ### initialize angles and click-counters of all tiles d = [] for ri in range(self.nRows): d.append([]) for ci in range(self.nCols): #angle = randint(0,3) * 90 angle = 0 click = 0 d[ri].append([angle, click]) self.ftArr = np.asarray(d, dtype=np.uint16) # store it as array self.ftSeq = [] # to store sequence of tile clicks self.progInitTime = time() # starting time of the program self.currMP = None # current mouse pointer position self.flagKandinsky = False # whether it's in Kandinsky mode self.kDBtns = [ "fill", "line", "rectangle", "circle", "curvyline", "polygon", "pencil" ] # button names for Kandinsky mode self.selectedDBtn = "" # selected drawing button name self.selectedFCol = "#cccccc" # selected filling color self.selectedSCol = "#0000ff" # selected stroke color self.selectedSThick = 1 # selected stroke thickness self.flagFreePencilDrawing = False # free drawing is on self.freePencilDrawingPts = [] # points for free pencil drawing ##### [end] setting up attributes ----- updateFrameSize(self, wSz) ### create panels for k in pi.keys(): if k == "lp": self.panel[k] = SPanel.ScrolledPanel(self, pos=pi[k]["pos"], size=pi[k]["sz"], style=pi[k]["style"]) elif k == "mp": self.panel[k] = wx.Panel(self, pos=pi[k]["pos"], size=pi[k]["sz"], style=pi[k]["style"]) self.panel[k].SetBackgroundColour(pi[k]["bgCol"]) ### set up main-panel self.panel["mp"].Bind(wx.EVT_PAINT, self.onPaint) self.panel["mp"].Bind(wx.EVT_LEFT_DOWN, self.onLeftDown) self.panel["mp"].Bind(wx.EVT_LEFT_UP, self.onLeftUp) self.panel["mp"].Bind(wx.EVT_RIGHT_UP, self.onRightClick) self.panel["mp"].Bind(wx.EVT_MOTION, self.onMouseMove) ##### [begin] set up left panel interface ----- nCol = 2 hlSz = (pi["lp"]["sz"][0] - 10, -1 ) # size of horizontal line separator self.gbs["lp"] = wx.GridBagSizer(0, 0) row = 0 col = 0 sTxt = setupStaticText(self.panel["lp"], label="DrawingTools", font=self.fonts[2], fgColor="#cccccc") add2gbs(self.gbs["lp"], sTxt, (row, col), (1, 2)) row += 1 for i in range(len(self.kDBtns)): bn = self.kDBtns[i].capitalize() # button name btn = wx.Button(self.panel["lp"], -1, size=(45, 45), name="draw%s_btn" % (bn)) # set image for button set_img_for_btn("img_draw%s_off.png" % (bn), btn) btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown) add2gbs(self.gbs["lp"], btn, (row, col), (1, 1), bw=5) if i % 2 != 0: row += 1 col = 0 else: col += 1 if len(self.kDBtns) % 2 != 0: row += 1 col = 0 sTxt = setupStaticText(self.panel["lp"], label="Fill", font=self.fonts[2], fgColor="#cccccc") add2gbs(self.gbs["lp"], sTxt, (row, col), (1, 1)) col += 1 cpc = wx.ColourPickerCtrl(self.panel["lp"], -1, name="drawFCol_cpc") cpc.Bind(wx.EVT_COLOURPICKER_CHANGED, self.onColorPicked) cpc.SetColour(self.selectedFCol) add2gbs(self.gbs["lp"], cpc, (row, col), (1, 1), bw=0) row += 1 col = 0 sTxt = setupStaticText(self.panel["lp"], label="Stroke", font=self.fonts[2], fgColor="#cccccc") add2gbs(self.gbs["lp"], sTxt, (row, col), (1, 1)) col += 1 cpc = wx.ColourPickerCtrl(self.panel["lp"], -1, name="drawSCol_cpc") cpc.Bind(wx.EVT_COLOURPICKER_CHANGED, self.onColorPicked) cpc.SetColour(self.selectedSCol) add2gbs(self.gbs["lp"], cpc, (row, col), (1, 1), bw=0) row += 1 col = 0 sTxt = setupStaticText(self.panel["lp"], label="Stroke thickness", font=self.fonts[0], fgColor="#cccccc") add2gbs(self.gbs["lp"], sTxt, (row, col), (1, 1)) col += 1 spin = wx.SpinCtrl(self.panel["lp"], -1, size=(50, -1), min=1, max=50, initial=self.selectedSThick, name='strokeThick_spin', style=wx.SP_ARROW_KEYS | wx.SP_WRAP) spin.Bind(wx.EVT_SPINCTRL, self.onSpinCtrl) add2gbs(self.gbs["lp"], spin, (row, col), (1, 1)) row += 1 col = 0 add2gbs(self.gbs["lp"], wx.StaticLine(self.panel["lp"], -1, size=hlSz, style=wx.LI_HORIZONTAL), (row, col), (1, nCol)) # horizontal line separator self.panel["lp"].SetSizer(self.gbs["lp"]) self.gbs["lp"].Layout() self.panel["lp"].SetupScrolling() self.panel["lp"].Hide() ##### [end] set up top panel interface ----- ### set up menu menuBar = wx.MenuBar() mainMenu = wx.Menu() kModeMenu = mainMenu.Append(wx.Window.NewControlId(), item="Kandinsky drawing mode\tCTRL+K") self.Bind(wx.EVT_MENU, self.onKandinskyMode, kModeMenu) saveMenu = mainMenu.Append(wx.Window.NewControlId(), item="Save\tCTRL+S") self.Bind(wx.EVT_MENU, self.onSave, saveMenu) quitMenu = mainMenu.Append(wx.Window.NewControlId(), item="Quit\tCTRL+Q") self.Bind(wx.EVT_MENU, self.onClose, quitMenu) menuBar.Append(mainMenu, "&FlexTiles") self.SetMenuBar(menuBar) ### keyboard binding kMode_btnId = wx.NewIdRef(count=1) save_btnId = wx.NewIdRef(count=1) exit_btnId = wx.NewIdRef(count=1) self.Bind(wx.EVT_MENU, self.onKandinskyMode, id=kMode_btnId) self.Bind(wx.EVT_MENU, self.onSave, id=save_btnId) self.Bind(wx.EVT_MENU, self.onClose, id=exit_btnId) accel_tbl = wx.AcceleratorTable([ (wx.ACCEL_CMD, ord('K'), kMode_btnId), (wx.ACCEL_CMD, ord('S'), save_btnId), (wx.ACCEL_CMD, ord('Q'), exit_btnId), ]) self.SetAcceleratorTable(accel_tbl) self.Bind(wx.EVT_CLOSE, self.onClose)
def __init__(self, parent, id, title, dm): wx.Frame.__init__(self, parent, -1, title) if platform != "darwin": icon = wx.Icon("LogoIcon.ico", wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.dm = dm self.Bind(wx.EVT_CLOSE, self.OnEnd) self.WindowParent = parent self.panel = wx.Panel(self) self.EpisodesChanged = False self.__GetEpisodesInfo() sizer = wx.BoxSizer(wx.HORIZONTAL) # ------------ Begin of episodes grid vboxLeft = wx.BoxSizer(wx.VERTICAL) scrolledPanel = scrolled.ScrolledPanel( self.panel, style=wx.EXPAND, size=(manualEdWindowMinSize[0] - buttonSizeManualEd[0] - borderVeryBig * 4, manualEdWindowSize[1] - borderVeryBig * 4)) # self.__CreateGrid(scrolledPanel) # scrolledPanel.SetAutoLayout(1) # scrolledPanel.SetupScrolling(scroll_x=False) # self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) # scrolledPanel.SetSizer(vboxLeft) # scrolledPanel.Layout() self.__CreateGrid(scrolledPanel) vboxLeft.Add(self.myGrid) scrolledPanel.SetSizer(vboxLeft) scrolledPanel.Layout() #scrolledPanel.SetAutoLayout(1) scrolledPanel.SetupScrolling(scroll_x=False) self.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) # # ------------ End of episodes grid # ------------ Begin of buttons boxsizer vboxRight = wx.BoxSizer(wx.VERTICAL) self.newButton = wx.Button(self.panel, -1, "New", size=buttonSizeManualEd) self.Bind(wx.EVT_BUTTON, self.OnNew, id=self.newButton.GetId()) self.newButton.SetToolTip(wx.ToolTip("Click to add a new episode")) vboxRight.Add(self.newButton, 0, border=borderSmall, flag=wx.ALL) self.editButton = wx.Button(self.panel, -1, "Edit", size=buttonSizeManualEd) self.Bind(wx.EVT_BUTTON, self.OnEdit, id=self.editButton.GetId()) self.editButton.SetToolTip( wx.ToolTip("Click to edit selected episode")) vboxRight.Add(self.editButton, 0, border=borderSmall, flag=wx.ALL) self.editButton.Disable() self.delButton = wx.Button(self.panel, -1, "Delete", size=buttonSizeManualEd) self.Bind(wx.EVT_BUTTON, self.OnDel, id=self.delButton.GetId()) self.delButton.SetToolTip( wx.ToolTip("Click to delete selected episodes")) vboxRight.Add(self.delButton, 0, border=borderSmall, flag=wx.ALL) self.delButton.Disable() vboxRight.AddStretchSpacer(prop=1) self.endButton = wx.Button(self.panel, -1, "End", size=buttonSizeManualEd) self.Bind(wx.EVT_BUTTON, self.OnEnd, id=self.endButton.GetId()) self.endButton.SetToolTip(wx.ToolTip("Click to close window")) vboxRight.Add(self.endButton, 0, border=borderSmall, flag=wx.ALL) # ------------ End of buttons boxsizer box = wx.StaticBox(self.panel, -1, "Episodes information: ") sizer2 = wx.StaticBoxSizer(box, wx.VERTICAL) sizer2.Add(scrolledPanel, 1, flag=wx.ALL | wx.EXPAND, border=borderBig) sizer.Add(sizer2, 0, flag=wx.ALL, border=borderBig) sizer.AddStretchSpacer(prop=1) sizer.Add(vboxRight, 0, flag=wx.ALL | wx.EXPAND, border=borderBig) self.panel.SetSizer(sizer) self.SetSize(manualEdWindowSize) # defSize,minSize=Utils.RecalculateWindowSizes(manualEdWindowSize,manualEdWindowMinSize) # self.SetSize(defSize) # self.SetMinSize(minSize) self.Show(True) # self.Layout() self.Refresh() self.Fit()
def __init__(self, parent, transforms, title=_("Select datum transformation"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): wx.Dialog.__init__(self, parent, wx.ID_ANY, title, pos, size, style) global transformlist self.CentreOnParent() # default transform number self.transnum = 0 panel = scrolled.ScrolledPanel(self, wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) # # set panel sizer # panel.SetSizer(sizer) panel.SetupScrolling() # # dialog body # bodyBox = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Select from list of datum transformations")) bodySizer = wx.StaticBoxSizer(bodyBox) # add no transform option transforms = '---\n\n0\nDo not apply any datum transformations\n\n' + transforms transformlist = transforms.split('---') tlistlen = len(transformlist) # calculate size for transform list height = 0 width = 0 for line in transforms.splitlines(): w, h = self.GetTextExtent(line) height += h width = max(width, w) height = height + 5 if height > 400: height = 400 width = width + 5 if width > 400: width = 400 # # VListBox for displaying and selecting transformations # self.translist = TransList(panel, id=-1, size=(width, height), style=wx.SUNKEN_BORDER) self.translist.SetItemCount(tlistlen) self.translist.SetSelection(2) self.translist.SetFocus() self.Bind(wx.EVT_LISTBOX, self.ClickTrans, self.translist) bodySizer.Add(self.translist, proportion=1, flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND) # # buttons # btnsizer = wx.StdDialogButtonSizer() btn = Button(parent=panel, id=wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = Button(parent=panel, id=wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(bodySizer, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) sizer.Add(btnsizer, proportion=0, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) sizer.Fit(panel) self.SetSize(self.GetBestSize()) self.Layout()
def __init__(self, parent=None, title='', content=None, size=( 800, 600, ), *args, **kwargs): if title: self.title = title wx.Frame.__init__(self, parent, title=self.title, size=size, *args, **kwargs) self.parent = parent self.application = Version() # icon myStream = cStringIO.StringIO(base64.b64decode(icon)) myImage = wx.ImageFromStream(myStream) myBitmap = wx.BitmapFromImage(myImage) self.icon = wx.EmptyIcon() self.icon.CopyFromBitmap(myBitmap) self.SetIcon(self.icon) # tree image list if self.T: self.tree_image_list = wx.ImageList(16, 16) self.dotlist = self.tree_image_list.Add( wx.Image('resources/dotlist.png', wx.BITMAP_TYPE_PNG).Scale(16, 16).ConvertToBitmap()) # Menu arrangement menu = wx.MenuBar() class Index(object): def __init__(self, current): self.__current = current - 1 @property def current(self): return self.__current @current.setter def current(self, x): self.__current = x def next(self): self.__current += 1 return self.__current index = Index(100) menu_file = wx.Menu() self.menu_file_open = menu_file.Append(index.next(), '&Open...') self.menu_file_open.Enable(True) self.Bind(wx.EVT_MENU, self.File_Open, id=index.current) self.menu_file_close = menu_file.Append(index.next(), '&Close') self.menu_file_close.Enable(False) self.Bind(wx.EVT_MENU, self.File_Close, id=index.current) self.menu_file_save = menu_file.Append(index.next(), '&Save\tCtrl+S') self.menu_file_save.Enable(False) self.Bind(wx.EVT_MENU, self.File_Save, id=index.current) self.menu_file_save_as = menu_file.Append(index.next(), '&Save As...') self.menu_file_save_as.Enable(False) self.Bind(wx.EVT_MENU, self.File_Save_As, id=index.current) menu_file.AppendSeparator() menu_file.Append(wx.ID_EXIT, 'E&xit\tCtrl+Q', 'Exit application') self.Bind(wx.EVT_MENU, self.__Exit, id=wx.ID_EXIT) menu.Append(menu_file, '&File') menu_edit = wx.Menu() self.menu_edit_find = menu_edit.Append(wx.ID_FIND, '&Find...') self.Bind(wx.EVT_MENU, self.Find, id=wx.ID_FIND) self.menu_edit_find.Enable(False) menu.Append(menu_edit, '&Edit') menu_help = wx.Menu() menu_help.Append(wx.ID_ABOUT, '&About') self.Bind(wx.EVT_MENU, self.About, id=wx.ID_ABOUT) menu.Append(menu_help, '&Help') self.SetMenuBar(menu) # Layout self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) #def splitter_dclick(e): # e.Veto() #self.Bind(wx.EVT_SPLITTER_DCLICK, splitter_dclick, self.splitter) self.splitter.SetMinimumPaneSize(200) #self.gray = self.splitter.GetBackgroundColour() self.left = wx.Panel(self.splitter, style=wx.BORDER_SIMPLE) self.tree = wx.TreeCtrl(self.left, style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT | wx.TR_MULTIPLE | wx.TR_EDIT_LABELS | wx.BORDER_NONE) #|wx.TR_NO_LINES if self.T: self.tree.AssignImageList(self.tree_image_list) def splitter_repaint(e): self._tree_adjust() self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, splitter_repaint, self.splitter) #self.splitter.Bind(wx.EVT_PAINT, splitter_repaint) #self.white = self.tree.GetBackgroundColour() #print self.stack.GetBackgroundColour() --> (240, 240, 240, 255) self.stack = sp.ScrolledPanel(self.splitter, style=wx.BORDER_SIMPLE) self.stack_sizer = wx.BoxSizer(wx.VERTICAL) self.stack.SetSizer(self.stack_sizer) self.stack.Layout() self.stack.SetupScrolling(scroll_x=False) self.stack_sizer.Fit(self.stack) self.splitter.SplitVertically(self.left, self.stack, 300) self.root = self.tree.AddRoot('') self.n = [] self.t = [] self.d = [] self.r = [] node = self.tree.AppendItem(self.root, '') self.item_height = self.tree.GetBoundingRect(node)[-1] - 1 self.tree.Delete(node) del node # tree popupmenu self.tree_popupmenu = wx.Menu() self.tree_popupmenu_newchildnode = self.tree_popupmenu.Append( -1, 'New child node') self.tree_popupmenu_newchildnode.Enable(False) self.Bind(wx.EVT_MENU, self.__tree_OnPopupMenu_NewChildNode, self.tree_popupmenu_newchildnode) self.tree_popupmenu_delnode = self.tree_popupmenu.Append( -1, 'Delete node') self.Bind(wx.EVT_MENU, self.__tree_OnPopupMenu_DelNode, self.tree_popupmenu_delnode) self.tree_popupmenu.AppendSeparator() tree_popupmenu_collapse_all = self.tree_popupmenu.Append( -1, 'Collapse all') self.Bind(wx.EVT_MENU, self.__tree_OnPopupMenu_CollapseAll, tree_popupmenu_collapse_all) tree_popupmenu_expand_children = self.tree_popupmenu.Append( -1, 'Expand children') self.Bind(wx.EVT_MENU, self.__tree_OnPopupMenu_ExpandChildren, tree_popupmenu_expand_children) tree_popupmenu_expand_all = self.tree_popupmenu.Append( -1, 'Expand all') self.Bind(wx.EVT_MENU, self.__tree_OnPopupMenu_ExpandAll, tree_popupmenu_expand_all) self.tree.Bind(wx.EVT_CONTEXT_MENU, self.__tree_OnPopupMenu) def tree_empty_OnPopupMenu(e): if self.tree.GetCount() == 0: self.__tree_OnPopupMenu(e) self.tree.Bind(wx.EVT_RIGHT_DOWN, tree_empty_OnPopupMenu) #for i in range(50): # self.n += [self.tree.AppendItem(self.root, str(i+1))] # ctrl = self.yTextCtrl(self.stack, self, size=(-1, self.item_height), style=wx.BORDER_NONE) # self.stack_sizer.Add(ctrl, flag=wx.LEFT|wx.RIGHT|wx.EXPAND) # ctrl.SetValue(str(i+1)) # self.t += [ctrl] # del ctrl #self.AppendNode('abc','def',dict(a=2)) #self.AppendNode('cgi','har',dict(a='frai')) #for i in range(1,50): # self.AppendNode(str(i),str(i)) #if self.perf: # self.perf_load = Perf('Load') # self.perf_load.start() # self.perf_stack_adjust = Perf('_stack_adjust') # self.perf_tree_adjust = Perf('_tree_adjust') if content != None: self.Load(content) #if self.perf: # self.perf_load.end().result() # self.perf_stack_adjust.result() # self.perf_tree_adjust.result() #self._stack_adjust() self.tree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.__tree_OnCollapse) self.tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.__tree_OnExpand) self.tree.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.__tree_BeginLabelEdit) self.tree.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.__tree_EndLabelEdit) # show #self.SetDoubleBuffered(True) self.CenterOnScreen() self.Show() self.SetMinSize(tuple(map(lambda x: x * 2 / 3, self.GetSize()))) self.Bind(wx.EVT_SIZE, self.__OnResize, self) self.Bind(wx.EVT_PAINT, self.__OnRepaint, self) self.Bind(wx.EVT_CLOSE, self.__OnClose) #self._tree_adjust() self.stack.SetScrollRate(16, self.item_height) self.tree.Bind(wx.EVT_PAINT, self.__tree_OnScroll) self.stack.Bind(wx.EVT_PAINT, self.__stack_OnScroll) #self.stack.Bind(wx.EVT_SCROLLWIN, self.__stack_OnScroll) def stack_focus_release(e): self.SetFocus() self.tree.UnselectAll() self.stack.Bind(wx.EVT_LEFT_UP, stack_focus_release) class FileDropTarget(wx.FileDropTarget): def __init__(self, target, handler): wx.FileDropTarget.__init__(self) self.target = target self.handler = handler def OnDropFiles(self, x, y, filenames): self.handler(filenames) def onDropFiles(filenames): if len(filenames) != 1: wx.MessageBox('Single file is expected!', 'Error', wx.OK | wx.ICON_ERROR) return #if self.file_changed: # dlg = wx.MessageDialog(self, 'You have unsaved changes. Do you want to discard them before opening new file?', 'Question', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) if self._File_Close(): self.Load(filenames[0]) dt = FileDropTarget(self.splitter, onDropFiles) self.splitter.SetDropTarget(dt) #self.t[2].Hide() #self.stack.Layout() #self.t[2].Show() #self.stack.Layout() #self.t[12].SetBackgroundColour(self.white) self.splitter.SetDoubleBuffered(True) #self.stack.SetBackgroundColour((240,255,255,255)) def tree_OnKey(e): keyCode = e.GetKeyCode() e.Skip() if keyCode == wx.WXK_RETURN: sel = self.tree.GetSelections() if len(sel) > 0: self.t[self.n.index(sel[0])].Edit() self.tree.Bind(wx.EVT_CHAR_HOOK, tree_OnKey)
def __init__(self, parent, cache): ''' Initialises the additional waypoints dialog. Arguments parent: The parent window for the dialog. cache: The cache object to display the additional waypoints from. ''' wx.Dialog.__init__(self, parent, wx.ID_ANY, _("Additional Waypoints for ") + cache.code, size=(490, 500), style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE) # Create a scrolled panel and a vertical sizer within it to take the logs sw = Scrolled.ScrolledPanel(self, -1, size=(480, 450), style=wx.TAB_TRAVERSAL) wptSizer = wx.BoxSizer(orient=wx.VERTICAL) res = Xrc.XmlResource( os.path.join(geocacher.getBasePath(), 'xrc', 'addWaypointsPanel.xrc')) # Create a block for each log and add it to the logs sizer for wpt in cache.getAddWaypoints(): wptPanel = res.LoadPanel(sw, 'addWaypointPanel') code = Xrc.XRCCTRL(wptPanel, 'codeText') wptType = Xrc.XRCCTRL(wptPanel, 'typeText') lat = Xrc.XRCCTRL(wptPanel, 'latText') lon = Xrc.XRCCTRL(wptPanel, 'lonText') name = Xrc.XRCCTRL(wptPanel, 'nameText') comment = Xrc.XRCCTRL(wptPanel, 'commentText') code.SetValue(wpt.code) wptType.SetValue(wpt.sym) lat.SetValue(latToStr(wpt.lat, geocacher.config().coordinateFormat)) lon.SetValue(lonToStr(wpt.lon, geocacher.config().coordinateFormat)) name.SetValue(wpt.name) comment.SetValue(wpt.cmt) wptSizer.Add(wptPanel) # Final Setup of the scrolled panel sw.SetSizer(wptSizer) sw.SetAutoLayout(1) sw.SetupScrolling() # Buttons closeButton = wx.Button(self, wx.ID_CLOSE) self.Bind(wx.EVT_BUTTON, self.OnClose, closeButton) buttonBox = wx.BoxSizer(orient=wx.HORIZONTAL) buttonBox.Add(closeButton, 0, wx.EXPAND) # finally, put the scrolledPannel and buttons in a sizer to manage the layout mainSizer = wx.BoxSizer(orient=wx.VERTICAL) mainSizer.Add(sw) mainSizer.Add(buttonBox, 0, wx.EXPAND) self.SetSizer(mainSizer)
def ShowVars(self): # create widgets to associate vars with labels and/or show messages self.varSizer.Clear(True) self.errbox = wxscroll.ScrolledPanel(self,style=wx.HSCROLL) self.errbox.SetMinSize((100,130)) self.varSizer.Add(self.errbox,0,wx.ALL|wx.EXPAND,1) self.varbox = wxscroll.ScrolledPanel(self,style=wx.HSCROLL) self.varSizer.Add(self.varbox,1,wx.ALL|wx.EXPAND,1) Siz = wx.BoxSizer(wx.VERTICAL) Siz.Add( wx.StaticText(self.varbox,wx.ID_ANY, 'Assignment of variables to labels:'), 0,wx.EXPAND|wx.ALIGN_CENTER,0) GridSiz = wx.FlexGridSizer(0,5,2,2) GridSiz.Add( wx.StaticText(self.varbox,wx.ID_ANY,'label',style=wx.CENTER), 0,wx.ALIGN_CENTER) lbls = ('varib. type\nselection','variable\nname','value') choices = ['Free','Phase','Hist./Phase','Hist.','Global'] if self.fit: lbls += ('refine\nflag',) else: lbls += ('',) choices[0] = '' for i in range(1,len(choices)): # remove empty menus from choice list if not len(self.parmLists[i]): choices[i] = '' self.AllowedChoices = [i for i in range(len(choices)) if choices[i]] for lbl in lbls: w = wx.StaticText(self.varbox,wx.ID_ANY,lbl,style=wx.CENTER) w.SetMinSize((80,-1)) GridSiz.Add(w,0,wx.ALIGN_CENTER) # show input for each var in expression. for v in self.exprVarLst: # label GridSiz.Add(wx.StaticText(self.varbox,wx.ID_ANY,v),0,wx.ALIGN_CENTER,0) # assignment type ch = wx.Choice( self.varbox, wx.ID_ANY, choices = [choices[i] for i in self.AllowedChoices] ) GridSiz.Add(ch,0,wx.ALIGN_LEFT,0) if v in self.varSelect and self.varSelect.get(v) in self.AllowedChoices: i = self.AllowedChoices.index(self.varSelect[v]) ch.SetSelection(i) else: ch.SetSelection(wx.NOT_FOUND) ch.label = v ch.Bind(wx.EVT_CHOICE,self.OnChoice) # var name/var assignment if self.varSelect.get(v) is None: GridSiz.Add((-1,-1),0,wx.ALIGN_LEFT|wx.EXPAND,0) elif self.varSelect.get(v) == 0: wid = G2G.ValidatedTxtCtrl(self.varbox,self.varName,v, #OnLeave=self.OnTxtLeave, size=(50,-1)) GridSiz.Add(wid,0,wx.ALIGN_LEFT|wx.EXPAND,0) else: wid = wx.StaticText(self.varbox,wx.ID_ANY,self.varName[v]) GridSiz.Add(wid,0,wx.ALIGN_LEFT,0) # value if self.varSelect.get(v) is None: GridSiz.Add((-1,-1),0,wx.ALIGN_RIGHT|wx.EXPAND,0) elif self.varSelect.get(v) == 0: wid = G2G.ValidatedTxtCtrl(self.varbox,self.varValue,v, #OnLeave=self.OnTxtLeave, size=(75,-1)) GridSiz.Add(wid,0,wx.ALIGN_LEFT|wx.EXPAND,0) wid.Bind(wx.EVT_CHAR,self.OnChar) else: var = self.varName[v] if '*' in var: #[self.parmDict[v] for v in LookupWildCard(var,self.parmDict.keys())] #print self.varValue[v] vs = G2obj.LookupWildCard(var,self.parmDict.keys()) s = '('+str(len(vs))+' values)' elif var in self.parmDict: val = self.parmDict[var] s = G2py3.FormatSigFigs(val).rstrip('0') else: s = '?' wid = wx.StaticText(self.varbox,wx.ID_ANY,s) GridSiz.Add(wid,0,wx.ALIGN_LEFT,0) # show a refine flag for Free Vars only if self.varSelect.get(v) == 0 and self.fit: self.varRefflag[v] = self.varRefflag.get(v,True) wid = G2G.G2CheckBox(self.varbox,'',self.varRefflag,v) GridSiz.Add(wid,0,wx.ALIGN_LEFT|wx.EXPAND,0) else: wid = (-1,-1) GridSiz.Add(wid,0,wx.ALIGN_LEFT|wx.EXPAND,0) Siz.Add(GridSiz) self.varbox.SetSizer(Siz,True) xwid,yhgt = Siz.Fit(self.varbox) self.varbox.SetMinSize((xwid,130)) self.varbox.SetAutoLayout(1) self.varbox.SetupScrolling() self.varbox.Refresh() self.Layout() #self.mainsizer.Fit(self) self.SendSizeEvent() # force repaint return
def __init__(self, parent, title, data, keyEditable=(-1, True), id=wx.ID_ANY, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): """Dialog for inserting/updating table record :param data: a list: [(column, value)] :param keyEditable: (id, editable?) indicates if textarea for key column is editable(True) or not """ # parent -> VDigitWindow wx.Dialog.__init__(self, parent, id, title, style=style) self.CenterOnParent() self.keyId = keyEditable[0] box = wx.StaticBox(parent=self, id=wx.ID_ANY) box.Hide() self.dataPanel = scrolled.ScrolledPanel(parent=self, id=wx.ID_ANY, style=wx.TAB_TRAVERSAL) self.dataPanel.SetupScrolling(scroll_x=False) # buttons self.btnCancel = wx.Button(self, wx.ID_CANCEL) self.btnSubmit = wx.Button(self, wx.ID_OK, _("&Submit")) self.btnSubmit.SetDefault() # data area self.widgets = [] cId = 0 self.usebox = False self.cat = None winFocus = False for column, ctype, ctypeStr, value in data: if self.keyId == cId: self.cat = int(value) if not keyEditable[1]: self.usebox = True box.SetLabel(" %s %d " % (_("Category"), self.cat)) box.Show() self.boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) cId += 1 continue else: valueWin = SpinCtrl(parent=self.dataPanel, id=wx.ID_ANY, value=value, min=-1e9, max=1e9, size=(250, -1)) else: valueWin = wx.TextCtrl(parent=self.dataPanel, id=wx.ID_ANY, value=value, size=(250, -1)) if ctype == int: valueWin.SetValidator(IntegerValidator()) elif ctype == float: valueWin.SetValidator(FloatValidator()) if not winFocus: wx.CallAfter(valueWin.SetFocus) winFocus = True label = wx.StaticText(parent=self.dataPanel, id=wx.ID_ANY, label=column) ctype = wx.StaticText(parent=self.dataPanel, id=wx.ID_ANY, label="[%s]:" % ctypeStr.lower()) self.widgets.append( (label.GetId(), ctype.GetId(), valueWin.GetId())) cId += 1 self._layout()
def UpdateDialog(self, map=None, query=None, cats=None, fid=-1, action=None): """Update dialog :param map: name of vector map :param query: :param cats: :param fid: feature id :param action: add, update, display or None :return: True if updated :return: False """ if action: self.action = action if action == 'display': enabled = False else: enabled = True self.closeDialog.Enable(enabled) self.FindWindowById(wx.ID_OK).Enable(enabled) if map: self.map = map # get layer/table/column information self.mapDBInfo = VectorDBInfo(self.map) if not self.mapDBInfo: return False self.mapDBInfo.Reset() layers = self.mapDBInfo.layers.keys() # get available layers # id of selected line if query: # select by position data = self.mapDBInfo.SelectByPoint(query[0], query[1]) self.cats = {} if data and 'Layer' in data: idx = 0 for layer in data['Layer']: layer = int(layer) if data['Id'][idx] is not None: tfid = int(data['Id'][idx]) else: tfid = 0 # Area / Volume if not tfid in self.cats: self.cats[tfid] = {} if not layer in self.cats[tfid]: self.cats[tfid][layer] = [] cat = int(data['Category'][idx]) self.cats[tfid][layer].append(cat) idx += 1 else: self.cats = cats if fid > 0: self.fid = fid elif len(self.cats.keys()) > 0: self.fid = self.cats.keys()[0] else: self.fid = -1 if len(self.cats.keys()) == 1: self.fidMulti.Show(False) self.fidText.Show(True) if self.fid > 0: self.fidText.SetLabel("%d" % self.fid) else: self.fidText.SetLabel(_("Unknown")) else: self.fidMulti.Show(True) self.fidText.Show(False) choices = [] for tfid in self.cats.keys(): choices.append(str(tfid)) self.fidMulti.SetItems(choices) self.fidMulti.SetStringSelection(str(self.fid)) # reset notebook self.notebook.DeleteAllPages() for layer in layers: # for each layer if not query: # select by layer/cat if self.fid > 0 and layer in self.cats[self.fid]: for cat in self.cats[self.fid][layer]: nselected = self.mapDBInfo.SelectFromTable( layer, where="%s=%d" % (self.mapDBInfo.layers[layer]['key'], cat)) else: nselected = 0 # if nselected <= 0 and self.action != "add": # continue # nothing selected ... if self.action == "add": if nselected <= 0: if layer in self.cats[self.fid]: table = self.mapDBInfo.layers[layer]["table"] key = self.mapDBInfo.layers[layer]["key"] columns = self.mapDBInfo.tables[table] for name in columns.keys(): if name == key: for cat in self.cats[self.fid][layer]: self.mapDBInfo.tables[table][name][ 'values'].append(cat) else: self.mapDBInfo.tables[table][name][ 'values'].append(None) else: # change status 'add' -> 'update' self.action = "update" table = self.mapDBInfo.layers[layer]["table"] key = self.mapDBInfo.layers[layer]["key"] columns = self.mapDBInfo.tables[table] for idx in range(len(columns[key]['values'])): for name in columns.keys(): if name == key: cat = int(columns[name]['values'][idx]) break # use scrolled panel instead (and fix initial max height of the # window to 480px) panel = scrolled.ScrolledPanel(parent=self.notebook, id=wx.ID_ANY, size=(-1, 150)) panel.SetupScrolling(scroll_x=False) self.notebook.AddPage(page=panel, text=" %s %d / %s %d" % (_("Layer"), layer, _("Category"), cat)) # notebook body border = wx.BoxSizer(wx.VERTICAL) flexSizer = wx.FlexGridSizer(cols=3, hgap=3, vgap=3) flexSizer.AddGrowableCol(2) # columns (sorted by index) names = [''] * len(columns.keys()) for name in columns.keys(): names[columns[name]['index']] = name for name in names: if name == key: # skip key column (category) continue vtype = columns[name]['type'].lower() ctype = columns[name]['ctype'] if columns[name]['values'][idx] is not None: if columns[name]['ctype'] != types.StringType: value = str(columns[name]['values'][idx]) else: value = columns[name]['values'][idx] else: value = '' colName = wx.StaticText(parent=panel, id=wx.ID_ANY, label=name) colType = wx.StaticText(parent=panel, id=wx.ID_ANY, label="[%s]:" % vtype) colValue = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=value) colValue.SetName(name) if ctype == int: colValue.SetValidator(IntegerValidator()) elif ctype == float: colValue.SetValidator(FloatValidator()) self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue) if self.action == 'display': colValue.SetWindowStyle(wx.TE_READONLY) flexSizer.Add(colName, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(colType, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) flexSizer.Add(colValue, proportion=1, flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) # add widget reference to self.columns columns[name]['ids'].append( colValue.GetId()) # name, type, values, id # for each attribute (including category) END border.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) panel.SetSizer(border) # for each category END # for each layer END if self.notebook.GetPageCount() == 0: self.noFoundMsg.Show(True) else: self.noFoundMsg.Show(False) self.Layout() return True
def __init__(self, parent, callback): wx.Panel.__init__(self, parent, -1) #Plugin page self.pluginList = profile.getPluginList() self.callback = callback sizer = wx.GridBagSizer(2, 2) self.SetSizer(sizer) effectStringList = [] for effect in self.pluginList: effectStringList.append(effect['name']) self.listbox = wx.ListBox(self, -1, choices=effectStringList) title = wx.StaticText(self, -1, _("Plugins:")) title.SetFont( wx.Font( wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) helpButton = wx.Button(self, -1, '?', style=wx.BU_EXACTFIT) addButton = wx.Button(self, -1, 'V', style=wx.BU_EXACTFIT) openPluginLocationButton = wx.Button(self, -1, _("Open plugin location")) sb = wx.StaticBox(self, label=_("Enabled plugins")) boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) self.pluginEnabledPanel = scrolledpanel.ScrolledPanel(self) self.pluginEnabledPanel.SetupScrolling(False, True) sizer.Add(title, (0, 0), border=10, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.TOP) sizer.Add(helpButton, (0, 1), border=10, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP) sizer.Add(self.listbox, (1, 0), span=(2, 2), border=10, flag=wx.EXPAND | wx.LEFT | wx.RIGHT) sizer.Add(addButton, (3, 0), span=(1, 2), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_BOTTOM) sizer.Add(boxsizer, (4, 0), span=(4, 2), border=10, flag=wx.EXPAND | wx.LEFT | wx.RIGHT) sizer.Add(openPluginLocationButton, (8, 0), border=10, flag=wx.LEFT | wx.BOTTOM) boxsizer.Add(self.pluginEnabledPanel, 1, flag=wx.EXPAND) sizer.AddGrowableCol(0) sizer.AddGrowableRow(1) # Plugins list box sizer.AddGrowableRow(4) # Enabled plugins sizer.AddGrowableRow(5) # Enabled plugins sizer.AddGrowableRow(6) # Enabled plugins sizer = wx.BoxSizer(wx.VERTICAL) self.pluginEnabledPanel.SetSizer(sizer) self.Bind(wx.EVT_BUTTON, self.OnAdd, addButton) self.Bind(wx.EVT_BUTTON, self.OnGeneralHelp, helpButton) self.Bind(wx.EVT_BUTTON, self.OnOpenPluginLocation, openPluginLocationButton) self.listbox.Bind(wx.EVT_LEFT_DCLICK, self.OnAdd) self.panelList = [] self.updateProfileToControls()
def __init__(self, user): super(FriendsFrame, self).__init__(title="我的好友", size=(260, 600)) self.chatFrame = None # 用户信息 self.user = user # 好友列表 self.friends = user["friends"] # 好友控件列表 self.friend_controls = [] user_icon_file = "resources/images/{0}.jpg".format(user["user_icon"]) user_icon = wx.Bitmap(user_icon_file, wx.BITMAP_TYPE_JPEG) # 顶部面板 toppanel = wx.Panel(self.content_panel) user_icon_sbitmap = wx.StaticBitmap(toppanel, bitmap=user_icon) username_st = wx.StaticText(toppanel, style=wx.ALIGN_CENTER_HORIZONTAL, label=user["user_name"]) # 创建顶部布局 topbox = wx.BoxSizer(wx.VERTICAL) topbox.AddSpacer(15) topbox.Add(user_icon_sbitmap, 1, wx.CENTER) topbox.AddSpacer(5) topbox.Add(username_st, 1, wx.CENTER) toppanel.SetSizer(topbox) # 好友列表面板 panel = scrolled.ScrolledPanel(self.content_panel, -1, size=(206, 1000), style=wx.DOUBLE_BORDER) gridsizer = wx.GridSizer(cols=1, rows=20, gap=(1, 1)) if len(self.friends) > 20: gridsizer = wx.GridSizer(cols=1, rows=len(self.friends), gap=(1, 1)) # 添加好友到好友列表面板 for index, friend in enumerate(self.friends): friend_panel = wx.Panel(panel, id=index) fdname_st = wx.StaticText(friend_panel, id=index, style=wx.ALIGN_CENTER_HORIZONTAL, label=friend["user_name"]) fdqq_st = wx.StaticText(friend_panel, id=index, style=wx.ALIGN_CENTER_HORIZONTAL, label=friend["user_id"]) path = "resources/images/{0}.jpg".format(friend["user_icon"]) icon = wx.Bitmap(path, wx.BITMAP_TYPE_JPEG) if friend["online"] == "0": icon2 = icon.ConvertToDisabled() fdicon_sb = wx.StaticBitmap(friend_panel, id=index, bitmap=icon2, style=wx.BORDER_RAISED) fdicon_sb.Enable(False) fdname_st.Enable(False) fdqq_st.Enable(False) self.friend_controls.append( (fdname_st, fdqq_st, fdicon_sb, icon)) else: fdicon_sb = wx.StaticBitmap(friend_panel, id=index, bitmap=icon, style=wx.BORDER_RAISED) fdicon_sb.Enable(True) fdname_st.Enable(True) fdqq_st.Enable(True) self.friend_controls.append( (fdname_st, fdqq_st, fdicon_sb, icon)) # 为好友图标和昵称和qq控件添加双击事件 fdicon_sb.Bind(wx.EVT_LEFT_DCLICK, self.on_dclick) fdname_st.Bind(wx.EVT_LEFT_DCLICK, self.on_dclick) fdqq_st.Bind(wx.EVT_LEFT_DCLICK, self.on_dclick) friendbox = wx.BoxSizer(wx.HORIZONTAL) friendbox.Add(fdicon_sb, 1, wx.CENTER) friendbox.Add(fdqq_st, 1, wx.CENTER) friendbox.Add(fdname_st, 1, wx.CENTER) friend_panel.SetSizer(friendbox) gridsizer.Add(friend_panel, 1, wx.ALL, border=5) panel.SetSizer(gridsizer) # 整体box布局 box = wx.BoxSizer(wx.VERTICAL) box.Add(toppanel, -1, wx.CENTER | wx.EXPAND) box.Add(panel, -1, wx.CENTER | wx.EXPAND) self.content_panel.SetSizer(box) # 初始化线程 # 设置子线程状态 self.isrunning = True # 创建一个子线程 self.t1 = threading.Thread(target=self.thread_body) self.t1.start()
def __init__(self, option_data): # wx Initialization wx.Frame.__init__(self, None, title="SU2 config file editor") # Define the main sizers self.frame_sizer = wx.BoxSizer(wx.HORIZONTAL) self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.left_sizer = wx.BoxSizer(wx.VERTICAL) self.right_sizer = wx.BoxSizer(wx.VERTICAL) # Use a scrolled panel on the right side self.main_panel = wx.Panel(self) self.scroll_sizer = wx.BoxSizer(wx.VERTICAL) self.right_panel = sp.ScrolledPanel(self.main_panel, size=(500, 500)) self.right_panel.SetupScrolling() # Left side - list of option categories self.list_ctrl = wx.ListCtrl(self.main_panel, style=wx.LC_REPORT | wx.BORDER_SUNKEN, size=(300, 600)) self.list_ctrl.InsertColumn(0, 'Option Category') bigfont = wx.Font(20, wx.MODERN, wx.NORMAL, wx.BOLD) # Read the option_data and build controls self.ctrldict = {} self.optlabels = {} for j, category in enumerate(option_data): self.list_ctrl.InsertStringItem( j, category) # Add category to left size list self.optlabels[category] = wx.StaticText(self.right_panel, label=category) self.optlabels[category].SetFont(bigfont) if j > 0: self.scroll_sizer.AddSpacer(20) self.scroll_sizer.Add(self.optlabels[category], wx.EXPAND) self.ctrldict[category] = [] yctr = 0 for j, opt in enumerate(option_data[category]): if opt.option_type in [ "EnumOption", "MathProblem", "SpecialOption", "ConvectOption" ]: self.ctrldict[category].append( LabeledComboBox(self.right_panel, opt.option_name, opt.option_name, opt.option_default, opt.option_values, opt.option_type, opt.option_description)) else: self.ctrldict[category].append( LabeledTextCtrl(self.right_panel, opt.option_name, opt.option_name, opt.option_default, opt.option_type)) for control in self.ctrldict[category]: self.scroll_sizer.Add( control.GetSizer(), wx.EXPAND) # Add each control to the sizer self.lastctrl = control.GetCtrl() # Set right_panel to scroll vertically self.right_panel.SetSizer(self.scroll_sizer) # Set up menu menuBar = wx.MenuBar() m_file = wx.Menu() m_save = m_file.Append(wx.ID_SAVE, "&Save", "Save an SU2 .cfg file") m_open = m_file.Append(wx.ID_OPEN, "&Open", "Load an SU2 .cfg file") m_exit = m_file.Append(wx.ID_EXIT, "E&xit", "Close window and exit program.") menuBar.Append(m_file, "&File") self.SetMenuBar(menuBar) self.CreateStatusBar() # Specify which functions to call when stuff is changed self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_click, self.list_ctrl) self.Bind(wx.EVT_MENU, self.OnSave, m_save) self.Bind(wx.EVT_MENU, self.OnOpen, m_open) self.Bind(wx.EVT_SIZE, self.OnResize) self.right_panel.SetAutoLayout(1) # Add it all to the panel and draw self.left_sizer.SetMinSize((300, 600)) self.right_sizer.SetMinSize((300, 600)) self.list_ctrl.SetColumnWidth(0, 500) self.left_sizer.Add(self.list_ctrl, 0, wx.EXPAND) self.right_sizer.Add(self.right_panel, 0, wx.EXPAND) self.main_sizer.Add(self.left_sizer, 0, wx.EXPAND) self.main_sizer.Add(self.right_sizer, 0, wx.EXPAND) self.frame_sizer.Add(self.main_sizer, 0, wx.EXPAND) self.main_panel.SetSizer(self.main_sizer) self.SetSizer(self.frame_sizer) self.SetInitialSize()
def make_text_panel(self, parent, font=None): panel = scrolled.ScrolledPanel(parent, size=(800, 200), style=wx.GROW | wx.TAB_TRAVERSAL, name='p1') if font is None: font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False) sizer = wx.GridBagSizer(2, 2) i = 0 irow = 0 bstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ST_NO_AUTORESIZE labstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL ax = self.axes[0] t0 = wx.StaticText(panel, -1, 'Text Size:', style=labstyle) t1 = wx.StaticText(panel, -1, 'Labels and Titles:', style=labstyle) t2 = wx.StaticText(panel, -1, 'Legends:', style=labstyle) t_size = wx.SpinCtrl(panel, -1, "", (-1, -1), (ISPINSIZE, 25)) t_size.SetRange(2, 20) t_size.SetValue(self.conf.labelfont.get_size()) t_size.Bind(wx.EVT_SPINCTRL, partial(self.onText, item='labelsize')) l_size = wx.SpinCtrl(panel, -1, " ", (-1, -1), (ISPINSIZE, 25)) l_size.SetRange(2, 20) l_size.SetValue(self.conf.legendfont.get_size()) l_size.Bind(wx.EVT_SPINCTRL, partial(self.onText, item='legendsize')) self.titl = LabelEntry(panel, self.conf.title.replace('\n', '\\n'), labeltext='Title: ', size=400, action=partial(self.onText, item='title')) self.ylab = LabelEntry(panel, self.conf.ylabel.replace('\n', '\\n'), labeltext='Y Label: ', size=400, action=partial(self.onText, item='ylabel')) self.y2lab = LabelEntry(panel, self.conf.y2label.replace('\n', '\\n'), labeltext='Y2 Label: ', size=400, action=partial(self.onText, item='y2label')) self.xlab = LabelEntry(panel, self.conf.xlabel.replace('\n', '\\n'), labeltext='X Label: ', size=400, action=partial(self.onText, item='xlabel')) sizer.Add(self.titl.label, (0, 0), (1, 1), labstyle) sizer.Add(self.titl, (0, 1), (1, 4), labstyle) sizer.Add(self.ylab.label, (1, 0), (1, 1), labstyle) sizer.Add(self.ylab, (1, 1), (1, 4), labstyle) sizer.Add(self.y2lab.label, (2, 0), (1, 1), labstyle) sizer.Add(self.y2lab, (2, 1), (1, 4), labstyle) sizer.Add(self.xlab.label, (3, 0), (1, 1), labstyle) sizer.Add(self.xlab, (3, 1), (1, 4), labstyle) sizer.Add(t0, (4, 0), (1, 1), labstyle) sizer.Add(t1, (4, 1), (1, 1), labstyle) sizer.Add(t_size, (4, 2), (1, 1), labstyle) sizer.Add(t2, (4, 3), (1, 1), labstyle) sizer.Add(l_size, (4, 4), (1, 1), labstyle) # Legend bstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ST_NO_AUTORESIZE labstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL ax = self.axes[0] leg_ttl = wx.StaticText(panel, -1, 'Legend:', size=(-1, -1), style=labstyle) loc_ttl = wx.StaticText(panel, -1, 'Location:', size=(-1, -1), style=labstyle) leg_loc = wx.Choice(panel, -1, choices=self.conf.legend_locs, size=(150, -1)) leg_loc.Bind(wx.EVT_CHOICE, partial(self.onShowLegend, item='loc')) leg_loc.SetStringSelection(self.conf.legend_loc) leg_onax = wx.Choice(panel, -1, choices=self.conf.legend_onaxis_choices, size=(120, -1)) leg_onax.Bind(wx.EVT_CHOICE, partial(self.onShowLegend, item='onaxis')) leg_onax.SetStringSelection(self.conf.legend_onaxis) togg_leg = wx.CheckBox(panel, -1, 'Click Legend to Show/Hide Line', (-1, -1), (-1, -1)) togg_leg.Bind(wx.EVT_CHECKBOX, self.onHideWithLegend) togg_leg.SetValue(self.conf.hidewith_legend) show_leg = wx.CheckBox(panel, -1, 'Show Legend', (-1, -1), (-1, -1)) show_leg.Bind(wx.EVT_CHECKBOX, partial(self.onShowLegend, item='legend')) show_leg.SetValue(self.conf.show_legend) show_lfr = wx.CheckBox(panel, -1, 'Show Legend Frame', (-1, -1), (-1, -1)) show_lfr.Bind(wx.EVT_CHECKBOX, partial(self.onShowLegend, item='frame')) show_lfr.SetValue(self.conf.show_legend_frame) lsizer = wx.BoxSizer(wx.HORIZONTAL) lsizer.AddMany((leg_ttl, show_leg, show_lfr, togg_leg)) sizer.Add(lsizer, (6, 0), (1, 8), labstyle, 2) lsizer = wx.BoxSizer(wx.HORIZONTAL) lsizer.AddMany((loc_ttl, leg_loc, leg_onax)) sizer.Add(lsizer, (7, 1), (1, 4), labstyle, 2) autopack(panel, sizer) return panel
def build_dialog(self): # positions = self.instdb.get_positionlist('IDE_SampleStage') positions = self.instdb.get_positionlist('SampleStage') panel = scrolled.ScrolledPanel(self) self.checkboxes = OrderedDict() sizer = wx.GridBagSizer(len(positions) + 5, 4) sizer.SetVGap(4) sizer.SetHGap(4) _nscans = ['%i' % (i + 1) for i in range(10)] self.scantype = add_choice(panel, ('Maps', 'XAFS', 'Linear'), size=(100, -1), action=self.onScanType) self.scantype.SetSelection(1) self.scanname = add_choice(panel, [], size=(200, -1)) self.pos_names = [] self.wid_include = {} self.wid_nscans = {} bkws = dict(size=(95, -1)) btn_insert = add_button(panel, "Insert Macro", action=self.onInsert, **bkws) btn_all = add_button(panel, "Select All", action=self.onSelAll, **bkws) btn_none = add_button(panel, "Select None", action=self.onSelNone, **bkws) btn_done = add_button(panel, "Close", action=self.onClose, **bkws) brow = wx.BoxSizer(wx.HORIZONTAL) brow.Add(btn_all, 0, ALL_EXP | wx.ALIGN_LEFT, 1) brow.Add(btn_none, 0, ALL_EXP | wx.ALIGN_LEFT, 1) brow.Add(btn_insert, 0, ALL_EXP | wx.ALIGN_LEFT, 1) brow.Add(btn_done, 0, ALL_EXP | wx.ALIGN_LEFT, 1) sizer.Add(brow, (0, 0), (1, 4), LEFT_CEN, 2) ir = 1 sizer.Add(SimpleText(panel, 'Scan Type:'), (ir, 0), (1, 1), LEFT_CEN, 2) sizer.Add(self.scantype, (ir, 1), (1, 1), LEFT_CEN, 2) sizer.Add(SimpleText(panel, 'Scan Name:'), (ir, 2), (1, 1), LEFT_CEN, 2) sizer.Add(self.scanname, (ir, 3), (1, 2), LEFT_CEN, 2) ir += 1 sizer.Add(SimpleText(panel, 'Position Name'), (ir, 0), (1, 2), LEFT_CEN, 2) sizer.Add(SimpleText(panel, 'Include?'), (ir, 2), (1, 1), LEFT_CEN, 2) sizer.Add(SimpleText(panel, 'Nscans'), (ir, 3), (1, 1), LEFT_CEN, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(500, 2)), (ir, 0), (1, 4), LEFT_CEN, 2) ir += 1 for pname in positions: self.pos_names.append(pname) label = SimpleText(panel, " %s " % pname) cbox = self.wid_include[pname] = wx.CheckBox(panel, -1, "") cbox.SetValue(True) nscans = self.wid_nscans[pname] = add_choice(panel, _nscans, size=(50, -1)) nscans.SetStringSelection('1') sizer.Add(label, (ir, 0), (1, 2), LEFT_CEN, 2) sizer.Add(cbox, (ir, 2), (1, 1), LEFT_CEN, 2) sizer.Add(nscans, (ir, 3), (1, 1), LEFT_CEN, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(500, 2)), (ir, 0), (1, 4), LEFT_CEN, 2) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, ALL_EXP | wx.GROW | wx.ALIGN_LEFT, 1) pack(self, mainsizer) self.SetMinSize((450, 550)) self.SetSize((525, 600)) self.Raise() self.Show() self.onScanType()
def make_linetrace_panel(self, parent, font=None): """colours and line properties""" panel = scrolled.ScrolledPanel(parent, size=(900, 250), style=wx.GROW | wx.TAB_TRAVERSAL, name='p1') if font is None: font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False) sizer = wx.GridBagSizer(2, 2) i = 0 ax = self.axes[0] if matplotlib.__version__ < '2.0': axis_bgcol = ax.get_axis_bgcolor() else: axis_bgcol = ax.get_facecolor() labstyle = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL opts = dict(size=(-1, 25), style=labstyle) ctitle = wx.StaticText(panel, -1, 'Colors: ') ltheme = wx.StaticText(panel, -1, 'Use Color Theme: ') themes = list(self.conf.color_themes.keys()) coltheme = wx.Choice(panel, choices=themes, size=(100, -1)) coltheme.SetStringSelection(self.conf.color_theme) coltheme.Bind(wx.EVT_CHOICE, self.onColorThemeStyle) textcol = csel.ColourSelect(panel, label=" Text ", colour=mpl_color(self.conf.textcolor), **opts) gridcol = csel.ColourSelect(panel, label=" Grid ", colour=mpl_color(self.conf.gridcolor), **opts) bgcol = csel.ColourSelect(panel, label=" Background ", colour=mpl_color(axis_bgcol), **opts) fbgcol = csel.ColourSelect(panel, label=" Outer Frame ", colour=mpl_color( self.canvas.figure.get_facecolor()), **opts) self.colwids = { 'text': textcol, 'bg': bgcol, 'grid': gridcol, 'frame': fbgcol } bgcol.Bind(csel.EVT_COLOURSELECT, partial(self.onColor, item='bg')) fbgcol.Bind(csel.EVT_COLOURSELECT, partial(self.onColor, item='frame')) gridcol.Bind(csel.EVT_COLOURSELECT, partial(self.onColor, item='grid')) textcol.Bind(csel.EVT_COLOURSELECT, partial(self.onColor, item='text')) show_grid = wx.CheckBox(panel, -1, ' Show Grid ', (-1, -1), (-1, -1)) show_grid.Bind(wx.EVT_CHECKBOX, self.onShowGrid) show_grid.SetValue(self.conf.show_grid) show_box = wx.CheckBox(panel, -1, ' Show Top/Right Axes ', (-1, -1), (-1, -1)) show_box.Bind(wx.EVT_CHECKBOX, self.onShowBox) show_box.SetValue(self.conf.axes_style == 'box') csizer = wx.BoxSizer(wx.HORIZONTAL) csizer.Add(ctitle, 0, labstyle, 3) csizer.Add(textcol, 0, labstyle, 3) csizer.Add(gridcol, 0, labstyle, 3) csizer.Add(bgcol, 0, labstyle, 3) csizer.Add(fbgcol, 0, labstyle, 3) csizer.Add(ltheme, 1, labstyle, 3) csizer.Add(coltheme, 1, labstyle, 3) csizer.Add(show_grid, 0, labstyle, 3) csizer.Add(show_box, 0, labstyle, 3) sizer.Add(csizer, (1, 0), (1, 9), labstyle, 2) reset_btn = wx.Button(panel, label='Reset Line Colors', size=(200, -1)) reset_btn.Bind(wx.EVT_BUTTON, self.onResetLines) sizer.Add(reset_btn, (2, 1), (1, 4)) irow = 3 for t in ('#', 'Label', 'Color', 'Style', 'Thickness', 'Symbol', ' Size', 'Z Order', 'Join Style'): x = wx.StaticText(panel, -1, t) x.SetFont(font) sizer.Add(x, (irow, i), (1, 1), wx.ALIGN_LEFT | wx.ALL, 3) i = i + 1 self.trace_labels = [] ntrace_display = min(self.conf.ntrace + 2, len(self.conf.traces)) for i in range(ntrace_display): irow += 1 label = "trace %i" % i lin = self.conf.traces[i] dlab = lin.label dcol = hexcolor(lin.color) dthk = lin.linewidth dmsz = lin.markersize dsty = lin.style djsty = lin.drawstyle dzord = lin.zorder dsym = lin.marker lab = LabelEntry(panel, dlab, size=125, labeltext="%i" % (i + 1), action=partial(self.onText, item='trace', trace=i)) self.trace_labels.append(lab) col = csel.ColourSelect(panel, -1, "", dcol, size=(25, 25)) col.Bind(csel.EVT_COLOURSELECT, partial(self.onColor, trace=i)) self.colwids[i] = col thk = FloatSpin(panel, -1, pos=(-1, -1), size=(FSPINSIZE, 25), value=dthk, min_val=0, max_val=10, increment=0.5, digits=1) thk.Bind(EVT_FLOATSPIN, partial(self.onThickness, trace=i)) sty = wx.Choice(panel, choices=self.conf.styles, size=(100, -1)) sty.Bind(wx.EVT_CHOICE, partial(self.onStyle, trace=i)) sty.SetStringSelection(dsty) msz = FloatSpin(panel, -1, pos=(-1, -1), size=(FSPINSIZE, 25), value=dmsz, min_val=0, max_val=30, increment=1, digits=0) msz.Bind(EVT_FLOATSPIN, partial(self.onMarkerSize, trace=i)) zor = FloatSpin(panel, -1, pos=(-1, -1), size=(FSPINSIZE, 25), value=dzord, min_val=-500, max_val=500, increment=1, digits=0) zor.Bind(EVT_FLOATSPIN, partial(self.onZorder, trace=i)) sym = wx.Choice(panel, -1, choices=self.conf.symbols, size=(120, -1)) sym.Bind(wx.EVT_CHOICE, partial(self.onSymbol, trace=i)) sym.SetStringSelection(dsym) jsty = wx.Choice(panel, -1, choices=self.conf.drawstyles, size=(100, -1)) jsty.Bind(wx.EVT_CHOICE, partial(self.onJoinStyle, trace=i)) jsty.SetStringSelection(djsty) sizer.Add(lab.label, (irow, 0), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(lab, (irow, 1), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(col, (irow, 2), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(sty, (irow, 3), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(thk, (irow, 4), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(sym, (irow, 5), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(msz, (irow, 6), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(zor, (irow, 7), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) sizer.Add(jsty, (irow, 8), (1, 1), wx.ALIGN_LEFT | wx.ALL, 5) autopack(panel, sizer) panel.SetupScrolling() return panel
def __init__(self, parent): super(VerificationPanel, self).__init__(parent) self.face_ids = { 'face_id': None, 'another_face_id': None, 'person_face_id': None, } self.person_group_id = str(uuid.uuid1()) self.person_name = None self.person_id = None self.face_paths = [] self.detected_face_paths = [] self.vsizer = wx.BoxSizer(wx.VERTICAL) self.panel = scrolled.ScrolledPanel(self) self.hsizer = wx.BoxSizer() self.hsizer.AddStretchSpacer() self.hvsizer = wx.BoxSizer(wx.VERTICAL) self.hvsizer.SetMinSize((util.INNER_PANEL_WIDTH, -1)) label = ( "Demo 1: Face-to-face verification determines whether " "two faces belong to the same person. Choose two images " "with a single face each. Then click 'Verify' to get " "the verification result." ) self.static_text = wx.StaticText(self.panel, label=label) self.static_text.Wrap(util.INNER_PANEL_WIDTH) self.hvsizer.Add(self.static_text, 0, wx.ALL, 0) self.vhsizer1 = wx.BoxSizer() self.lsizer1 = wx.BoxSizer(wx.VERTICAL) self.lsizer1.SetMinSize((util.MAX_IMAGE_SIZE, -1)) flag = wx.EXPAND | wx.ALIGN_CENTER | wx.ALL self.btn_face2face_1 = wx.Button(self.panel, label='Choose Image') self.lsizer1.Add(self.btn_face2face_1, 0, flag, 5) flag = wx.ALIGN_CENTER | wx.ALL self.bitmap_face2face_1 = base.MyStaticBitmap(self.panel) self.lsizer1.Add(self.bitmap_face2face_1, 0, flag, 5) self.btn_face2face_1.Bind( wx.EVT_BUTTON, lambda evt: self.OnChooseImage( evt, self.bitmap_face2face_1, 'face_id')) self.vhsizer1.Add(self.lsizer1, 1, wx.EXPAND) self.msizer1 = wx.BoxSizer(wx.VERTICAL) self.msizer1.SetMinSize((90, -1)) self.btn_verify_1 = wx.Button(self.panel, label='Verify') self.msizer1.Add(self.btn_verify_1, 0, wx.EXPAND | wx.ALL, 5) self.result_1 = wx.StaticText(self.panel, label='Results:') self.msizer1.Add(self.result_1, 0, wx.EXPAND | wx.ALL, 5) self.btn_verify_1.Bind( wx.EVT_BUTTON, lambda evt: self.OnVerify(evt, 'face2face', self.result_1)) self.vhsizer1.Add(self.msizer1, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.rsizer1 = wx.BoxSizer(wx.VERTICAL) self.rsizer1.SetMinSize((util.MAX_IMAGE_SIZE, -1)) flag = wx.EXPAND | wx.ALIGN_CENTER | wx.ALL self.btn_face2face_2 = wx.Button(self.panel, label='Choose Image') self.rsizer1.Add(self.btn_face2face_2, 0, flag, 5) flag = wx.ALIGN_CENTER | wx.ALL self.bitmap_face2face_2 = base.MyStaticBitmap(self.panel) self.rsizer1.Add(self.bitmap_face2face_2, 0, flag, 5) self.btn_face2face_2.Bind( wx.EVT_BUTTON, lambda evt: self.OnChooseImage( evt, self.bitmap_face2face_2, 'another_face_id')) self.vhsizer1.Add(self.rsizer1, 1, wx.EXPAND) self.hvsizer.Add(self.vhsizer1) label = ( "Demo 2: Face-to-person verification determines whether a " "face belongs to a given person. Click 'Load Person' to " "pick a folder containing the images of one person's face. " "Next, click 'Choose Image' to pick a face image of the " "same person (or of a different person). Finally, click " "'Verify' to see the verification result." ) self.static_text = wx.StaticText(self.panel, label=label) self.static_text.Wrap(util.INNER_PANEL_WIDTH) self.hvsizer.Add(self.static_text, 0, wx.ALL, 0) self.vhsizer2 = wx.BoxSizer() self.lsizer2 = wx.BoxSizer(wx.VERTICAL) self.lsizer2.SetMinSize((util.MAX_IMAGE_SIZE, -1)) flag = wx.EXPAND | wx.ALIGN_CENTER | wx.ALL self.btn_face2person_1 = wx.Button(self.panel, label='Load Person') self.lsizer2.Add(self.btn_face2person_1, 0, flag, 5) self.Bind(wx.EVT_BUTTON, self.OnChooseFolder, self.btn_face2person_1) flag = wx.ALIGN_CENTER | wx.ALL self.grid = base.MyGridStaticBitmap(self.panel, 0, 4, 0, 0) self.lsizer2.Add(self.grid, 0, flag, 5) self.vhsizer2.Add(self.lsizer2, 1, wx.EXPAND) self.msizer2 = wx.BoxSizer(wx.VERTICAL) self.msizer2.SetMinSize((90, -1)) self.btn_verify_2 = wx.Button(self.panel, label='Verify') self.msizer2.Add(self.btn_verify_2, 0, wx.EXPAND | wx.ALL, 5) self.result_2 = wx.StaticText(self.panel, label='Results:') self.msizer2.Add(self.result_2, 0, wx.EXPAND | wx.ALL, 5) self.btn_verify_2.Bind( wx.EVT_BUTTON, lambda evt: self.OnVerify(evt, 'face2person', self.result_2)) self.vhsizer2.Add(self.msizer2, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.rsizer2 = wx.BoxSizer(wx.VERTICAL) self.rsizer2.SetMinSize((util.MAX_IMAGE_SIZE, -1)) flag = wx.EXPAND | wx.ALIGN_CENTER | wx.ALL self.btn_face2person_2 = wx.Button(self.panel, label='Choose Image') self.rsizer2.Add(self.btn_face2person_2, 0, flag, 5) flag = wx.ALIGN_CENTER | wx.ALL self.bitmap_face2person = base.MyStaticBitmap(self.panel) self.rsizer2.Add(self.bitmap_face2person, 0, flag, 5) self.btn_face2person_2.Bind( wx.EVT_BUTTON, lambda evt: self.OnChooseImage( evt, self.bitmap_face2person, 'person_face_id')) self.vhsizer2.Add(self.rsizer2, 1, wx.EXPAND) self.hvsizer.Add(self.vhsizer2) self.hsizer.Add(self.hvsizer) self.hsizer.AddStretchSpacer() self.hsizer.Layout() self.panel.SetSizer(self.hsizer) self.panel.Layout() self.panel.SetupScrolling(scroll_x=False) self.vsizer.Add(self.panel, 3, wx.EXPAND) self.log = base.MyLog(self) self.vsizer.Add(self.log, 1, wx.EXPAND) self.SetSizerAndFit(self.vsizer) self.btn_verify_1.Disable() self.btn_verify_2.Disable()
def __init__(self, parent): wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title=u"Ключи") self.btn = wx.Button(self, wx.ID_REFRESH) self.btn1 = wx.Button(self, wx.ID_SAVE) self.btn2 = wx.Button(self,-1, u"Считать ключ") self.btn3 = wx.Button(self, wx.ID_CLEAR) sizer = wx.BoxSizer(wx.VERTICAL) # Текущий элемент self.fieldnow = None sizer_1 = wx.BoxSizer(wx.HORIZONTAL) panel1 = scrolled.ScrolledPanel(self, -1, size=(550, 550), style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel1" ) fgs1 = wx.FlexGridSizer(cols=4, vgap=4, hgap=4) label = [] self.keys = [] label2 = [] self.sections = [] for i in range(0,128): label.append(wx.StaticText(panel1, -1, u"Ключ %s" % (i+1))) self.keys.append(wx.TextCtrl(panel1, -1, '', size=(200,-1))) label2.append(wx.StaticText(panel1, -1, u"Раздел")) self.sections.append(wx.SpinCtrl(panel1, -1, "", (10, -1))) self.sections[i].SetRange(0,8) fgs1.Add(label[i], flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10) fgs1.Add(self.keys[i], flag=wx.RIGHT, border=10) fgs1.Add(label2[i], flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10) fgs1.Add(self.sections[i], flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10) self.keys[i].Bind(wx.EVT_KILL_FOCUS, self.OnTextCtrlKillFocus) self.keys[i].Bind(wx.EVT_SET_FOCUS, self.OnTextCtrlSetFocus) panel1.SetSizer( fgs1 ) panel1.SetAutoLayout(1) panel1.SetupScrolling() sizer_1.Add(panel1,0) sizer.Add(sizer_1,0, wx.ALL|wx.ALIGN_LEFT, border=20) sizer_2 = wx.BoxSizer(wx.HORIZONTAL) sizer_2.Add(self.btn,0) sizer_2.Add(self.btn1,0) sizer_2.Add(self.btn2,0) sizer_2.Add(self.btn3,0) sizer.Add(sizer_2,0, wx.ALL|wx.ALIGN_LEFT, border=20) self.SetSizer(sizer) wx.CallAfter(self.Layout) self.Bind(wx.EVT_BUTTON, self.Read, self.btn) self.Bind(wx.EVT_BUTTON, self.Write, self.btn1) self.Bind(wx.EVT_BUTTON, self.ReadKey, self.btn2) self.Bind(wx.EVT_BUTTON, self.ClearKey, self.btn3)
def __init__(self, parent): super(Licenses, self).__init__(parent, title="Licenses", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.scrolled_panel = sp.ScrolledPanel(self) mono_font = wx.Font() mono_font.SetFamily(wx.FONTFAMILY_TELETYPE) info = wx.StaticText( self.scrolled_panel, label=("DisableWinTracking uses a number of open source software." "The following are the licenses for these software.")) wxw = wx.StaticText( self.scrolled_panel, label=( "DisableWinTracking uses wxWidgets and wxPython. Their license " "is below\nMore info at https://www.wxwidgets.org/about/")) wxw_license = """ wxWindows Library Licence, Version 3.1 ====================================== Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al Everyone is permitted to copy and distribute verbatim copies of this licence document, but changing it is not allowed. WXWINDOWS LIBRARY LICENCE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public Licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public Licence for more details. You should have received a copy of the GNU Library General Public Licence along with this software, usually in a file named COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. EXCEPTION NOTICE 1. As a special exception, the copyright holders of this library give permission for additional uses of the text contained in this release of the library as licenced under the wxWindows Library Licence, applying either version 3.1 of the Licence, or (at your option) any later version of the Licence as published by the copyright holders of version 3.1 of the Licence document. 2. The exception is that you may use, copy, link, modify and distribute under your own terms, binary object code versions of works based on the Library. 3. If you copy code from files distributed under the terms of the GNU General Public Licence or the GNU Library General Public Licence into a copy of this library, as this licence permits, the exception does not apply to the code that you add in this way. To avoid misleading anyone as to the status of such modified files, you must delete this exception notice from such code and/or adjust the licensing conditions notice accordingly. 4. If you write modifications of your own for this library, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, you must delete the exception notice from such code and/or adjust the licensing conditions notice accordingly.""" wxw_text = wx.StaticText(self.scrolled_panel, label=wxw_license) wxw_text.SetFont(mono_font) pywin = wx.StaticText( self.scrolled_panel, label="DisableWinTracking uses PyWin32. Its license is below.") pywin_license = """ Unless stated in the specfic source file, this work is Copyright (c) 1996-2008, Greg Stein and Mark Hammond. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither names of Greg Stein, Mark Hammond nor the name of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.""" pywin_text = wx.StaticText(self.scrolled_panel, label=pywin_license) pywin_text.SetFont(mono_font) self.top_sizer = wx.BoxSizer(wx.VERTICAL) self.scroll_sizer = wx.BoxSizer(wx.VERTICAL) self.scroll_sizer.Add(info, 0, wx.ALL, 2) self.scroll_sizer.Add(wxw, 0, wx.ALL, 2) self.scroll_sizer.Add(wxw_text, 0, wx.EXPAND | wx.ALL, 3) self.scroll_sizer.Add(pywin, 0, wx.ALL, 2) self.scroll_sizer.Add(pywin_text, 0, wx.EXPAND | wx.ALL, 3) self.top_sizer.Add(self.scrolled_panel, 1, wx.EXPAND) self.SetSizerAndFit(self.top_sizer) self.scrolled_panel.SetSizerAndFit(self.scroll_sizer) self.scrolled_panel.SetupScrolling() self.Show()
def __init__(self, parent): wx.adv.WizardPageSimple.__init__(self, parent) self.expectedFieldCol = None border = 4 vbs = wx.BoxSizer(wx.VERTICAL) vbs.Add(wx.StaticText( self, wx.ID_ANY, _('Specify the spreadsheet columns corresponding to the Results fields.' )), flag=wx.ALL, border=border) vbs.Add(wx.StaticText( self, wx.ID_ANY, _('You should define Pos, LastName, Category and License (at least).' )), flag=wx.ALL, border=border) vbs.Add(wx.StaticText( self, wx.ID_ANY, _('You must also define a Time column if you are Scoring by Time.') ), flag=wx.ALL, border=border) vbs.AddSpacer(8) border = 4 # Create a map for the field names we are looking for # and the headers we found in the Excel sheet. sp = scrolled.ScrolledPanel(self, wx.ID_ANY, size=(750, 64), style=wx.TAB_TRAVERSAL) boldFont = None gs = wx.GridSizer(2, len(Fields), 4, 4) for c, f in enumerate(Fields): label = wx.StaticText(sp, label=f) if boldFont is None: font = label.GetFont() boldFont = wx.Font(font.GetPointSize() + 1, font.GetFamily(), font.GetStyle(), wx.FONTWEIGHT_BOLD) label.SetFont(boldFont) gs.Add(label) self.headers = [] self.choices = [] for c, f in enumerate(Fields): self.choices.append(wx.Choice(sp, -1, choices=self.headers)) gs.Add(self.choices[-1]) sp.SetSizer(gs) sp.SetAutoLayout(1) sp.SetupScrolling(scroll_y=False) self.sp = sp self.gs = gs vbs.Add(sp, flag=wx.ALL, border=border) self.SetSizer(vbs)
def __init__(self, parent=None, pos=(-1, -1), inst=None, db=None, page=None): title = 'New Position' if inst is not None: title = 'New Position for Instrument %s ' % inst.name style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL wx.Frame.__init__(self, None, -1, title, size=(350, 450), style=style, pos=pos) self.Handle_FocusEvents() panel = scrolled.ScrolledPanel(self, size=(400, 500), style=wx.GROW|wx.TAB_TRAVERSAL) colors = GUIColors() font = self.GetFont() if parent is not None: font = parent.GetFont() titlefont = font titlefont.PointSize += 1 titlefont.SetWeight(wx.BOLD) panel.SetBackgroundColour(colors.bg) self.parent = parent self.page = page self.db = db self.inst = db.get_instrument(inst) STY = wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL LSTY = wx.ALIGN_LEFT|wx.GROW|wx.ALL|wx.ALIGN_CENTER_VERTICAL RSTY = wx.ALIGN_RIGHT|STY CSTY = wx.ALIGN_CENTER|STY CEN = wx.ALIGN_CENTER|wx.GROW|wx.ALL LEFT = wx.ALIGN_LEFT|wx.GROW|wx.ALL self.name = wx.TextCtrl(panel, value='', size=(200, -1)) sizer = wx.GridBagSizer(12, 3) ir = 0 sizer.Add(SimpleText(panel, " New Position for '%s'" % self.inst.name, font=titlefont, colour=colors.title), (ir, 0), (1, 2), LSTY, 2) ir += 1 sizer.Add(SimpleText(panel, 'Position Name:'), (ir, 0), (1, 1), LSTY, 2) sizer.Add(self.name, (ir, 1), (1, 2), LSTY, 2) ir += 1 sizer.Add(SimpleText(panel, 'PV Name:'), (ir, 0), (1, 1), LSTY, 2) sizer.Add(SimpleText(panel, 'Position:'), (ir, 1), (1, 1), LSTY, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL), (ir, 0), (1, 3), CEN, 2) self.positions = [] ir += 1 for p in self.inst.pvs: val = wx.TextCtrl(panel, value='', size=(150, -1)) sizer.Add(SimpleText(panel, p.name), (ir, 0), (1, 1), LSTY, 2) sizer.Add(val, (ir, 1), (1, 1), LSTY, 2) self.positions.append(val) ir += 1 sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL), (ir, 0), (1, 3), CEN, 2) btn_panel = wx.Panel(panel, size=(75, -1)) btn_sizer = wx.BoxSizer(wx.HORIZONTAL) btn_ok = add_button(btn_panel, 'OK', size=(70, -1), action=self.onOK) btn_cancel = add_button(btn_panel, 'Cancel', size=(70, -1), action=self.onCancel) btn_sizer.Add(btn_ok, 0, wx.ALIGN_LEFT, 2) btn_sizer.Add(btn_cancel, 0, wx.ALIGN_RIGHT, 2) pack(btn_panel, btn_sizer) ir += 1 sizer.Add(btn_panel, (ir, 0), (1, 3), CEN, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(195, -1), style=wx.LI_HORIZONTAL), (ir, 0), (1, 3), CEN, 2) pack(panel, sizer) panel.SetupScrolling() self.Layout() self.Show() self.Raise()
def __init__(self, parent=None, id=-1, title="Message", msg="", iconFP="", font=None, pos=None, size=(300, 200), flagOkayBtn=True, flagCancelBtn=False, flagDefOK=False): if DEBUG: print("PopupDialog.__init__()") ### init Dialog wx.Dialog.__init__(self, parent, id, title) self.SetSize(size) if pos == None: self.Center() else: self.SetPosition(pos) self.Center() # init panel panel = sPanel.ScrolledPanel(self, -1, pos=(0, 0), size=size) ### font setup if font == None: font = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL, False, "Arial", wx.FONTENCODING_SYSTEM) ##### [begin] set up widgets ----- gbs = wx.GridBagSizer(0, 0) row = 0 col = 0 ### icon image if iconFP != "" and path.isfile(iconFP) == True: bmp = wx.Bitmap(wxLoadImg(iconFP)) icon_sBmp = wx.StaticBitmap(panel, -1, bmp) iconBMPsz = icon_sBmp.GetBitmap().GetSize() add2gbs(gbs, icon_sBmp, (row, col), (1, 1)) col += 1 else: iconFP = "" iconBMPsz = (0, 0) ### message to show sTxt = wx.StaticText(panel, -1, label=msg) sTxt.SetSize((size[0] - max(iconBMPsz[0], 100) - 50, -1)) sTxt.SetFont(font) if iconFP == "": sTxt.Wrap(size[0] - 30) else: sTxt.Wrap(size[0] - iconBMPsz[0] - 30) if iconFP == "": _span = (1, 2) else: _span = _span = (1, 1) add2gbs(gbs, sTxt, (row, col), _span) ### okay button row += 1 col = 0 btn = wx.Button(panel, wx.ID_OK, "OK", size=(100, -1)) add2gbs(gbs, btn, (row, col), (1, 1)) if flagOkayBtn: # okay button is shown if flagCancelBtn == False or flagDefOK == True: # cancel button won't be made or default-okay is set True panel.Bind(wx.EVT_KEY_DOWN, self.onKeyPress) btn.SetDefault() else: btn.Hide() ### cancel button col += 1 if flagCancelBtn: btn = wx.Button(panel, wx.ID_CANCEL, "Cancel", size=(100, -1)) add2gbs(gbs, btn, (row, col), (1, 1)) else: sTxt = wx.StaticText(panel, -1, label=" ") add2gbs(gbs, sTxt, (row, col), (1, 1)) ### lay out panel.SetSizer(gbs) gbs.Layout() panel.SetupScrolling()
def __init__(self, parent, group, on_ok=None): self.parent = parent self.group = group self.on_ok = on_ok wx.Frame.__init__(self, None, -1, 'Add Selected Columns', style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetFont(Font(10)) sizer = wx.GridBagSizer(2, 2) panel = scrolled.ScrolledPanel(self) self.SetMinSize((550, 550)) self.wids = {} lab_aname = SimpleText(panel, label=' Save Array Name:') lab_range = SimpleText(panel, label=' Use column index:') lab_regex = SimpleText(panel, label=' Use column label:') wids = self.wids = {} wids['arrayname'] = wx.TextCtrl(panel, value='sum', size=(175, -1)) wids['tc_nums'] = wx.TextCtrl(panel, value='1,3-10', size=(175, -1)) wids['tc_regex'] = wx.TextCtrl(panel, value='*fe*', size=(175, -1)) savebtn = Button(panel, 'Save', action=self.onOK) plotbtn = Button(panel, 'Plot Sum', action=self.onPlot) sel_nums = Button(panel, 'Select by Index', action=self.onSelColumns) sel_re = Button(panel, 'Select by Pattern', action=self.onSelRegex) sizer.Add(lab_aname, (0, 0), (1, 2), LEFT, 3) sizer.Add(wids['arrayname'], (0, 2), (1, 1), LEFT, 3) sizer.Add(plotbtn, (0, 3), (1, 1), LEFT, 3) sizer.Add(savebtn, (0, 4), (1, 1), LEFT, 3) sizer.Add(lab_range, (1, 0), (1, 2), LEFT, 3) sizer.Add(wids['tc_nums'], (1, 2), (1, 1), LEFT, 3) sizer.Add(sel_nums, (1, 3), (1, 2), LEFT, 3) sizer.Add(lab_regex, (2, 0), (1, 2), LEFT, 3) sizer.Add(wids['tc_regex'], (2, 2), (1, 1), LEFT, 3) sizer.Add(sel_re, (2, 3), (1, 2), LEFT, 3) sizer.Add(HLine(panel, size=(550, 2)), (3, 0), (1, 5), LEFT, 3) ir = 4 cind = SimpleText(panel, label=' Index ') csel = SimpleText(panel, label=' Select ') cname = SimpleText(panel, label=' Array Name ') sizer.Add(cind, (ir, 0), (1, 1), LEFT, 3) sizer.Add(csel, (ir, 1), (1, 1), LEFT, 3) sizer.Add(cname, (ir, 2), (1, 3), LEFT, 3) for i, name in enumerate(group.array_labels): ir += 1 cind = SimpleText(panel, label=' %i ' % (i + 1)) cname = SimpleText(panel, label=' %s ' % name) csel = Check(panel, label='', default=False) self.wids["col_%d" % i] = csel sizer.Add(cind, (ir, 0), (1, 1), LEFT, 3) sizer.Add(csel, (ir, 1), (1, 1), LEFT, 3) sizer.Add(cname, (ir, 2), (1, 3), LEFT, 3) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, wx.GROW | wx.ALL, 1) pack(self, mainsizer) self.Show() self.Raise()
def __init__(self, parent): self.MyName = "STATISTICS" # parent is the main frame of PyCorrFit self.boxsizerlist = list() self.parent = parent # Get the window positioning correctly pos = self.parent.GetPosition() pos = (pos[0] + 100, pos[1] + 100) wx.Frame.__init__(self, parent=self.parent, title="Statistics", pos=pos, size=(700, 600), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT) ## MYID # This ID is given by the parent for an instance of this class self.MyID = None self.MyName = "STATISTICS" # List of parameters that are plotted or not self.PlotParms = list(["None", 0]) # Page - the currently active page of the notebook. self.Page = self.parent.notebook.GetCurrentPage() # Pagenumbers self.PageNumbers = range(1, 1 + self.parent.notebook.GetPageCount()) ## Splitter window. left side: checkboxes ## right side: plot with parameters self.sp = wx.SplitterWindow(self, style=wx.SP_3DSASH) # This is necessary to prevent "Unsplit" of the SplitterWindow: self.sp.SetMinimumPaneSize(1) ## Content # We will display a dialog that conains all the settings # - Which model we want statistics on # - What kind of parameters should be printed # (We will get the parameters from the current page) # If on another page, the parameter is not available, # do not make a mess out of it. # Then the user presses a button and sees/saves the table # with all the info. self.panel = scrolled.ScrolledPanel(self.sp) self.panel.SetupScrolling(scroll_y=True) # Parameter settings. if self.parent.notebook.GetPageCount() != 0: self.InfoClass = InfoClass(CurPage=self.Page) else: self.panel.Disable() # A dropdown menu for the source Page: text = wx.StaticText(self.panel, label="Create a table with all the selected\n" + "variables below from pages with the\n" + "same model as the current page.") ## Page selection as in average tool Pagetext = wx.StaticText(self.panel, label="Curves ") Psize = text.GetSize()[0] / 2 self.WXTextPages = wx.TextCtrl(self.panel, value="", size=(Psize, -1)) # Set number of pages pagenumlist = list() for i in np.arange(self.parent.notebook.GetPageCount()): Page = self.parent.notebook.GetPage(i) pagenumlist.append(int(filter(lambda x: x.isdigit(), Page.counter))) valstring = misc.parsePagenum2String(pagenumlist) self.WXTextPages.SetValue(valstring) ## Plot parameter dropdown box self.PlotParms = self.GetListOfPlottableParms() Parmlist = self.PlotParms DDtext = wx.StaticText(self.panel, label="Plot parameter ") self.WXDropdown = wx.ComboBox(self.panel, -1, "", size=(Psize, -1), choices=Parmlist, style=wx.CB_DROPDOWN | wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnDropDown, self.WXDropdown) self.Bind(wx.EVT_TEXT, self.OnDropDown, self.WXTextPages) self.WXDropdown.SetSelection(0) ## Show Average and SD textavg = wx.StaticText(self.panel, label="Average ") textsd = wx.StaticText(self.panel, label="Standard deviation ") self.WXavg = wx.TextCtrl(self.panel, size=(Psize, -1)) self.WXsd = wx.TextCtrl(self.panel, size=(Psize, -1)) self.WXavg.SetEditable(False) self.WXsd.SetEditable(False) # Create space for parameters self.box = wx.StaticBox(self.panel, label="Export parameters") self.masterboxsizer = wx.StaticBoxSizer(self.box, wx.VERTICAL) self.masterboxsizer.Add(text) self.boxsizer = wx.BoxSizer(wx.HORIZONTAL) self.masterboxsizer.Add(self.boxsizer) self.Checkboxes = list() self.Checklabels = list() if self.parent.notebook.GetPageCount() != 0: self.OnChooseValues() self.btnSave = wx.Button(self.panel, wx.ID_ANY, 'Save') self.Bind(wx.EVT_BUTTON, self.OnSaveTable, self.btnSave) # Add elements to sizer self.topSizer = wx.BoxSizer(wx.VERTICAL) GridAll = wx.FlexGridSizer(rows=4, cols=2, vgap=5, hgap=5) GridAll.Add(Pagetext) GridAll.Add(self.WXTextPages) GridAll.Add(DDtext) GridAll.Add(self.WXDropdown) GridAll.Add(textavg) GridAll.Add(self.WXavg) GridAll.Add(textsd) GridAll.Add(self.WXsd) #Psizer = wx.BoxSizer(wx.HORIZONTAL) #Psizer.Add(Pagetext) #Psizer.Add(self.WXTextPages) #DDsizer = wx.BoxSizer(wx.HORIZONTAL) #DDsizer.Add(DDtext) #DDsizer.Add(self.WXDropdown) #self.topSizer.Add(Psizer) #self.topSizer.Add(DDsizer) self.topSizer.Add(GridAll) self.topSizer.Add(self.masterboxsizer) self.topSizer.Add(self.btnSave) # Set size of window self.panel.SetSizer(self.topSizer) self.topSizer.Fit(self.panel) px = self.topSizer.GetMinSizeTuple()[0] ## Plotting panel self.canvas = plot.PlotCanvas(self.sp) self.canvas.SetEnableZoom(True) self.sp.SplitVertically(self.panel, self.canvas, px + 5) ## Icon if parent.MainIcon is not None: wx.Frame.SetIcon(self, parent.MainIcon) self.Show(True) self.OnDropDown()
'Permite la visualización del panel' self.panel.Hide() self.panel = paneltemp self.sizerbody.Add(self.panel, 0, wx.EXPAND | wx.ALL, border=0) self.panel.Show(True) self.Layout() self.parent.Refresh() self.parent.Update() ##----------------------------------------------------------- app = wx.App(False) displaySize = wx.DisplaySize() frame = wx.Frame(None, wx.ID_ANY, 'Full display size', pos=(0, 0), size=(displaySize[0], displaySize[1])) menubar = wx.MenuBar() topPanel = scrolled.ScrolledPanel(frame) topPanel.SetupScrolling(scroll_y=True) topPanel.SetBackgroundColour('3399FF') sizertopPanel = wx.BoxSizer(wx.VERTICAL) sizertopPanel.Add(HeadLow.Head(topPanel), 0, wx.EXPAND | wx.ALL, border=10) sizertopPanel.Add(Body(topPanel), 0, wx.EXPAND | wx.ALL, border=10) sizertopPanel.Add(HeadLow.Low(topPanel), 0, wx.EXPAND | wx.ALL, border=10) topPanel.SetSizer(sizertopPanel) frame.Show() app.MainLoop()
def __init__(self, title): wx.Frame.__init__(self, None, title=title, size=(1400, 700), style=wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.CAPTION) self._db = DB() max_row = self._db.get_row() get_all = self._db.get_all() field = FormField() # menubar = field.setMenuBar() self.Bind(wx.EVT_CLOSE, self.onClose) self.panel = wx.Panel(self) self.panel.SetBackgroundColour("STEEL BLUE") form_panel = wx.Panel(self.panel, size=(1300, 40)) form_panel.SetBackgroundColour("STEEL BLUE") hbox = wx.BoxSizer(wx.HORIZONTAL) vbox = wx.BoxSizer(wx.VERTICAL) refresh_panel = wx.Panel(self.panel, size=(1300, 200)) # header = wx.Panel(self.panel, size=(1400, 80), style=wx.RAISED_BORDER) # header.SetBackgroundColour("MEDIUM SLATE BLUE") # font = wx.Font(30, wx.ROMAN, wx.ITALIC, wx.FONTWEIGHT_BOLD) # self.header_title = wx.StaticText(header, 1, "Banana Data System", style = wx.ALIGN_CENTER, size=(1200, 200)) # self.header_title.SetFont(font) # vbox.Add(header, 0, wx.SHAPED, 0) label_data = wx.Font(14, wx.ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.refresh_btn = wx.Button(refresh_panel, label='Refresh', size=(100, 30)) hbox.Add(self.refresh_btn, 0, wx.ALIGN_CENTER_VERTICAL, 50) self.Bind(wx.EVT_BUTTON, lambda event: self.refreshFrame(event), self.refresh_btn) self.connect_btn = wx.Button(refresh_panel, label='Connect', size=(100, 30)) hbox.Add(self.connect_btn, 1, wx.ALIGN_CENTER_VERTICAL, 50) self.Bind(wx.EVT_BUTTON, lambda event: self.showConnectDiag(event), self.connect_btn) # refresh_panel.SetSizer(hbox) vbox.Add(hbox, 0, wx.ALIGN_TOP, 50) label_font = wx.Font(20, wx.ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) label_data = wx.Font(14, wx.ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) fgs = wx.FlexGridSizer(int(max_row[0]) + 1, 9, 20, 50) self.scrolled_panel = scrolled.ScrolledPanel(self.panel, -1, size=(1300, 300), style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER, name="panel1") self.scrolled_panel.SetBackgroundColour("STEEL BLUE") self.scrolled_panel.SetAutoLayout(1) self.scrolled_panel.SetupScrolling() self._width = wx.StaticText(form_panel, label="Width") self._width.SetFont(label_font) self._height = wx.StaticText(form_panel, label="Height") self._height.SetFont(label_font) self._weight = wx.StaticText(form_panel, label="Weight") self._weight.SetFont(label_font) self._image = wx.StaticText(form_panel, label="Front") self._image.SetFont(label_font) self._filter = wx.StaticText(form_panel, label="Back") self._filter.SetFont(label_font) self._status = wx.StaticText(form_panel, label="Status") self._status.SetFont(label_font) self._quality = wx.StaticText(form_panel, label="Quality") self._quality.SetFont(label_font) self._ripen = wx.StaticText(form_panel, label="Ripen") self._ripen.SetFont(label_font) self._action = wx.StaticText(form_panel, label="Action") self._action.SetFont(label_font) fgs.AddMany([ (self._width, 1, wx.EXPAND), (self._height, 1, wx.EXPAND), (self._weight, 1, wx.EXPAND), (self._image, 1, wx.EXPAND), (self._filter, 1, wx.EXPAND), (self._status, 1, wx.EXPAND), (self._quality, 1, wx.EXPAND), (self._ripen, 1, wx.EXPAND), (self._action, 1, wx.EXPAND) ]) form_panel.SetSizer(fgs) vbox.Add(form_panel, 0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL, 0) count = 1 for i in get_all: homedir = os.path.expanduser('~') dir_path = os.path.dirname(os.path.realpath(__file__)) if not wx.Image().CanRead(dir_path + "\\..\\images\\front\\" + str(i[5])): continue self.__weight = wx.StaticText(self.scrolled_panel, 1, str(i[1])) self.__weight.SetFont(label_data) self.__height = wx.StaticText(self.scrolled_panel, 1, str(i[2])) self.__height.SetFont(label_data) self.__width = wx.StaticText(self.scrolled_panel, 1, str(i[3])) self.__width.SetFont(label_data) if wx.Image().CanRead(dir_path + "\\..\\images\\front\\" + str(i[5])): self.img = wx.Image( dir_path + "\\..\\images\\front\\" + str(i[5]), wx.BITMAP_TYPE_ANY) else: self.img = wx.Image(dir_path + "\\..\\No-image-available.jpg", wx.BITMAP_TYPE_JPEG) self.img = self.img.Scale(100, 100) self.img = wx.StaticBitmap(self.scrolled_panel, wx.ID_ANY, wx.Bitmap(self.img)) if wx.Image().CanRead(dir_path + "\\..\\images\\back\\" + str(i[6])): self.__filter = wx.Image( dir_path + "\\..\\images\\back\\" + str(i[6]), wx.BITMAP_TYPE_ANY) else: self.__filter = wx.Image( dir_path + "\\..\\No-image-available.jpg", wx.BITMAP_TYPE_JPEG) self.__filter = self.__filter.Scale(100, 100) self.__filter = wx.StaticBitmap(self.scrolled_panel, wx.ID_ANY, wx.Bitmap(self.__filter)) self.__quality = wx.StaticText(self.scrolled_panel, 1, str(i[9]) + "%") self.__quality.SetFont(label_data) self.__status = wx.StaticText(self.scrolled_panel, 1, str(i[10])) self.__status.SetFont(label_data) dateripen = "Empty" if i[9] is not None: dateripen = i[13] + timedelta(days=i[11]) self.__life = wx.StaticText(self.scrolled_panel, 1, str(dateripen)) self.__life.SetFont(label_data) self.capture_btn = wx.Button(self.scrolled_panel, label='View', size=(50, 20)) self.capture_btn.id = i[0] fgs.AddMany([(self.__width, 1, wx.EXPAND), (self.__height, 1, wx.EXPAND), (self.__weight, 1, wx.EXPAND), (self.img, 1, wx.EXPAND), (self.__filter, 1, wx.EXPAND), (self.__status, 1, wx.EXPAND), (self.__quality, 1, wx.EXPAND), (self.__life, 1, wx.EXPAND), (self.capture_btn, 1, wx.EXPAND)]) self.Bind(wx.EVT_BUTTON, lambda event: self.insertData(event), self.capture_btn) count += 1 self.scrolled_panel.SetSizer(fgs) vbox.Add(self.scrolled_panel, 0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL, 20) btn_h = wx.BoxSizer(wx.HORIZONTAL) back_eval = wx.Button(self.panel, label='Back to evaluate', size=(150, 100)) btn_h.Add(back_eval, 1, wx.ALIGN_LEFT, 20) btn_h.AddSpacer(130) cancel_btn = wx.Button(self.panel, label='Cancel', size=(150, 100)) btn_h.Add(cancel_btn, 1, wx.ALIGN_LEFT, 20) vbox.AddSpacer(50) vbox.Add(btn_h, 1, wx.ALIGN_CENTER_HORIZONTAL, 20) # self.SetMenuBar(menubar) self.Bind(wx.EVT_BUTTON, lambda event: self.goToEvaluate(event, self), back_eval) self.Bind(wx.EVT_BUTTON, lambda event: self.goToMenu(event, self), cancel_btn) # self.Bind(wx.EVT_MENU, lambda event: field.menuHandler(event, self)) self.panel.SetSizer(vbox) self.Centre() self.Show(True)