def __init__(self, parent, title, segments, list_title=None, credits=False): wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.segment_map = {k: v for k, v in enumerate(segments)} sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) t = wx.StaticText(self, -1, self.instructions) sizer.Add(t, 0, wx.ALL | wx.EXPAND, self.border) hbox = wx.BoxSizer(wx.HORIZONTAL) vbox1 = wx.BoxSizer(wx.VERTICAL) t = wx.StaticText(self, -1, "All Segments") vbox1.Add(t, 0, wx.ALL | wx.EXPAND, self.border) self.source = ReorderableList(self, self.segment_map.keys(), self.get_item_text, columns=["Origin", "Size", "Name"], resize_column=3, allow_drop=False, size=(400, 300)) vbox1.Add(self.source, 1, wx.ALL | wx.EXPAND, self.border) hbox.Add(vbox1, 1, wx.ALL | wx.EXPAND, 0) vbox2 = wx.BoxSizer(wx.VERTICAL) if list_title is None: list_title = self.dest_list_title t = wx.StaticText(self, -1, list_title) vbox2.Add(t, 0, wx.ALL | wx.EXPAND, self.border) self.dest = ReorderableList(self, [], self.get_item_text, columns=["Origin", "Size", "Name"], resize_column=3, size=(400, 300)) vbox2.Add(self.dest, 1, wx.ALL | wx.EXPAND, self.border) hbox.Add(vbox2, 1, wx.ALL | wx.EXPAND, 0) vbox = wx.BoxSizer(wx.VERTICAL) self.add_command_area(vbox, credits) vbox.AddStretchSpacer() btnsizer = wx.StdDialogButtonSizer() self.ok_btn = wx.Button(self, wx.ID_OK) self.ok_btn.SetDefault() btnsizer.AddButton(self.ok_btn) btn = wx.Button(self, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() vbox.Add(btnsizer, 0, wx.ALL | wx.EXPAND, self.border) hbox.Add(vbox, 0, wx.EXPAND, 0) sizer.Add(hbox, 1, wx.EXPAND, 0) self.Bind(wx.EVT_BUTTON, self.on_button) self.Bind(wx.EVT_TEXT, self.on_text_changed) # Don't call self.Fit() otherwise the dialog buttons are zero height sizer.Fit(self) self.check_enable()
def __init__(self, parent, ID, title, ref_choices, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, data={"flag": "new"}): pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) self.PostCreate(pre) sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, "Mapping") sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.ref_choices = ref_choices box1 = wx.BoxSizer(wx.HORIZONTAL) label1 = wx.StaticText(self, -1, "TargetField:", size=(70, -1)) label1.SetForegroundColour((255, 0, 0)) box1.Add(label1, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.textTF = wx.TextCtrl(self, -1, "", size=(180, -1)) box1.Add(self.textTF, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box1, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box2 = wx.BoxSizer(wx.HORIZONTAL) self.label2 = wx.StaticText(self, -1, "SourceField:", size=(70, -1)) box2.Add(self.label2, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.textSF = wx.TextCtrl(self, -1, "", size=(180, -1)) box2.Add(self.textSF, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box2, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box3 = wx.BoxSizer(wx.HORIZONTAL) label3 = wx.StaticText(self, -1, "FieldType:", size=(70, -1)) label3.SetForegroundColour((255, 0, 0)) box3.Add(label3, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.choiceFT = wx.Choice(self, -1, (100, 50), choices=choiceFTList) box3.Add(self.choiceFT, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box3, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box4 = wx.BoxSizer(wx.HORIZONTAL) label4 = wx.StaticText(self, -1, "FieldLength:", size=(70, -1)) label4.SetForegroundColour((255, 0, 0)) box4.Add(label4, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.textFL = wx.TextCtrl(self, -1, "", size=(180, -1)) box4.Add(self.textFL, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box4, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box5 = wx.BoxSizer(wx.HORIZONTAL) label5 = wx.StaticText(self, -1, "Rule:", size=(70, -1)) label5.SetForegroundColour((255, 0, 0)) box5.Add(label5, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.choiceRule = wx.Choice(self, -1, (100, 50), choices=choiceRuleList) self.Bind(wx.EVT_CHOICE, self.OnEvtChoiceRule, self.choiceRule) box5.Add(self.choiceRule, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box5, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box6 = wx.BoxSizer(wx.HORIZONTAL) self.label6 = wx.StaticText(self, -1, "Reference:", size=(70, -1)) box6.Add(self.label6, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.choiceRef = wx.Choice(self, -1, (100, 50), choices=self.ref_choices) box6.Add(self.choiceRef, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box6, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box7 = wx.BoxSizer(wx.HORIZONTAL) label7 = wx.StaticText(self, -1, "IsKey:", size=(70, -1)) box7.Add(label7, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.checkboxKey = wx.CheckBox(self, -1, "", style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER) box7.Add(self.checkboxKey, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box7, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box8 = wx.BoxSizer(wx.HORIZONTAL) label8 = wx.StaticText(self, -1, "IsVariable:", size=(70, -1)) box8.Add(label8, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.checkboxVal = wx.CheckBox(self, -1, "", style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER) box8.Add(self.checkboxVal, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box8, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() if wx.Platform != "__WXMSW__": btn = wx.ContextHelpButton(self) btnsizer.AddButton(btn) btnSave = wx.Button(self, wx.ID_SAVE) btnSave.SetHelpText("The OK button completes the dialog") btnSave.SetDefault() self.Bind(wx.EVT_BUTTON, self.OnEvtButtonSave, btnSave) btnsizer.AddButton(btnSave) btnCancel = wx.Button(self, wx.ID_CANCEL) btnCancel.SetHelpText( "The Cancel button cancels the dialog. (Cool, huh?)") btnsizer.AddButton(btnCancel) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) if data["flag"] == "edit": self.textTF.SetValue(data["target_field"]) self.textSF.SetValue(data["source_field"]) self.choiceFT.SetSelection(choiceFTList.index(data["field_type"])) self.textFL.SetValue(data["field_length"]) self.choiceRule.SetSelection(choiceRuleList.index(data["rule"])) if data["rule"] == "direct": self.label6.SetForegroundColour((0, 0, 0)) self.label2.SetForegroundColour((255, 0, 0)) else: self.label6.SetForegroundColour((255, 0, 0)) self.label2.SetForegroundColour((0, 0, 0)) self.choiceRef.SetSelection(ref_choices.index(data["reference"])) if data["iskey"] == "False": isKey = False elif data["iskey"] == "True": isKey = True self.checkboxKey.SetValue(isKey) if data["isvariable"] == "False": isVal = False elif data["isvariable"] == "True": isVal = True self.checkboxVal.SetValue(isVal)
def __init__(self, parent, device, offset, winFunc): self.device = device self.offset = offset * 1e3 self.winFunc = winFunc self.band1 = None self.band2 = None wx.Dialog.__init__(self, parent=parent, title="Scan Offset") figure = matplotlib.figure.Figure(facecolor='white') self.axes = figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, figure) textHelp = wx.StaticText(self, label="Remove the aerial and press refresh, " "adjust the offset so the shaded areas overlay the flattest parts " "of the plot_line.") textFreq = wx.StaticText(self, label="Test frequency (MHz)") self.spinFreq = wx.SpinCtrl(self) self.spinFreq.SetRange(F_MIN, F_MAX) self.spinFreq.SetValue(200) textGain = wx.StaticText(self, label="Test gain (dB)") self.spinGain = wx.SpinCtrl(self) self.spinGain.SetRange(-100, 200) self.spinGain.SetValue(200) refresh = wx.Button(self, wx.ID_ANY, 'Refresh') self.Bind(wx.EVT_BUTTON, self.__on_refresh, refresh) textOffset = wx.StaticText(self, label="Offset (kHz)") self.spinOffset = wx.SpinCtrl(self) self.spinOffset.SetRange(0, ((SAMPLE_RATE / 2) - BANDWIDTH) / 1e3) self.spinOffset.SetValue(offset) self.Bind(wx.EVT_SPINCTRL, self.__on_spin, self.spinOffset) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) boxSizer1 = wx.BoxSizer(wx.HORIZONTAL) boxSizer1.Add(textFreq, border=5) boxSizer1.Add(self.spinFreq, border=5) boxSizer1.Add(textGain, border=5) boxSizer1.Add(self.spinGain, border=5) boxSizer2 = wx.BoxSizer(wx.HORIZONTAL) boxSizer2.Add(textOffset, border=5) boxSizer2.Add(self.spinOffset, border=5) gridSizer = wx.GridBagSizer(5, 5) gridSizer.Add(self.canvas, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=5) gridSizer.Add(textHelp, pos=(1, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=5) gridSizer.Add(boxSizer1, pos=(2, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=5) gridSizer.Add(refresh, pos=(3, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=5) gridSizer.Add(boxSizer2, pos=(4, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=5) gridSizer.Add(sizerButtons, pos=(5, 1), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) self.SetSizerAndFit(gridSizer) self.__draw_limits() self.__setup_plot()
def handle_interaction(self, current_shape, orig_image): '''Show the cropping user interface''' import matplotlib as M import matplotlib.cm import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg pixel_data = stretch(orig_image) # # Create the UI - a dialog with a figure inside # style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER dialog_box = wx.Dialog(wx.GetApp().TopWindow, -1, "Select the cropping region", size=(640,480), style = style) sizer = wx.BoxSizer(wx.VERTICAL) figure = matplotlib.figure.Figure() panel = FigureCanvasWxAgg(dialog_box, -1, figure) sizer.Add(panel, 1, wx.EXPAND) btn_sizer = wx.StdDialogButtonSizer() btn_sizer.AddButton(wx.Button(dialog_box, wx.ID_OK)) btn_sizer.AddButton(wx.Button(dialog_box, wx.ID_CANCEL)) btn_sizer.Realize() sizer.Add(btn_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5) dialog_box.SetSizer(sizer) dialog_box.Size = dialog_box.BestSize dialog_box.Layout() axes = figure.add_subplot(1,1,1) assert isinstance(axes, matplotlib.axes.Axes) if pixel_data.ndim == 2: axes.imshow(pixel_data, matplotlib.cm.Greys_r, origin="upper") else: axes.imshow(pixel_data, origin="upper") #t = axes.transData.inverted() current_handle = [ None ] def data_xy(mouse_event): '''Return the mouse event's x & y converted into data-relative coords''' x = mouse_event.xdata y = mouse_event.ydata return (x,y) class handle(M.patches.Rectangle): dm = max((10,min(pixel_data.shape)/50)) height, width = (dm,dm) def __init__(self, x, y, on_move): x = max(0, min(x, pixel_data.shape[1])) y = max(0, min(y, pixel_data.shape[0])) self.__selected = False self.__color = cpprefs.get_primary_outline_color() self.__color = np.hstack((self.__color,[255])).astype(float) / 255.0 self.__on_move = on_move super(handle, self).__init__((x-self.width/2, y-self.height/2), self.width, self.height, edgecolor = self.__color, facecolor = "none") self.set_picker(True) def move(self, x, y): self.set_xy((x-self.width/2, y-self.height/2)) self.__on_move(x, y) def select(self, on): self.__selected = on if on: current_handle[0] = self self.set_facecolor(self.__color) else: self.set_facecolor("none") if current_handle[0] == self: current_handle[0] = None figure.canvas.draw() dialog_box.Update() @property def is_selected(self): return self.__selected @property def center_x(self): '''The handle's notion of its x coordinate''' return self.get_x() + self.get_width() / 2 @property def center_y(self): '''The handle's notion of its y coordinate''' return self.get_y() + self.get_height() / 2 def handle_pick(self, event): mouse_event = event.mouseevent x, y = data_xy(mouse_event) if mouse_event.button == 1: self.select(True) self.orig_x = self.center_x self.orig_y = self.center_y self.first_x = x self.first_y = y def handle_mouse_move_event(self, event): x,y = data_xy(event) if x is None or y is None: return x = x - self.first_x + self.orig_x y = y - self.first_y + self.orig_y if x < 0: x = 0 if x >= pixel_data.shape[1]: x = pixel_data.shape[1] -1 if y < 0: y = 0 if y >= pixel_data.shape[0]: y = pixel_data.shape[0] -1 self.move(x, y) class crop_rectangle(object): def __init__(self, top_left, bottom_right): self.__left, self.__top = top_left self.__right, self.__bottom = bottom_right color = cpprefs.get_primary_outline_color() color = np.hstack((color,[255])).astype(float) / 255.0 self.rectangle = M.patches.Rectangle( (min(self.__left, self.__right), min(self.__bottom, self.__top)), abs(self.__right - self.__left), abs(self.__top - self.__bottom), edgecolor = color, facecolor = "none" ) self.top_left_handle = handle(top_left[0], top_left[1], self.handle_top_left) self.bottom_right_handle = handle(bottom_right[0], bottom_right[1], self.handle_bottom_right) def handle_top_left(self, x, y): self.__left = x self.__top = y self.__reshape() def handle_bottom_right(self, x, y): self.__right = x self.__bottom = y self.__reshape() def __reshape(self): self.rectangle.set_xy((min(self.__left, self.__right), min(self.__bottom,self.__top))) self.rectangle.set_width(abs(self.__right - self.__left)) self.rectangle.set_height(abs(self.__bottom - self.__top)) self.rectangle.figure.canvas.draw() dialog_box.Update() @property def patches(self): return [self.rectangle, self.top_left_handle, self.bottom_right_handle] @property def handles(self): return [self.top_left_handle, self.bottom_right_handle] @property def left(self): return min(self.__left, self.__right) @property def right(self): return max(self.__left, self.__right) @property def top(self): return min(self.__top, self.__bottom) @property def bottom(self): return max(self.__top, self.__bottom) class crop_ellipse(object): def __init__(self, center, radius): '''Draw an ellipse with control points at the ellipse center and a given x and y radius''' self.center_x, self.center_y = center self.radius_x = self.center_x + radius[0] / 2 self.radius_y = self.center_y + radius[1] / 2 color = cpprefs.get_primary_outline_color() color = np.hstack((color,[255])).astype(float) / 255.0 self.ellipse = M.patches.Ellipse(center, self.width, self.height, edgecolor = color, facecolor = "none") self.center_handle = handle(self.center_x, self.center_y, self.move_center) self.radius_handle = handle(self.radius_x, self.radius_y, self.move_radius) def move_center(self, x, y): self.center_x = x self.center_y = y self.redraw() def move_radius(self, x, y): self.radius_x = x self.radius_y = y self.redraw() @property def width(self): return abs(self.center_x - self.radius_x) * 4 @property def height(self): return abs(self.center_y - self.radius_y) * 4 def redraw(self): self.ellipse.center = (self.center_x, self.center_y) self.ellipse.width = self.width self.ellipse.height = self.height self.ellipse.figure.canvas.draw() dialog_box.Update() @property def patches(self): return [self.ellipse, self.center_handle, self.radius_handle] @property def handles(self): return [self.center_handle, self.radius_handle] if self.shape == SH_ELLIPSE: if current_shape is None: current_shape = { EL_XCENTER: pixel_data.shape[1] / 2, EL_YCENTER: pixel_data.shape[0] / 2, EL_XRADIUS: pixel_data.shape[1] / 2, EL_YRADIUS: pixel_data.shape[0] / 2 } ellipse = current_shape shape = crop_ellipse((ellipse[EL_XCENTER], ellipse[EL_YCENTER]), (ellipse[EL_XRADIUS], ellipse[EL_YRADIUS])) else: if current_shape is None: current_shape = { RE_LEFT: pixel_data.shape[1] / 4, RE_TOP: pixel_data.shape[0] / 4, RE_RIGHT: pixel_data.shape[1] * 3 / 4, RE_BOTTOM: pixel_data.shape[0] * 3 / 4 } rectangle = current_shape shape = crop_rectangle((rectangle[RE_LEFT], rectangle[RE_TOP]), (rectangle[RE_RIGHT], rectangle[RE_BOTTOM])) for patch in shape.patches: axes.add_artist(patch) def on_mouse_down_event(event): axes.pick(event) def on_mouse_move_event(event): if current_handle[0] is not None: current_handle[0].handle_mouse_move_event(event) def on_mouse_up_event(event): if current_handle[0] is not None: current_handle[0].select(False) def on_pick_event(event): for h in shape.handles: if id(h) == id(event.artist): h.handle_pick(event) figure.canvas.mpl_connect('button_press_event', on_mouse_down_event) figure.canvas.mpl_connect('button_release_event', on_mouse_up_event) figure.canvas.mpl_connect('motion_notify_event', on_mouse_move_event) figure.canvas.mpl_connect('pick_event', on_pick_event) try: if dialog_box.ShowModal() != wx.ID_OK: raise ValueError("Cancelled by user") finally: dialog_box.Destroy() if self.shape == SH_RECTANGLE: return { RE_LEFT: shape.left, RE_TOP: shape.top, RE_RIGHT: shape.right, RE_BOTTOM: shape.bottom } else: return { EL_XCENTER: shape.center_x, EL_YCENTER: shape.center_y, EL_XRADIUS: shape.width / 2, EL_YRADIUS: shape.height / 2 }
def display_error_message(parent, message, title, buttons = None, size = (300, 200)): '''Display an error in a scrolling message box parent - parent window to the error message message - message to display in scrolling box title - title to display in frame buttons - a list of buttons to put at bottom of dialog. For instance, [wx.ID_YES, wx.ID_NO]. Defaults to OK button size - size of frame. Defaults to 300 x 200 but will fit. returns the code from ShowModal. ''' import wx if buttons is None: buttons = [wx.ID_OK] else: assert len(buttons) > 0 with wx.Dialog(parent, title=title, size = size, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) as dlg: assert isinstance(dlg, wx.Dialog) dlg.Sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.HORIZONTAL) dlg.Sizer.AddSpacer(20) dlg.Sizer.Add(sizer, 1, wx.EXPAND) sizer.AddSpacer(10) icon = wx.ArtProvider.GetBitmap(wx.ART_ERROR) sizer.Add(wx.StaticBitmap(dlg, bitmap=icon), 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_TOP | wx.ALL, 10) sizer.AddSpacer(10) message_ctrl = wx.TextCtrl( dlg, value = message, style = wx.TE_MULTILINE | wx.TE_READONLY | wx.NO_BORDER) message_ctrl.SetBackgroundColour(dlg.BackgroundColour) line_sizes = [message_ctrl.GetTextExtent(line) for line in message.split("\n")] width = reduce(max, [x[0] for x in line_sizes]) width += wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X) width += wx.SystemSettings.GetMetric(wx.SYS_BORDER_X) * 2 height = sum([x[1] for x in line_sizes]) message_ctrl.SetMinSize((width, min(height, size[1]))) sizer.Add(message_ctrl, 1, wx.EXPAND) sizer.AddSpacer(10) dlg.Sizer.AddSpacer(10) button_sizer = wx.StdDialogButtonSizer() dlg.Sizer.Add(button_sizer, 0, wx.EXPAND | wx.ALL, 10) def on_button(event): id2code = { wx.ID_YES: wx.YES, wx.ID_NO: wx.NO, wx.ID_CANCEL: wx.CANCEL, wx.ID_OK: wx.OK } assert isinstance(event, wx.Event) dlg.EndModal(id2code[event.Id]) for button in buttons: button_ctl = wx.Button(dlg, button) button_sizer.AddButton(button_ctl) button_ctl.Bind(wx.EVT_BUTTON, on_button) button_ctl.SetFocus() button_sizer.Realize() dlg.Fit() return dlg.ShowModal()
def __init__(self, parent, spectrum, settings): self.spectrum = spectrum self.settings = settings self.smoothed = None wx.Dialog.__init__(self, parent=parent, title='Smooth Spectrum', style=wx.RESIZE_BORDER | wx.CAPTION | wx.SYSTEM_MENU | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX | wx.CLOSE_BOX) self.queue = Queue.Queue() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.__on_timer, self.timer) self.timer.Start(self.POLL) self.figure = matplotlib.figure.Figure(facecolor='white') self.canvas = FigureCanvas(self, -1, self.figure) settings = copy.copy(settings) settings.plotFunc = PlotFunc.NONE self.plot = Plotter(self.queue, self.figure, settings) textFunc = wx.StaticText(self, label='Window function') self.choiceFunc = wx.Choice(self, choices=WINFUNC[::2]) self.choiceFunc.SetSelection(WINFUNC[::2].index(settings.smoothFunc)) textRatio = wx.StaticText(self, label='Smoothing') self.slideRatio = wx.Slider(self, value=settings.smoothRatio, minValue=2, maxValue=100, style=wx.SL_INVERSE) buttonSmooth = wx.Button(self, label='Smooth') self.Bind(wx.EVT_BUTTON, self.__on_smooth, buttonSmooth) sizerButtons = wx.StdDialogButtonSizer() self.buttonOk = wx.Button(self, wx.ID_OK) self.buttonOk.Disable() buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(self.buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, self.buttonOk) sizerGrid = wx.GridBagSizer(5, 5) sizerGrid.Add(self.canvas, pos=(0, 0), span=(10, 6), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(textFunc, pos=(1, 6), border=5) sizerGrid.Add(self.choiceFunc, pos=(2, 6), span=(1, 2), flag=wx.ALL, border=5) sizerGrid.Add(textRatio, pos=(3, 6), flag=wx.ALL, border=5) sizerGrid.Add(self.slideRatio, pos=(4, 6), span=(1, 2), flag=wx.ALL, border=5) sizerGrid.Add(buttonSmooth, pos=(5, 6), span=(1, 2), flag=wx.ALL, border=5) sizerGrid.Add(sizerButtons, pos=(11, 6), span=(1, 2), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) sizerGrid.AddGrowableCol(0) sizerGrid.AddGrowableRow(0) self.SetSizerAndFit(sizerGrid) self.__draw_plot(self.spectrum)
def __init__(self, dlg_title, box_label, choices, options=None, defaults=None): """Initialise the dialog and draw the content dlg_title: Dialog title box_label: Label of the draw around the listed choices choices: Choices to select one (string list) options: see uses of the dialog""" pos = wx.GetMousePosition() wx.Dialog.__init__(self, None, -1, dlg_title, pos) szr = wx.BoxSizer(wx.VERTICAL) if box_label: self.box = wx.RadioBox(self, wx.ID_ANY, box_label, wx.DefaultPosition, wx.DefaultSize, choices.split('|'), 1, style=wx.RA_SPECIFY_COLS) self.box.SetSelection(0) self.Bind(wx.EVT_RADIOBOX, self.on_choice) szr.Add(self.box, 5, wx.ALL | wx.EXPAND, 10) if options: self._check_option_dependencies(options) self.option_controls = [] self.option_values = [] for o, option in enumerate(self.options): # calculate border flags #flags = wx.LEFT | wx.RIGHT #if not self.dependencies[o]: flags |= wx.TOP #if not self.dependencies[o+1]: flags |= wx.BOTTOM flags = wx.ALL # create and add the option controls if option[0] == "Text": label = option[1] hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, label), 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4) ctrl = wx.TextCtrl(self, -1, option[1]) value = defaults and defaults[o] or "" ctrl.SetValue(value) hsizer.Add(ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4) szr.Add(hsizer, 0, flags | wx.EXPAND, 4) ctrl.Bind(wx.EVT_TEXT, self.callback) elif option[0] == "Checkbox": ctrl = wx.CheckBox(self, -1, option[1]) value = defaults and defaults[o] ctrl.SetValue(value) szr.Add(ctrl, 0, flags, 8) ctrl.Bind(wx.EVT_CHECKBOX, self.callback) elif option[0] == "Spin": label, range_ = option[1:] hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(self, -1, label), 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4) mi_, ma_ = range_ value = defaults and defaults[o] or 1 ctrl = wx.SpinCtrl(self, -1, str(value), min=mi_, max=ma_, initial=value) hsizer.Add(ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4) szr.Add(hsizer, 0, flags | wx.EXPAND, 4) ctrl.Bind(wx.EVT_SPINCTRL, self.callback) self.option_controls.append(ctrl) self.option_values.append(value) self.active = [True] * len(self.options) self._activate(1) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) szr.Add(line, 0, wx.EXPAND | wx.TOP | wx.LEFT, 5) # buttons btnbox = wx.StdDialogButtonSizer() btnOK = wx.Button(self, wx.ID_OK) btnOK.SetDefault() btnCANCEL = wx.Button(self, wx.ID_CANCEL) btnbox.AddButton(btnOK) btnbox.AddButton(btnCANCEL) btnbox.Realize() szr.Add(btnbox, 0, wx.ALL | wx.ALIGN_CENTER, 8) self.SetAutoLayout(True) self.SetSizer(szr) szr.Fit(self)
def __init__(self, parent): wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=_("Import Image"), pos=wx.DefaultPosition, size=wx.Size(402, 173), style=wx.CAPTION | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) bSizer = wx.BoxSizer(wx.VERTICAL) bhSizer = wx.BoxSizer(wx.HORIZONTAL) self.bmp = wx.StaticBitmap(self, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.Size(100, 100), wx.SUNKEN_BORDER) bhSizer.Add(self.bmp, 0, wx.ALL, 5) gbSizer2 = wx.GridBagSizer(0, 0) gbSizer2.AddGrowableCol(1) gbSizer2.AddGrowableRow(2) gbSizer2.SetFlexibleDirection(wx.BOTH) gbSizer2.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.stTag = wx.StaticText(self, wx.ID_ANY, _("Image Tag:"), wx.DefaultPosition, wx.DefaultSize, 0) self.stTag.Wrap(-1) gbSizer2.Add(self.stTag, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.txtTag = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) gbSizer2.Add(self.txtTag, wx.GBPosition(0, 1), wx.GBSpan(1, 1), wx.ALL | wx.EXPAND, 5) self.stFile = wx.StaticText(self, wx.ID_ANY, _("Image source:"), wx.DefaultPosition, wx.DefaultSize, 0) self.stFile.Wrap(-1) gbSizer2.Add(self.stFile, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.filePicker = wx.FilePickerCtrl(self, wx.ID_ANY, wx.EmptyString, _("Select a file"), u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE) gbSizer2.Add(self.filePicker, wx.GBPosition(1, 1), wx.GBSpan(1, 1), wx.ALL | wx.EXPAND, 5) self.stInfo = wx.StaticText(self, wx.ID_ANY, _("Image info:"), wx.DefaultPosition, wx.DefaultSize, 0) self.stInfo.Wrap(-1) gbSizer2.Add(self.stInfo, wx.GBPosition(2, 0), wx.GBSpan(1, 1), wx.ALL, 5) self.stImageInfo = wx.StaticText(self, wx.ID_ANY, _("1x1; 1 bytes"), wx.DefaultPosition, wx.DefaultSize, 0) self.stImageInfo.Wrap(-1) gbSizer2.Add(self.stImageInfo, wx.GBPosition(2, 1), wx.GBSpan(1, 1), wx.ALL, 5) bhSizer.Add(gbSizer2, 1, wx.EXPAND, 5) bSizer.Add(bhSizer, 1, wx.EXPAND, 5) sdbSizer = wx.StdDialogButtonSizer() self.sdbSizerOK = wx.Button(self, wx.ID_OK) sdbSizer.AddButton(self.sdbSizerOK) self.sdbSizerCancel = wx.Button(self, wx.ID_CANCEL) sdbSizer.AddButton(self.sdbSizerCancel) sdbSizer.Realize() bSizer.Add(sdbSizer, 0, wx.ALL | wx.EXPAND, 5) self.SetSizer(bSizer) self.Layout() self.Centre(wx.BOTH) # Connect Events self.filePicker.Bind(wx.EVT_FILEPICKER_CHANGED, self.LoadFile) self.sdbSizerOK.Bind(wx.EVT_BUTTON, self.OnOk)
def on_choose_font(self, event): with wx.Dialog(self.choice_panel.Parent, title="Measurement appearance") as dlg: labels = [] def add_label(sizer, label): ctrl = wx.StaticText(dlg, label=label) sizer.Add(ctrl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) labels.append(ctrl) sizer.AddSpacer(2) dlg.Sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL) dlg.Sizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 5) subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Font") font_picker = wx.FontPickerCtrl(dlg) font_picker.SetSelectedFont(self.font) font_picker.SetPickerCtrlGrowable(True) font_picker.Bind(wx.EVT_FONTPICKER_CHANGED, lambda event: dlg.Layout()) subsizer.Add(font_picker, 0, wx.ALIGN_LEFT) # # Foreground color # subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Text color") foreground_color = wx.lib.colourselect.ColourSelect( dlg, colour=self.foreground_color) subsizer.Add(foreground_color, 0, wx.ALIGN_LEFT) # # Background color and alpha # subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Background color") background_color = wx.lib.colourselect.ColourSelect( dlg, colour=self.background_color) subsizer.Add(background_color, 0, wx.ALIGN_LEFT) subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Alpha") alpha = wx.Slider(dlg, value=self.background_alpha * 100, minValue=0, maxValue=100, style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS) alpha.SetMinSize(wx.Size(200, alpha.GetMinSize()[0])) subsizer.Add(alpha, 0, wx.EXPAND) subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Box shape") box_style = wx.Choice(dlg, choices=[ "circle", "round", "roundtooth", "sawtooth", "square" ]) box_style.SetStringSelection(self.box_style) subsizer.Add(box_style, 0, wx.ALIGN_LEFT) subsizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(subsizer, 0, wx.EXPAND) sizer.AddSpacer(2) add_label(subsizer, "Precision") precision = wx.SpinCtrl(dlg, value=str(self.precision), min=0) subsizer.AddSpacer(2) subsizer.Add(precision, 0, wx.ALIGN_LEFT) width = 0 for label in labels: width = max(width, label.GetBestSize()[0]) for label in labels: label.SetMinSize(wx.Size(width, label.GetBestSize()[1])) button_sizer = wx.StdDialogButtonSizer() dlg.Sizer.Add(button_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5) button_sizer.AddButton(wx.Button(dlg, wx.ID_OK)) button_sizer.AddButton(wx.Button(dlg, wx.ID_CANCEL)) button_sizer.Realize() dlg.Fit() if dlg.ShowModal() == wx.ID_OK: self.font = font_picker.GetSelectedFont() self.foreground_color = foreground_color.GetColour() self.background_color = background_color.GetColour() self.background_alpha = float(alpha.Value) / 100 self.box_style = box_style.GetStringSelection() self.precision = precision.Value self.on_change(event)
def __init__(self, dataFrame_lst): wx.Frame.__init__(self, None, id=wx.ID_ANY, title=u"DataFrame Browser", size=wx.Size(400, 325), style=wx.CAPTION | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) self.SetBackgroundColour(wx.Colour(219, 219, 219)) main_sizer = wx.BoxSizer(wx.VERTICAL) self.main_panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) self.main_panel.SetBackgroundColour(wx.Colour(219, 219, 219)) main_panel_sizer = wx.BoxSizer(wx.VERTICAL) sub_panel_sizer_h1 = wx.BoxSizer(wx.HORIZONTAL) sub_panel_sizer_v1 = wx.BoxSizer(wx.VERTICAL) self.loaded_frames_StaticText = wx.StaticText(self.main_panel, wx.ID_ANY, u"Loaded DataFrames: ", wx.DefaultPosition, wx.DefaultSize, 0) self.loaded_frames_StaticText.Wrap(-1) sub_panel_sizer_v1.Add(self.loaded_frames_StaticText, 0, wx.ALL, 5) dataFrame_ListBoxChoices = dataFrame_lst self.dataFrame_ListBox = wx.ListBox( self.main_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, dataFrame_ListBoxChoices, wx.LB_EXTENDED | wx.LB_HSCROLL | wx.LB_NEEDED_SB | wx.LB_SORT) self.dataFrame_ListBox.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DLIGHT)) sub_panel_sizer_v1.Add(self.dataFrame_ListBox, 0, wx.ALL | wx.EXPAND, 5) sub_panel_sizer_h1.Add(sub_panel_sizer_v1, 1, wx.EXPAND, 5) main_panel_sizer.Add(sub_panel_sizer_h1, 0, wx.EXPAND, 5) sub_panel_sizer_h2 = wx.BoxSizer(wx.HORIZONTAL) self.delete_button = wx.Button(self.main_panel, wx.ID_ANY, u"Add to List for Deletion...", wx.DefaultPosition, wx.DefaultSize, 0) sub_panel_sizer_h2.Add(self.delete_button, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5) main_panel_sizer.Add(sub_panel_sizer_h2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5) bSizer117 = wx.BoxSizer(wx.VERTICAL) self.m_staticText54 = wx.StaticText(self.main_panel, wx.ID_ANY, u"List for Deletion: ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText54.Wrap(-1) bSizer117.Add(self.m_staticText54, 0, wx.ALL, 5) list_for_deletionChoices = [] self.list_for_deletion = wx.ListBox(self.main_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, list_for_deletionChoices, wx.LB_HSCROLL | wx.LB_NEEDED_SB) self.list_for_deletion.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DLIGHT)) bSizer117.Add(self.list_for_deletion, 0, wx.ALL | wx.EXPAND, 5) main_panel_sizer.Add(bSizer117, 0, wx.EXPAND, 5) panel_ok_cancel_sizer = wx.StdDialogButtonSizer() self.panel_ok_cancel_sizerOK = wx.Button(self.main_panel, wx.ID_OK) panel_ok_cancel_sizer.AddButton(self.panel_ok_cancel_sizerOK) self.panel_ok_cancel_sizerCancel = wx.Button(self.main_panel, wx.ID_CANCEL) panel_ok_cancel_sizer.AddButton(self.panel_ok_cancel_sizerCancel) panel_ok_cancel_sizer.Realize() main_panel_sizer.Add(panel_ok_cancel_sizer, 1, wx.EXPAND, 5) self.main_panel.SetSizer(main_panel_sizer) self.main_panel.Layout() main_panel_sizer.Fit(self.main_panel) main_sizer.Add(self.main_panel, 1, wx.EXPAND, 5) self.SetSizer(main_sizer) self.Layout() self.Centre(wx.BOTH) self.delete_button.Bind(wx.EVT_BUTTON, self.on_add_to_list) self.panel_ok_cancel_sizerCancel.Bind(wx.EVT_BUTTON, self.on_cancel_click) self.panel_ok_cancel_sizerOK.Bind(wx.EVT_BUTTON, self.on_ok_click) self.Show(True)
def __init__(self, parent): wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Settings", pos=wx.DefaultPosition, size=wx.Size(307, 171), style=wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) fgSizer1 = wx.FlexGridSizer(2, 1, 0, 0) fgSizer1.SetFlexibleDirection(wx.BOTH) fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) fgSizer2 = wx.FlexGridSizer(4, 2, 0, 0) fgSizer2.SetFlexibleDirection(wx.BOTH) fgSizer2.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.m_staticText1 = wx.StaticText(self, wx.ID_ANY, u"Tivo Account Name", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT) self.m_staticText1.Wrap(-1) fgSizer2.Add(self.m_staticText1, 0, wx.ALL, 5) self.m_textAcct = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer2.Add(self.m_textAcct, 0, wx.ALL, 5) self.m_staticText2 = wx.StaticText(self, wx.ID_ANY, u"Tivo Account Password", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText2.Wrap(-1) fgSizer2.Add(self.m_staticText2, 0, wx.ALL, 5) self.m_textPW = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer2.Add(self.m_textPW, 0, wx.ALL, 5) self.m_staticText3 = wx.StaticText(self, wx.ID_ANY, u"TSN", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText3.Wrap(-1) fgSizer2.Add(self.m_staticText3, 0, wx.ALL, 5) self.m_textTSN = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer2.Add(self.m_textTSN, 0, wx.ALL, 5) fgSizer1.Add(fgSizer2, 1, wx.EXPAND, 5) m_sdbSizer1 = wx.StdDialogButtonSizer() self.m_sdbSizer1OK = wx.Button(self, wx.ID_OK) m_sdbSizer1.AddButton(self.m_sdbSizer1OK) self.m_sdbSizer1Cancel = wx.Button(self, wx.ID_CANCEL) m_sdbSizer1.AddButton(self.m_sdbSizer1Cancel) m_sdbSizer1.Realize() fgSizer1.Add(m_sdbSizer1, 1, wx.ALL | wx.EXPAND, 5) self.m_textAcct.SetValue(settings.un) self.m_textPW.SetValue(settings.pw) self.m_textTSN.SetValue(settings.tsn) self.SetSizer(fgSizer1) self.Layout() self.Centre(wx.BOTH) # Connect Events self.m_sdbSizer1Cancel.Bind(wx.EVT_BUTTON, self.onCancel) self.m_sdbSizer1OK.Bind(wx.EVT_BUTTON, self.onOK)
def __init__(self, parent, infoDict, export=True): self.export = export if export: title = _('Export filter customizations') else: title = _('Import filter customizations') wx.Dialog.__init__(self, parent, wx.ID_ANY, title, size=(500, 300), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.calltipDict = infoDict[0] self.presetDict = infoDict[1] self.docpathDict = infoDict[2] self.functiontypeDict = infoDict[3] # Create the list control using the dictionary decList = [(s.lower(), s) for s in self.calltipDict.keys()] decList.sort() self.names = [s[1] for s in decList] self.checkListBox = wx.CheckListBox(self, wx.ID_ANY, choices=self.names) # Create extra control buttons def OnButtonSelectAll(event): for index in xrange(len(self.names)): self.checkListBox.Check(index, True) def OnButtonClearAll(event): for index in xrange(len(self.names)): self.checkListBox.Check(index, False) buttonSelectAll = wx.Button(self, wx.ID_ANY, _('Select all')) self.Bind(wx.EVT_BUTTON, OnButtonSelectAll, buttonSelectAll) buttonClearAll = wx.Button(self, wx.ID_ANY, _('Clear all')) self.Bind(wx.EVT_BUTTON, OnButtonClearAll, buttonClearAll) if export: staticText = wx.StaticText(self, wx.ID_ANY, _('Select filters to export:')) extraItem = (-1, 20) else: staticText = wx.StaticText( self, wx.ID_ANY, _('Select filters to import from the file:')) # Import dialog, check all names by default for index in xrange(len(self.names)): self.checkListBox.Check(index) # Extra controls to provide options for import information #~ self.checkBoxCalltip = wx.CheckBox(self, wx.ID_ANY, _('Calltips')) #~ self.checkBoxPreset = wx.CheckBox(self, wx.ID_ANY, _('Presets')) #~ self.checkBoxDocpath = wx.CheckBox(self, wx.ID_ANY, _('Docpaths')) #~ self.checkBoxType = wx.CheckBox(self, wx.ID_ANY, _('Filter types')) #~ staticBox = wx.StaticBox(self, wx.ID_ANY, _('Import from filters:')) #~ staticBoxSizer = wx.StaticBoxSizer(staticBox, wx.HORIZONTAL) #~ for item in (self.checkBoxCalltip, self.checkBoxPreset, self.checkBoxDocpath, self.checkBoxType): #~ item.SetValue(True) #~ staticBoxSizer.Add(item, 0, wx.ALL, 5) self.checkBoxOverwriteAll = wx.CheckBox(self, wx.ID_ANY, _('Overwrite all data')) self.checkBoxOverwriteAll.SetValue(True) extraItem = wx.BoxSizer(wx.VERTICAL) #~ extraItem.Add(staticBoxSizer, 0, wx.BOTTOM, 10) extraItem.Add(self.checkBoxOverwriteAll, 0, wx.LEFT | wx.BOTTOM, 5) # Standard buttons okay = wx.Button(self, wx.ID_OK, _('OK')) self.Bind(wx.EVT_BUTTON, self.OnButtonOK, okay) cancel = wx.Button(self, wx.ID_CANCEL, _('Cancel')) btns = wx.StdDialogButtonSizer() btns.AddButton(okay) btns.AddButton(cancel) btns.Realize() # Size the elements buttonSizer = wx.BoxSizer(wx.VERTICAL) buttonSizer.Add(buttonSelectAll, 0, wx.ALL, 5) buttonSizer.Add(buttonClearAll, 0, wx.ALL, 5) listSizer = wx.BoxSizer(wx.HORIZONTAL) listSizer.Add(self.checkListBox, 1, wx.EXPAND | wx.ALL, 5) listSizer.Add(buttonSizer, 0, wx.ALL, 5) dlgSizer = wx.BoxSizer(wx.VERTICAL) dlgSizer.Add((-1, 5)) dlgSizer.Add(staticText, 0, wx.ALL, 5) dlgSizer.Add(listSizer, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5) dlgSizer.Add(extraItem, 0, wx.ALL, 5) dlgSizer.Add(btns, 0, wx.EXPAND | wx.ALL, 5) self.SetSizer(dlgSizer) dlgSizer.SetSizeHints(self) # Misc okay.SetDefault()
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, mtexts.txts['FindTime'], pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE) self.parent = parent #main vertical sizer mvsizer = wx.BoxSizer(wx.VERTICAL) #main horizontal sizer mhsizer = wx.BoxSizer(wx.HORIZONTAL) vsizer = wx.BoxSizer(wx.VERTICAL) #BC sbc = wx.StaticBox(self, label='') sbcsizer = wx.StaticBoxSizer(sbc, wx.VERTICAL) self.bcckb = wx.CheckBox(self, -1, mtexts.txts['BC']) sbcsizer.Add(self.bcckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) # self.bcckb.Enable(False) vsizer.Add(sbcsizer, 0, wx.GROW) #Planets splanets =wx.StaticBox(self, label='') splanetssizer = wx.StaticBoxSizer(splanets, wx.VERTICAL) gsizer = wx.GridSizer(7, 5) label = wx.StaticText(self, -1, mtexts.txts['Sun']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sundeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.sundeg.SetHelpText(mtexts.txts['HelpDeg']) self.sundeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.sundeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.sunmin.SetHelpText(mtexts.txts['HelpMin']) self.sunmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.sunmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.sunmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.sunsec.SetHelpText(mtexts.txts['HelpMin']) self.sunsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.sunsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunsectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.sunsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.sunretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.sunretr.Enable(False) label = wx.StaticText(self, -1, mtexts.txts['Moon']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moondeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.moondeg.SetHelpText(mtexts.txts['HelpDeg']) self.moondeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.moondeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.moonmin.SetHelpText(mtexts.txts['HelpMin']) self.moonmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.moonmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.moonmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.moonsec.SetHelpText(mtexts.txts['HelpMin']) self.moonsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.moonsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonsectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.moonsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.moonretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.moonretr.Enable(False) label = wx.StaticText(self, -1, mtexts.txts['Mercury']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercurydeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.mercurydeg.SetHelpText(mtexts.txts['HelpDeg']) self.mercurydeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mercurydeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercurymin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.mercurymin.SetHelpText(mtexts.txts['HelpMin']) self.mercurymin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mercurymin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercurymintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.mercurymintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercurysec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.mercurysec.SetHelpText(mtexts.txts['HelpMin']) self.mercurysec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mercurysec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercurysectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.mercurysectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mercuryretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mercuryretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['Venus']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venusdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.venusdeg.SetHelpText(mtexts.txts['HelpDeg']) self.venusdeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.venusdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venusmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.venusmin.SetHelpText(mtexts.txts['HelpMin']) self.venusmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.venusmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venusmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.venusmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venussec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.venussec.SetHelpText(mtexts.txts['HelpMin']) self.venussec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.venussec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venussectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.venussectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.venusretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.venusretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['Mars']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marsdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.marsdeg.SetHelpText(mtexts.txts['HelpDeg']) self.marsdeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.marsdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marsmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.marsmin.SetHelpText(mtexts.txts['HelpMin']) self.marsmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.marsmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marsmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.marsmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marssec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.marssec.SetHelpText(mtexts.txts['HelpMin']) self.marssec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.marssec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marssectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.marssectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.marsretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.marsretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['Jupiter']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupiterdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.jupiterdeg.SetHelpText(mtexts.txts['HelpDeg']) self.jupiterdeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.jupiterdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupitermin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.jupitermin.SetHelpText(mtexts.txts['HelpMin']) self.jupitermin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.jupitermin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupitermintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.jupitermintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupitersec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.jupitersec.SetHelpText(mtexts.txts['HelpMin']) self.jupitersec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.jupitersec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupitersectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.jupitersectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.jupiterretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.jupiterretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['Saturn']+':') gsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturndeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.saturndeg.SetHelpText(mtexts.txts['HelpDeg']) self.saturndeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.saturndeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) label = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturnmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.saturnmin.SetHelpText(mtexts.txts['HelpMin']) self.saturnmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.saturnmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturnmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.saturnmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturnsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.saturnsec.SetHelpText(mtexts.txts['HelpMin']) self.saturnsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.saturnsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturnsectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.saturnsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.saturnretr = wx.CheckBox(self, -1, mtexts.txts['R']) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.saturnretr, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) splanetssizer.Add(gsizer, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) vsizer.Add(splanetssizer, 0) #Use suse = wx.StaticBox(self, label=mtexts.txts['Use']) susesizer = wx.StaticBoxSizer(suse, wx.VERTICAL) self.useminckb = wx.CheckBox(self, -1, mtexts.txts['Minute']) susesizer.Add(self.useminckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) self.usesecckb = wx.CheckBox(self, -1, mtexts.txts['Second']) susesizer.Add(self.usesecckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) self.useretrckb = wx.CheckBox(self, -1, mtexts.txts['Retrograde']) susesizer.Add(self.useretrckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) vsizer.Add(susesizer, 1, wx.GROW) mhsizer.Add(vsizer, 0, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL, 0) #Angles vvvsizer = wx.BoxSizer(wx.VERTICAL) sangles = wx.StaticBox(self, label='') sanglessizer = wx.StaticBoxSizer(sangles, wx.VERTICAL) gsizer = wx.GridSizer(2, 4) self.asctxt = wx.StaticText(self, -1, mtexts.txts['Asc']+':') gsizer.Add(self.asctxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.ascdeg.SetHelpText(mtexts.txts['HelpDeg']) self.ascdeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.ascdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascdegtxt = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(self.ascdegtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.ascmin.SetHelpText(mtexts.txts['HelpMin']) self.ascmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.ascmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.ascmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.ascsec.SetHelpText(mtexts.txts['HelpMin']) self.ascsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.ascsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.ascsectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.ascsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mctxt = wx.StaticText(self, -1, mtexts.txts['MC']+':') gsizer.Add(self.mctxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 359), size=(40,-1)) self.mcdeg.SetHelpText(mtexts.txts['HelpDeg']) self.mcdeg.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mcdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcdegtxt = wx.StaticText(self, -1, mtexts.txts['D2']) hsizer.Add(self.mcdegtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.mcmin.SetHelpText(mtexts.txts['HelpMin']) self.mcmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mcmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcmintxt = wx.StaticText(self, -1, mtexts.txts['M2']) hsizer.Add(self.mcmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.mcsec.SetHelpText(mtexts.txts['HelpMin']) self.mcsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.mcsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.mcsectxt = wx.StaticText(self, -1, mtexts.txts['S2']) hsizer.Add(self.mcsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) sanglessizer.Add(gsizer, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) self.useascmcckb = wx.CheckBox(self, -1, mtexts.txts['Use']) sanglessizer.Add(self.useascmcckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) vvvsizer.Add(sanglessizer, 0, wx.GROW|wx.LEFT, 5) #Force date rnge = 3000 checker = rangechecker.RangeChecker() if checker.isExtended(): rnge = 5000 sforce = wx.StaticBox(self, label='') sforcesizer = wx.StaticBoxSizer(sforce, wx.VERTICAL) gsizer = wx.GridSizer(2, 3) self.fyear = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(1, rnge), size=(50,-1)) if checker.isExtended(): self.fyear.SetHelpText(mtexts.txts['HelpYear']) else: self.fyear.SetHelpText(mtexts.txts['HelpYear2']) self.fyear.SetMaxLength(4) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fyear, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fyeartxt = wx.StaticText(self, -1, mtexts.txts['YE']) hsizer.Add(self.fyeartxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fmonth = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(1, 12), size=(50,-1)) self.fmonth.SetHelpText(mtexts.txts['HelpMonth']) self.fmonth.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fmonth, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fmonthtxt = wx.StaticText(self, -1, mtexts.txts['MO2']) hsizer.Add(self.fmonthtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fday = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(1, 31), size=(50,-1)) self.fday.SetHelpText(mtexts.txts['HelpDay']) self.fday.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fday, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fdaytxt = wx.StaticText(self, -1, mtexts.txts['DA']) hsizer.Add(self.fdaytxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fhour = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 23), size=(50,-1)) self.fhour.SetHelpText(mtexts.txts['HelpHour']) self.fhour.SetMaxLength(3) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fhour, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fhourtxt = wx.StaticText(self, -1, mtexts.txts['HO']) hsizer.Add(self.fhourtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(50,-1)) self.fmin.SetHelpText(mtexts.txts['HelpMin']) self.fmin.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fmintxt = wx.StaticText(self, -1, mtexts.txts['MI']) hsizer.Add(self.fmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(50,-1)) self.fsec.SetHelpText(mtexts.txts['HelpMin']) self.fsec.SetMaxLength(2) hsizer = wx.BoxSizer(wx.HORIZONTAL)# hsizer.Add(self.fsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.fsectxt = wx.StaticText(self, -1, mtexts.txts['SE']) hsizer.Add(self.fsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) gsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) sforcesizer.Add(gsizer, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) self.forceckb = wx.CheckBox(self, -1, mtexts.txts['ForceTheDate']) sforcesizer.Add(self.forceckb, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) vvvsizer.Add(sforcesizer, 0, wx.GROW|wx.LEFT, 5) #Approximation(Planets) sapprox = wx.StaticBox(self, label=mtexts.txts['ApproxPlanets']) sapproxsizer = wx.StaticBoxSizer(sapprox, wx.VERTICAL) self.useapproxckb = wx.CheckBox(self, -1, mtexts.txts['Use']) self.approxdeg = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 4), size=(30,-1)) self.approxdeg.SetHelpText(mtexts.txts['HelpApproxDeg']) self.approxdeg.SetMaxLength(1) self.approxmin = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.approxmin.SetHelpText(mtexts.txts['HelpMin']) self.approxmin.SetMaxLength(2) self.approxsec = wx.TextCtrl(self, -1, '', validator=intvalidator.IntValidator(0, 59), size=(40,-1)) self.approxsec.SetHelpText(mtexts.txts['HelpMin']) self.approxsec.SetMaxLength(2) hsizerDeg = wx.BoxSizer(wx.HORIZONTAL)# hsizerDeg.Add(self.approxdeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.approxdegtxt = wx.StaticText(self, -1, mtexts.txts['D']) hsizerDeg.Add(self.approxdegtxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerMin = wx.BoxSizer(wx.HORIZONTAL)# hsizerMin.Add(self.approxmin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.approxmintxt = wx.StaticText(self, -1, mtexts.txts['M']) hsizerMin.Add(self.approxmintxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerSec = wx.BoxSizer(wx.HORIZONTAL)# hsizerSec.Add(self.approxsec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) self.approxsectxt = wx.StaticText(self, -1, mtexts.txts['S']) hsizerSec.Add(self.approxsectxt, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerLon = wx.BoxSizer(wx.HORIZONTAL)# hsizerLon.Add(hsizerDeg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerLon.Add(hsizerMin, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerLon.Add(hsizerSec, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerAppr = wx.BoxSizer(wx.HORIZONTAL)# hsizerAppr.Add(self.useapproxckb, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) hsizerAppr.Add(hsizerLon, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 2) sapproxsizer.Add(hsizerAppr, 0, wx.ALIGN_LEFT|wx.LEFT|wx.TOP, 5) vvvsizer.Add(sapproxsizer, 0, wx.GROW|wx.LEFT, 5) #List sreslist =wx.StaticBox(self, label='') reslistsizer = wx.StaticBoxSizer(sreslist, wx.VERTICAL) ID_ResList = wx.NewId() self.li = ResListCtrl(self, ID_ResList, size=(360,100), style=wx.LC_VRULES|wx.LC_REPORT|wx.LC_SINGLE_SEL) reslistsizer.Add(self.li, 1, wx.GROW|wx.ALL, 5) vvvsizer.Add(reslistsizer, 0, wx.GROW|wx.LEFT, 5) #Start and Show List_Start_ID = wx.NewId() self.btnStart = wx.Button(self, List_Start_ID, mtexts.txts['Start2']) List_Show_ID = wx.NewId() self.btnShow = wx.Button(self, List_Show_ID, mtexts.txts['Show']) self.btnShow.Enable(False) hbtnsizer = wx.BoxSizer(wx.HORIZONTAL) hbtnsizer.Add(self.btnStart, 1, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL, 5) hbtnsizer.Add(self.btnShow, 1, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL, 5) vvvsizer.Add(hbtnsizer, 0, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL, 5) mhsizer.Add(vvvsizer, 0, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL, 0) mvsizer.Add(mhsizer, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) btnsizer = wx.StdDialogButtonSizer() if wx.Platform != '__WXMSW__': btn = wx.ContextHelpButton(self) btnsizer.AddButton(btn) btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Close']) btnOk.SetDefault() btnsizer.AddButton(btnOk) btnsizer.Realize() mvsizer.Add(btnsizer, 0, wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10) self.SetSizer(mvsizer) mvsizer.Fit(self) self.Bind(wx.EVT_CHECKBOX, self.onUseMin, id=self.useminckb.GetId()) self.Bind(wx.EVT_CHECKBOX, self.onUseSec, id=self.usesecckb.GetId()) self.Bind(wx.EVT_CHECKBOX, self.onUseRetr, id=self.useretrckb.GetId()) self.Bind(wx.EVT_CHECKBOX, self.onUseAscMC, id=self.useascmcckb.GetId()) self.Bind(wx.EVT_CHECKBOX, self.onUseForce, id=self.forceckb.GetId()) self.Bind(wx.EVT_CHECKBOX, self.onUseApprox, id=self.useapproxckb.GetId()) self.useminckb.SetValue(True) self.usesecckb.SetValue(True) self.useretrckb.SetValue(True) self.useascmcckb.SetValue(False) self.enableAscMC(self.useascmcckb.GetValue()) self.enableForce(self.useascmcckb.GetValue()) self.useapproxckb.SetValue(False) self.approxdeg.Enable(False) self.approxdegtxt.Enable(False) self.approxmin.Enable(False) self.approxmintxt.Enable(False) self.approxsec.Enable(False) self.approxsectxt.Enable(False) self.Bind(wx.EVT_BUTTON, self.OnStart, id=self.btnStart.GetId()) self.Bind(wx.EVT_BUTTON, self.OnShow, id=self.btnShow.GetId()) self.Bind(wx.EVT_BUTTON, self.onOK, id=btnOk.GetId()) self.Bind(EVT_FTREADY, self.OnFTReady) self.Bind(EVT_FTDATAREADY, self.OnFTDataReady) self.Bind(EVT_FTYEAR, self.OnFTYear) btnOk.SetFocus() self.progtxt = mtexts.txts['BusyInfo2'] self.suffix = '' self.found = False self.ar = None
def __init__(self, app, pos=wx.DefaultPosition, size=dlgSize, style=defaultStyle): title = _translate("PsychoPy Preferences") wx.Dialog.__init__(self, None, -1, title, pos, size, style) self.app = app self.Center() self.prefsCfg = self.app.prefs.userPrefsCfg self.prefsSpec = self.app.prefs.prefsSpec sizer = wx.BoxSizer(wx.VERTICAL) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) lineStyle = wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP sizer.Add(line, 0, lineStyle, 5) # notebook, flatnotebook or something else? self.nb = fnb.FlatNotebook(self, style=fnb.FNB_NO_X_BUTTON | fnb.FNB_NO_NAV_BUTTONS) # self.nb = wx.Notebook(self) # notebook not nice with lots of pages self.ctrls = {} sectionOrdering = [ 'app', 'builder', 'coder', 'general', 'connections', 'keyBindings' ] for section in sectionOrdering: prefsPage = self.makePrefPage(parent=self.nb, sectionName=section, prefsSection=self.prefsCfg[section], specSection=self.prefsSpec[section]) self.nb.AddPage(prefsPage, _localized[section]) self.nb.SetSelection(self.app.prefs.pageCurrent) sizer.Add(self.nb, 1, wx.EXPAND) aTable = wx.AcceleratorTable([ (wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CANCEL), (wx.ACCEL_NORMAL, wx.WXK_RETURN, wx.ID_OK), ]) self.SetAcceleratorTable(aTable) # create buttons line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() # ok btn = wx.Button(self, wx.ID_OK, _translate('OK')) btn.SetHelpText( _translate("Save prefs (in all sections) and close " "window")) btn.Bind(wx.EVT_BUTTON, self.onOK) btn.SetDefault() btnsizer.AddButton(btn) # cancel btn = wx.Button(self, wx.ID_CANCEL, _translate('Cancel')) btn.SetHelpText(_translate("Cancel any changes (to any panel)")) btn.Bind(wx.EVT_BUTTON, self.onCancel) btnsizer.AddButton(btn) # apply btn = wx.Button(self, wx.ID_APPLY, _translate('Apply')) btn.SetHelpText( _translate("Apply these prefs (in all sections) and " "continue")) btn.Bind(wx.EVT_BUTTON, self.onApply) btnsizer.AddButton(btn) # help btn = wx.Button(self, wx.ID_HELP, _translate('Help')) btn.SetHelpText(_translate("Get help on prefs")) btn.Bind(wx.EVT_BUTTON, self.onHelp) btnsizer.AddButton(btn) btnsizer.Realize() # add buttons to dlg sizer.Add(btnsizer, 0, wx.BOTTOM | wx.ALL, 5) self.SetSizerAndFit(sizer) self.SetAutoLayout(True) sizer.Fit(self)
def __init__(self, parent, utility, editfriend=None): #provider = wx.SimpleHelpProvider() #wx.HelpProvider_Set(provider) self.utility = utility self.editfriend = editfriend style = wx.DEFAULT_DIALOG_STYLE #| wx.RESIZE_BORDER pos = wx.DefaultPosition size = wx.Size(600, 200) #size, split = self.getWindowSettings() if editfriend is None: title = self.utility.lang.get('addfriend') else: title = self.utility.lang.get('editfriend') wx.Dialog.__init__(self, parent, -1, title, size=size, style=style) pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, -1, title, pos, size, style) self.PostCreate(pre) sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, title) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # name box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, self.utility.lang.get('name') + ':', wx.DefaultPosition, wx.Size(40, 18)) #label.SetHelpText("") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) if editfriend is not None: name = editfriend['name'] else: name = '' self.name_text = wx.TextCtrl(self, -1, name, size=(140, -1)) ##self.name_text.SetHelpText(self.utility.lang.get('nickname_help')) box.Add(self.name_text, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # text about e-mail invitation label = wx.StaticText(self, -1, self.utility.lang.get('pasteinvitationemail'), wx.DefaultPosition) label.Wrap(500) sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # ip box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, self.utility.lang.get('ipaddress') + ':', wx.DefaultPosition, wx.Size(40, 18)) #label.SetHelpText("") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) if editfriend is not None: ip = editfriend['ip'] else: ip = '' self.ip_text = wx.TextCtrl(self, -1, ip, size=(140, -1)) ##self.ip_text.SetHelpText(self.utility.lang.get('friendsipaddr_help')) box.Add(self.ip_text, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add( box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) # port box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, self.utility.lang.get('portnumber'), wx.DefaultPosition, wx.Size(40, 18)) #label.SetHelpText("") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) if editfriend is not None: port_str = str(editfriend['port']) else: port_str = '' self.port_text = wx.TextCtrl(self, -1, port_str, size=(140, -1)) ##self.port_text.SetHelpText(self.utility.lang.get('friendsport_help')) box.Add(self.port_text, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add( box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) # permid box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, self.utility.lang.get('permid') + ':', wx.DefaultPosition, wx.Size(40, 18)) #label.SetHelpText("") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) if editfriend is not None: permid = show_permid(editfriend['permid']) else: permid = '' self.permid_text = wx.TextCtrl(self, -1, permid, size=(300, -1)) ## self.permid_text.SetHelpText(self.utility.lang.get('friendspermid_help')) box.Add(self.permid_text, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) """ # picture box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, self.utility.lang.get('icon')) #label.SetHelpText("") box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) if editfriend is not None and editfriend.has_key('icon'): icon = str(editfriend['icon']) else: icon = '' self.icon_path = wx.TextCtrl(self, -1, icon, size=(80,-1)) ## self.icon_path.SetHelpText(self.utility.lang.get('friendsicon_help')) box.Add(self.icon_path, 3, wx.ALIGN_CENTRE|wx.ALL, 5) iconbtn = wx.Button(self, -1, label=self.utility.lang.get('browsebtn')) box.Add(iconbtn, 1, wx.ALIGN_CENTRE|wx.ALL, 5) self.Bind(wx.EVT_BUTTON, self.OnIconButton, iconbtn) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) """ box = wx.BoxSizer(wx.HORIZONTAL) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() ##if (sys.platform != 'win32'): ## btn = wx.ContextHelpButton(self) ## btnsizer.AddButton(btn) if editfriend is None: lbl = self.utility.lang.get('buttons_add') else: lbl = self.utility.lang.get('buttons_update') btn = wx.Button(self, wx.ID_OK, label=lbl) btn.SetDefault() btnsizer.AddButton(btn) self.Bind(wx.EVT_BUTTON, self.OnAddEditFriend, btn) btn = wx.Button(self, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() #sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) sizer.Add(btnsizer, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
def createSplitWindowView(self, title, value): self.SetTitle("Create Command") sizer_1 = wx.FlexGridSizer(3, 1, 0, 0) self.panel_1 = wx.Panel(self, wx.ID_ANY) sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0) grid_sizer_1 = wx.FlexGridSizer(1, 3, 0, 0) self.command = wx.Panel(self.panel_1, wx.ID_ANY) grid_sizer_1.Add(self.command, 1, wx.ALL | wx.EXPAND, 3) sizer_12 = wx.StaticBoxSizer( wx.StaticBox(self.command, wx.ID_ANY, "Command Arguements"), wx.VERTICAL) self.panel_18 = wx.Panel(self.command, wx.ID_ANY) sizer_12.Add(self.panel_18, 1, wx.EXPAND, 0) grid_sizer_2 = wx.FlexGridSizer(4, 1, 0, 0) self.panel_5 = wx.Panel(self.panel_18, wx.ID_ANY) grid_sizer_2.Add(self.panel_5, 1, wx.ALL | wx.EXPAND, 2) grid_sizer_5 = wx.GridSizer(1, 2, 0, 0) self.panel_6 = wx.Panel(self.panel_5, wx.ID_ANY) grid_sizer_5.Add(self.panel_6, 1, wx.EXPAND, 0) sizer_6 = wx.BoxSizer(wx.VERTICAL) label_4 = wx.StaticText(self.panel_6, wx.ID_ANY, "Command Type") sizer_6.Add(label_4, 0, 0, 0) self.choice_1 = wx.Choice(self.panel_6, wx.ID_ANY, choices=Globals.COMMAND_TYPES) self.choice_1.SetSelection(-1) sizer_6.Add(self.choice_1, 0, wx.EXPAND, 0) self.panel_7 = wx.Panel(self.panel_5, wx.ID_ANY) grid_sizer_5.Add(self.panel_7, 1, wx.EXPAND | wx.LEFT, 2) sizer_7 = wx.BoxSizer(wx.VERTICAL) label_5 = wx.StaticText(self.panel_7, wx.ID_ANY, "Package Name") sizer_7.Add(label_5, 0, 0, 0) self.text_ctrl_2 = wx.TextCtrl(self.panel_7, wx.ID_ANY, "") self.text_ctrl_2.Enable(False) sizer_7.Add(self.text_ctrl_2, 0, wx.EXPAND, 0) self.panel_4 = wx.Panel(self.panel_18, wx.ID_ANY) grid_sizer_2.Add(self.panel_4, 1, wx.ALL | wx.EXPAND, 2) grid_sizer_4 = wx.GridSizer(1, 2, 0, 0) self.panel_8 = wx.Panel(self.panel_4, wx.ID_ANY) grid_sizer_4.Add(self.panel_8, 1, wx.EXPAND, 0) sizer_5 = wx.BoxSizer(wx.VERTICAL) label_3 = wx.StaticText(self.panel_8, wx.ID_ANY, "App Version Id") sizer_5.Add(label_3, 0, 0, 0) self.text_ctrl_3 = wx.TextCtrl(self.panel_8, wx.ID_ANY, "") self.text_ctrl_3.Enable(False) sizer_5.Add(self.text_ctrl_3, 0, wx.EXPAND, 0) self.panel_9 = wx.Panel(self.panel_4, wx.ID_ANY) grid_sizer_4.Add(self.panel_9, 1, wx.EXPAND | wx.LEFT, 2) sizer_8 = wx.BoxSizer(wx.VERTICAL) label_6 = wx.StaticText(self.panel_9, wx.ID_ANY, "App State") sizer_8.Add(label_6, 0, 0, 0) self.choice_2 = wx.Choice(self.panel_9, wx.ID_ANY, choices=["", "Show", "Hide", "Disable"]) self.choice_2.Enable(False) self.choice_2.SetSelection(0) sizer_8.Add(self.choice_2, 0, wx.EXPAND, 0) self.panel_3 = wx.Panel(self.panel_18, wx.ID_ANY) grid_sizer_2.Add(self.panel_3, 1, wx.ALL | wx.EXPAND, 2) grid_sizer_3 = wx.GridSizer(1, 2, 0, 0) self.panel_10 = wx.Panel(self.panel_3, wx.ID_ANY) grid_sizer_3.Add(self.panel_10, 1, wx.EXPAND, 0) sizer_4 = wx.BoxSizer(wx.VERTICAL) label_2 = wx.StaticText(self.panel_10, wx.ID_ANY, "Device State") sizer_4.Add(label_2, 0, 0, 0) self.choice_3 = wx.Choice(self.panel_10, wx.ID_ANY, choices=["", "Unlocked", "Locked"]) self.choice_3.Enable(False) self.choice_3.SetSelection(0) sizer_4.Add(self.choice_3, 0, wx.EXPAND, 0) self.panel_11 = wx.Panel(self.panel_3, wx.ID_ANY) grid_sizer_3.Add(self.panel_11, 1, wx.EXPAND | wx.LEFT, 2) sizer_9 = wx.BoxSizer(wx.VERTICAL) label_7 = wx.StaticText(self.panel_11, wx.ID_ANY, "Lock Message") sizer_9.Add(label_7, 0, 0, 0) self.text_ctrl_4 = wx.TextCtrl(self.panel_11, wx.ID_ANY, "") self.text_ctrl_4.Enable(False) sizer_9.Add(self.text_ctrl_4, 0, wx.EXPAND, 0) self.panel_2 = wx.Panel(self.panel_18, wx.ID_ANY) grid_sizer_2.Add(self.panel_2, 1, wx.ALL | wx.EXPAND, 2) sizer_3 = wx.FlexGridSizer(2, 1, 0, 0) label_1 = wx.StaticText(self.panel_2, wx.ID_ANY, "Custom Config:") sizer_3.Add(label_1, 0, 0, 0) self.text_ctrl_1 = wx.TextCtrl(self.panel_2, wx.ID_ANY, "", style=wx.TE_BESTWRAP | wx.TE_MULTILINE) sizer_3.Add(self.text_ctrl_1, 0, wx.EXPAND, 0) static_line_2 = wx.StaticLine(self.panel_1, wx.ID_ANY, style=wx.LI_VERTICAL) grid_sizer_1.Add(static_line_2, 0, wx.ALL | wx.EXPAND, 2) self.schedule = wx.Panel(self.panel_1, wx.ID_ANY) grid_sizer_1.Add(self.schedule, 1, wx.ALL | wx.EXPAND, 3) sizer_10 = wx.StaticBoxSizer( wx.StaticBox(self.schedule, wx.ID_ANY, "Schedule Arguements"), wx.VERTICAL) self.panel_13 = wx.Panel(self.schedule, wx.ID_ANY) sizer_10.Add(self.panel_13, 1, wx.EXPAND, 0) grid_sizer_6 = wx.FlexGridSizer(4, 1, 0, 0) self.panel_14 = wx.Panel(self.panel_13, wx.ID_ANY) grid_sizer_6.Add(self.panel_14, 1, wx.EXPAND, 0) sizer_11 = wx.BoxSizer(wx.VERTICAL) label_9 = wx.StaticText(self.panel_14, wx.ID_ANY, "Type") sizer_11.Add(label_9, 0, 0, 0) self.choice_4 = wx.Choice( self.panel_14, wx.ID_ANY, choices=[ "Immediate", "Window", "Reocurring", ], ) self.choice_4.SetSelection(0) sizer_11.Add(self.choice_4, 0, wx.EXPAND, 0) self.panel_15 = wx.Panel(self.panel_13, wx.ID_ANY) grid_sizer_6.Add(self.panel_15, 1, wx.EXPAND, 0) sizer_13 = wx.BoxSizer(wx.VERTICAL) label_10 = wx.StaticText(self.panel_15, wx.ID_ANY, "Time Type") sizer_13.Add(label_10, 0, 0, 0) self.choice_5 = wx.Choice(self.panel_15, wx.ID_ANY, choices=["Device", "Console"]) self.choice_5.SetSelection(0) sizer_13.Add(self.choice_5, 0, wx.EXPAND, 0) self.panel_16 = wx.Panel(self.panel_13, wx.ID_ANY) grid_sizer_6.Add(self.panel_16, 1, wx.EXPAND, 0) grid_sizer_8 = wx.GridSizer(2, 1, 0, 0) self.panel_19 = wx.Panel(self.panel_16, wx.ID_ANY) grid_sizer_8.Add(self.panel_19, 1, wx.EXPAND, 0) grid_sizer_9 = wx.GridSizer(2, 1, 0, 0) label_11 = wx.StaticText(self.panel_19, wx.ID_ANY, "Start Datetime") grid_sizer_9.Add(label_11, 0, 0, 0) self.panel_20 = wx.Panel(self.panel_19, wx.ID_ANY) grid_sizer_9.Add(self.panel_20, 1, wx.EXPAND, 0) sizer_14 = wx.BoxSizer(wx.HORIZONTAL) self.datepicker_ctrl_1 = wx.adv.DatePickerCtrl(self.panel_20, wx.ID_ANY) sizer_14.Add(self.datepicker_ctrl_1, 0, 0, 0) sizer_14.Add((20, 20), 0, wx.EXPAND, 0) self.timepicker_ctrl_2 = wx.adv.TimePickerCtrl(self.panel_20, wx.ID_ANY) sizer_14.Add(self.timepicker_ctrl_2, 0, 0, 0) self.panel_21 = wx.Panel(self.panel_16, wx.ID_ANY) grid_sizer_8.Add(self.panel_21, 1, wx.EXPAND, 0) grid_sizer_10 = wx.GridSizer(2, 1, 0, 0) label_12 = wx.StaticText(self.panel_21, wx.ID_ANY, "End Datetime") grid_sizer_10.Add(label_12, 0, 0, 0) self.panel_22 = wx.Panel(self.panel_21, wx.ID_ANY) grid_sizer_10.Add(self.panel_22, 1, wx.EXPAND, 0) sizer_15 = wx.BoxSizer(wx.HORIZONTAL) self.datepicker_ctrl_3 = wx.adv.DatePickerCtrl(self.panel_22, wx.ID_ANY) sizer_15.Add(self.datepicker_ctrl_3, 0, 0, 0) sizer_15.Add((20, 20), 0, wx.EXPAND, 0) self.timepicker_ctrl_4 = wx.adv.TimePickerCtrl(self.panel_22, wx.ID_ANY) sizer_15.Add(self.timepicker_ctrl_4, 0, 0, 0) self.panel_12 = wx.Panel(self.panel_13, wx.ID_ANY) grid_sizer_6.Add(self.panel_12, 1, wx.EXPAND, 0) grid_sizer_7 = wx.FlexGridSizer(2, 1, 0, 0) label_8 = wx.StaticText(self.panel_12, wx.ID_ANY, "Days") grid_sizer_7.Add(label_8, 0, 0, 0) self.check_list_box_1 = wx.CheckListBox( self.panel_12, wx.ID_ANY, choices=[ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", ], style=wx.LB_MULTIPLE | wx.LB_NEEDED_SB, ) grid_sizer_7.Add(self.check_list_box_1, 0, wx.EXPAND, 0) static_line_1 = wx.StaticLine(self, wx.ID_ANY) sizer_1.Add(static_line_1, 0, wx.ALL | wx.EXPAND, 2) sizer_2 = wx.StdDialogButtonSizer() sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.ALL, 5) self.button_OK = wx.Button(self, wx.ID_OK, "") self.button_OK.SetDefault() sizer_2.AddButton(self.button_OK) self.button_CANCEL = wx.Button(self, wx.ID_CANCEL, "") sizer_2.AddButton(self.button_CANCEL) sizer_2.Realize() grid_sizer_7.AddGrowableRow(1) grid_sizer_7.AddGrowableCol(0) self.panel_12.SetSizer(grid_sizer_7) self.panel_22.SetSizer(sizer_15) self.panel_21.SetSizer(grid_sizer_10) self.panel_20.SetSizer(sizer_14) self.panel_19.SetSizer(grid_sizer_9) self.panel_16.SetSizer(grid_sizer_8) self.panel_15.SetSizer(sizer_13) self.panel_14.SetSizer(sizer_11) grid_sizer_6.AddGrowableRow(3) grid_sizer_6.AddGrowableCol(0) self.panel_13.SetSizer(grid_sizer_6) self.schedule.SetSizer(sizer_10) sizer_3.AddGrowableRow(1) sizer_3.AddGrowableCol(0) self.panel_2.SetSizer(sizer_3) self.panel_11.SetSizer(sizer_9) self.panel_10.SetSizer(sizer_4) self.panel_3.SetSizer(grid_sizer_3) self.panel_9.SetSizer(sizer_8) self.panel_8.SetSizer(sizer_5) self.panel_4.SetSizer(grid_sizer_4) self.panel_7.SetSizer(sizer_7) self.panel_6.SetSizer(sizer_6) self.panel_5.SetSizer(grid_sizer_5) grid_sizer_2.AddGrowableRow(3) grid_sizer_2.AddGrowableCol(0) self.panel_18.SetSizer(grid_sizer_2) self.command.SetSizer(sizer_12) grid_sizer_1.AddGrowableRow(0) grid_sizer_1.AddGrowableCol(0) grid_sizer_1.AddGrowableCol(2) self.panel_1.SetSizer(grid_sizer_1) sizer_1.AddGrowableRow(0) sizer_1.AddGrowableCol(0) self.SetSizer(sizer_1) sizer_1.Fit(self) sizer_1.SetSizeHints(self) self.SetAffirmativeId(self.button_OK.GetId()) self.SetEscapeId(self.button_CANCEL.GetId()) self.Layout() self.Centre() self.datepicker_ctrl_1.Enable(False) self.timepicker_ctrl_2.Enable(False) self.datepicker_ctrl_3.Enable(False) self.timepicker_ctrl_4.Enable(False) self.check_list_box_1.Enable(False) self.button_OK.Enable(False) self.choice_1.Bind(wx.EVT_CHOICE, self.onCommandType) self.choice_3.Bind(wx.EVT_CHOICE, self.onDeviceState) self.button_OK.Bind(wx.EVT_BUTTON, self.OnClose) self.button_CANCEL.Bind(wx.EVT_BUTTON, self.OnClose) self.choice_4.Bind(wx.EVT_CHOICE, self.onScheduleType) self.startDate = None self.endDate = None self.winStartTime = None self.winEndTime = None
def __init__(self, parent, options, ephepath): # Instead of calling wx.Dialog.__init__ we precreate the dialog # so we can set an extra style that must be set before # creation, and then we create the GUI object using the Create # method. pre = wx.Dialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, -1, mtexts.txts['PrimaryDirs'], pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE) # This next step is the most important, it turns this Python # object into the real wrapper of the dialog (instead of pre) # as far as the wxPython extension is concerned. self.PostCreate(pre) self.parent = parent self.options = options self.ephepath = ephepath self.cpdlons = options.pdcustomerlon[:] self.cpdlats = options.pdcustomerlat[:] self.southern = options.pdcustomersouthern self.cpd2lons = options.pdcustomer2lon[:] self.cpd2lats = options.pdcustomer2lat[:] self.southern2 = options.pdcustomer2southern #main vertical sizer mvsizer = wx.BoxSizer(wx.VERTICAL) #main horizontal sizer mhsizer = wx.BoxSizer(wx.HORIZONTAL) #Type stype = wx.StaticBox(self, label='') typesizer = wx.StaticBoxSizer(stype, wx.VERTICAL) self.placidiansemiarcrb = wx.RadioButton( self, -1, mtexts.txts['PlacidianSemiArc'], style=wx.RB_GROUP) typesizer.Add(self.placidiansemiarcrb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 5) self.placidiansemiarcrb.SetHelpText( mtexts.txts['HelpPlacidianSemiArc']) self.placidianutprb = wx.RadioButton( self, -1, mtexts.txts['PlacidianUnderThePole']) typesizer.Add(self.placidianutprb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 5) self.placidianutprb.SetHelpText( mtexts.txts['HelpPlacidianUnderThePole']) self.regiomontanrb = wx.RadioButton(self, -1, mtexts.txts['Regiomontan']) typesizer.Add(self.regiomontanrb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 5) self.regiomontanrb.SetHelpText(mtexts.txts['HelpRegiomontan']) self.Bind(wx.EVT_RADIOBUTTON, self.onPlacidian, id=self.placidiansemiarcrb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onPlacidianUTP, id=self.placidianutprb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onRegiomontan, id=self.regiomontanrb.GetId()) # self.placidianutprb.Enable(False) vsizer = wx.BoxSizer(wx.VERTICAL) vsizer.Add(typesizer, 1, wx.GROW | wx.ALIGN_LEFT | wx.TOP, 5) #Subtype vzodsizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, mtexts.txts['UseSZ'] + ':') vzodsizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.szneitherrb = wx.RadioButton(self, -1, mtexts.txts['SZNeither'], style=wx.RB_GROUP) self.szneitherrb.SetHelpText(mtexts.txts['HelpSZNeither']) vzodsizer.Add(self.szneitherrb, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.szpromissorrb = wx.RadioButton(self, -1, mtexts.txts['SZPromissor']) self.szpromissorrb.SetHelpText(mtexts.txts['HelpSZPromissor']) vzodsizer.Add(self.szpromissorrb, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.szsignificatorrb = wx.RadioButton(self, -1, mtexts.txts['SZSignificator']) self.szsignificatorrb.SetHelpText(mtexts.txts['HelpSZSignificator']) vzodsizer.Add(self.szsignificatorrb, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.szbothrb = wx.RadioButton(self, -1, mtexts.txts['SZBoth']) self.szbothrb.SetHelpText(mtexts.txts['HelpSZBoth']) vzodsizer.Add(self.szbothrb, 0, wx.ALIGN_LEFT | wx.ALL, 2) hzodsizer = wx.BoxSizer(wx.HORIZONTAL) self.szbianchinickb = wx.CheckBox(self, -1, mtexts.txts['Bianchini']) hzodsizer.Add(self.szbianchinickb, 0, wx.ALIGN_LEFT | wx.LEFT, 20) vzodsizer.Add(hzodsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) ssubtype = wx.StaticBox(self, label='') subtypesizer = wx.StaticBoxSizer(ssubtype, wx.VERTICAL) self.mundanerb = wx.RadioButton(self, -1, mtexts.txts['Mundane'], style=wx.RB_GROUP) subtypesizer.Add(self.mundanerb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 5) self.mundanerb.SetHelpText(mtexts.txts['HelpMundane']) self.zodiacalrb = wx.RadioButton(self, -1, mtexts.txts['Zodiacal']) self.zodiacalrb.SetHelpText(mtexts.txts['HelpZodiacal']) subtypesizer.Add(self.zodiacalrb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 5) subtypesizer.Add(vzodsizer, 0, wx.ALIGN_LEFT | wx.LEFT, 20) # self.bothrb = wx.RadioButton(self, -1, mtexts.txts['Both']) # subtypesizer.Add(self.bothrb, 0, wx.ALIGN_LEFT|wx.ALL|wx.TOP, 5) self.Bind(wx.EVT_RADIOBUTTON, self.onMundane, id=self.mundanerb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onZodiacal, id=self.zodiacalrb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onSZNeither, id=self.szneitherrb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onSZPromissor, id=self.szpromissorrb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onSZSignificator, id=self.szsignificatorrb.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.onSZBoth, id=self.szbothrb.GetId()) # self.Bind(wx.EVT_RADIOBUTTON, self.onBoth, id=self.bothrb.GetId()) vsizer.Add(subtypesizer, 0, wx.GROW | wx.ALIGN_LEFT | wx.BOTTOM, 5) self.zodopt = wx.StaticBox(self, label=mtexts.txts['ZodiacalOpts']) zodoptsizer = wx.StaticBoxSizer(self.zodopt, wx.VERTICAL) self.aspspromstosigsckb = wx.CheckBox( self, -1, mtexts.txts['ZodAspsPromsToSigs1']) zodoptsizer.Add(self.aspspromstosigsckb, 0, wx.ALIGN_LEFT | wx.TOP | wx.LEFT | wx.RIGHT, 5) vsubsizer = wx.BoxSizer(wx.VERTICAL) self.labelzodopt1 = wx.StaticText(self, -1, mtexts.txts['ZodAspsPromsToSigs2']) vsubsizer.Add(self.labelzodopt1, 0, wx.ALIGN_LEFT | wx.LEFT, 30) zodoptsizer.Add(vsubsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.promstosigaspsckb = wx.CheckBox(self, -1, mtexts.txts['ZodPromsToSigAsps1']) zodoptsizer.Add(self.promstosigaspsckb, 0, wx.ALIGN_LEFT | wx.TOP | wx.LEFT | wx.RIGHT, 5) vsubsizer = wx.BoxSizer(wx.VERTICAL) self.labelzodopt2 = wx.StaticText(self, -1, mtexts.txts['ZodPromsToSigAsps2']) vsubsizer.Add(self.labelzodopt2, 0, wx.ALIGN_LEFT | wx.LEFT, 30) zodoptsizer.Add(vsubsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.ascmchcsaqspromsckb = wx.CheckBox( self, -1, mtexts.txts['ZodAscMCHCsAsProms']) zodoptsizer.Add(self.ascmchcsaqspromsckb, 0, wx.ALIGN_LEFT | wx.TOP | wx.LEFT | wx.RIGHT, 5) vsizer.Add(zodoptsizer, 0, wx.GROW | wx.ALIGN_LEFT | wx.BOTTOM, 5) mhsizer.Add(vsizer, 0, wx.GROW | wx.ALIGN_LEFT | wx.LEFT, 0) #Apply sapply = wx.StaticBox(self, label='') applysizer = wx.StaticBoxSizer(sapply, wx.VERTICAL) fgsizer = wx.FlexGridSizer(2, gap=wx.Size(0, 0)) vsizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, mtexts.txts['Promissors']) vsizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promsunckb = wx.CheckBox(self, -1, mtexts.txts['Sun']) vsizer.Add(self.promsunckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.prommoonckb = wx.CheckBox(self, -1, mtexts.txts['Moon']) vsizer.Add(self.prommoonckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) hsubsizer = wx.BoxSizer(wx.HORIZONTAL) vsubsizer = wx.BoxSizer(wx.VERTICAL) self.secmotionckb = wx.CheckBox(self, -1, mtexts.txts['SecondaryMotion']) vsubsizer.Add(self.secmotionckb, 0) #, wx.ALIGN_LEFT|wx.LEFT, 15) self.secmotionitercb = wx.ComboBox(self, -1, mtexts.smiterList[0], size=(100, -1), choices=mtexts.smiterList, style=wx.CB_DROPDOWN | wx.CB_READONLY) vsubsizer.Add(self.secmotionitercb, 0) #, wx.ALIGN_LEFT|wx.LEFT, 15) hsubsizer.Add(vsubsizer, 0, wx.ALIGN_LEFT | wx.LEFT, 15) vsizer.Add(hsubsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) self.prommercuryckb = wx.CheckBox(self, -1, mtexts.txts['Mercury']) vsizer.Add(self.prommercuryckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promvenusckb = wx.CheckBox(self, -1, mtexts.txts['Venus']) vsizer.Add(self.promvenusckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.prommarsckb = wx.CheckBox(self, -1, mtexts.txts['Mars']) vsizer.Add(self.prommarsckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promjupiterckb = wx.CheckBox(self, -1, mtexts.txts['Jupiter']) vsizer.Add(self.promjupiterckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promsaturnckb = wx.CheckBox(self, -1, mtexts.txts['Saturn']) vsizer.Add(self.promsaturnckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promuranusckb = wx.CheckBox(self, -1, mtexts.txts['Uranus']) vsizer.Add(self.promuranusckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promneptuneckb = wx.CheckBox(self, -1, mtexts.txts['Neptune']) vsizer.Add(self.promneptuneckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promplutockb = wx.CheckBox(self, -1, mtexts.txts['Pluto']) vsizer.Add(self.promplutockb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promanodeckb = wx.CheckBox(self, -1, mtexts.txts['AscNode']) vsizer.Add(self.promanodeckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promdnodeckb = wx.CheckBox(self, -1, mtexts.txts['DescNode']) vsizer.Add(self.promdnodeckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promantsckb = wx.CheckBox(self, -1, mtexts.txts['Antiscia']) vsizer.Add(self.promantsckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) # self.prommidpointsckb = wx.CheckBox(self, -1, mtexts.txts['MidPoints']) # vsizer.Add(self.prommidpointsckb, 0, wx.ALIGN_LEFT|wx.ALL|wx.TOP, 2) self.promlofckb = wx.CheckBox(self, -1, mtexts.txts['LoF']) vsizer.Add(self.promlofckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.promtermsckb = wx.CheckBox(self, -1, mtexts.txts['Terms2']) vsizer.Add(self.promtermsckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.Bind(wx.EVT_CHECKBOX, self.onPromMoon, id=self.prommoonckb.GetId()) fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT | wx.ALL, 5) vsizer = wx.BoxSizer(wx.VERTICAL) self.conjunctiockb = wx.CheckBox(self, -1, mtexts.txts['Conjunctio']) vsizer.Add(self.conjunctiockb, 0, wx.ALIGN_LEFT | wx.TOP, 20) self.semisextilckb = wx.CheckBox(self, -1, mtexts.txts['Semisextil']) vsizer.Add(self.semisextilckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.semiquadratckb = wx.CheckBox(self, -1, mtexts.txts['Semiquadrat']) vsizer.Add(self.semiquadratckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.sextilckb = wx.CheckBox(self, -1, mtexts.txts['Sextil']) vsizer.Add(self.sextilckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.quintileckb = wx.CheckBox(self, -1, mtexts.txts['Quintile']) vsizer.Add(self.quintileckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.quadratckb = wx.CheckBox(self, -1, mtexts.txts['Quadrat']) vsizer.Add(self.quadratckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.trigonckb = wx.CheckBox(self, -1, mtexts.txts['Trigon']) vsizer.Add(self.trigonckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.sesquiquadratckb = wx.CheckBox(self, -1, mtexts.txts['Sesquiquadrat']) vsizer.Add(self.sesquiquadratckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.biquintileckb = wx.CheckBox(self, -1, mtexts.txts['Biquintile']) vsizer.Add(self.biquintileckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.quinqunxckb = wx.CheckBox(self, -1, mtexts.txts['Quinqunx']) vsizer.Add(self.quinqunxckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.oppositiockb = wx.CheckBox(self, -1, mtexts.txts['Oppositio']) vsizer.Add(self.oppositiockb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.mundaneparckb = wx.CheckBox(self, -1, mtexts.txts['Parallel']) vsizer.Add(self.mundaneparckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) self.raptparckb = wx.CheckBox(self, -1, mtexts.txts['RaptParallel']) vsizer.Add(self.raptparckb, 0, wx.ALIGN_LEFT | wx.TOP, 2) scustomer = wx.StaticBox(self, label=mtexts.txts['Promissors']) customersizer = wx.StaticBoxSizer(scustomer, wx.VERTICAL) vsubsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.customerckb = wx.CheckBox(self, -1, '') hsizer.Add(self.customerckb, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) ID_Customer = wx.NewId() self.btnCustomer = wx.Button(self, ID_Customer, mtexts.txts['Customer2']) self.Bind(wx.EVT_BUTTON, self.onCustomer, id=ID_Customer) self.Bind(wx.EVT_CHECKBOX, self.onCustomerCheck, id=self.customerckb.GetId()) hsizer.Add(self.btnCustomer, 0, wx.ALIGN_LEFT) vsubsizer.Add(hsizer, 0, wx.ALIGN_LEFT | wx.TOP | wx.BOTTOM, 2) customersizer.Add(vsubsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) vsizer.Add(customersizer, 0, wx.ALIGN_LEFT | wx.TOP, 10) scustomer2 = wx.StaticBox(self, label=mtexts.txts['Significators']) customer2sizer = wx.StaticBoxSizer(scustomer2, wx.VERTICAL) vsubsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.customer2ckb = wx.CheckBox(self, -1, '') hsizer.Add(self.customer2ckb, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) ID_Customer2 = wx.NewId() self.btnCustomer2 = wx.Button(self, ID_Customer2, mtexts.txts['User2']) self.Bind(wx.EVT_BUTTON, self.onCustomer2, id=ID_Customer2) self.Bind(wx.EVT_CHECKBOX, self.onCustomer2Check, id=self.customer2ckb.GetId()) hsizer.Add(self.btnCustomer2, 0, wx.ALIGN_LEFT) vsubsizer.Add(hsizer, 0, wx.ALIGN_LEFT | wx.TOP | wx.BOTTOM, 2) customer2sizer.Add(vsubsizer, 0, wx.ALIGN_LEFT | wx.ALL, 2) vsizer.Add(customer2sizer, 0, wx.ALIGN_LEFT | wx.TOP, 5) fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT | wx.ALL, 5) vsizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, mtexts.txts['Significators']) vsizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigascckb = wx.CheckBox(self, -1, 'Asc') vsizer.Add(self.sigascckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigmcckb = wx.CheckBox(self, -1, 'MC') vsizer.Add(self.sigmcckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sighousecuspsckb = wx.CheckBox(self, -1, mtexts.txts['HouseCusps']) vsizer.Add(self.sighousecuspsckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigsunckb = wx.CheckBox(self, -1, mtexts.txts['Sun']) vsizer.Add(self.sigsunckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigmoonckb = wx.CheckBox(self, -1, mtexts.txts['Moon']) vsizer.Add(self.sigmoonckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigmercuryckb = wx.CheckBox(self, -1, mtexts.txts['Mercury']) vsizer.Add(self.sigmercuryckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigvenusckb = wx.CheckBox(self, -1, mtexts.txts['Venus']) vsizer.Add(self.sigvenusckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigmarsckb = wx.CheckBox(self, -1, mtexts.txts['Mars']) vsizer.Add(self.sigmarsckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigjupiterckb = wx.CheckBox(self, -1, mtexts.txts['Jupiter']) vsizer.Add(self.sigjupiterckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigsaturnckb = wx.CheckBox(self, -1, mtexts.txts['Saturn']) vsizer.Add(self.sigsaturnckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.siguranusckb = wx.CheckBox(self, -1, mtexts.txts['Uranus']) vsizer.Add(self.siguranusckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.signeptuneckb = wx.CheckBox(self, -1, mtexts.txts['Neptune']) vsizer.Add(self.signeptuneckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigplutockb = wx.CheckBox(self, -1, mtexts.txts['Pluto']) vsizer.Add(self.sigplutockb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.siganodeckb = wx.CheckBox(self, -1, mtexts.txts['AscNode']) vsizer.Add(self.siganodeckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigdnodeckb = wx.CheckBox(self, -1, mtexts.txts['DescNode']) vsizer.Add(self.sigdnodeckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.siglofckb = wx.CheckBox(self, -1, mtexts.txts['LoF']) vsizer.Add(self.siglofckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) self.sigsyzckb = wx.CheckBox(self, -1, mtexts.txts['Syzygy']) vsizer.Add(self.sigsyzckb, 0, wx.ALIGN_LEFT | wx.ALL | wx.TOP, 2) fgsizer.Add(vsizer, 0, wx.ALIGN_LEFT | wx.ALL, 5) applysizer.Add(fgsizer, 0, wx.ALIGN_LEFT, 5) mhsizer.Add(applysizer, 0, wx.GROW | wx.ALIGN_LEFT | wx.ALL, 5) mvsizer.Add(mhsizer, 0, wx.GROW | wx.ALIGN_LEFT | wx.LEFT, 5) btnsizer = wx.StdDialogButtonSizer() if wx.Platform != '__WXMSW__': btn = wx.ContextHelpButton(self) btnsizer.AddButton(btn) btnOk = wx.Button(self, wx.ID_OK, mtexts.txts['Ok']) btnsizer.AddButton(btnOk) btnOk.SetHelpText(mtexts.txts['HelpOk']) btnOk.SetDefault() btn = wx.Button(self, wx.ID_CANCEL, mtexts.txts['Cancel']) btnsizer.AddButton(btn) btn.SetHelpText(mtexts.txts['HelpCancel']) btnsizer.Realize() mvsizer.Add(btnsizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizer(mvsizer) mvsizer.Fit(self) btnOk.SetFocus()
def __init__(self, klass, base_classes=None, message="Select Class", toplevel=True, options=None, defaults=None): pos = wx.GetMousePosition() wx.Dialog.__init__(self, common.main, -1, _(message), pos) self.standalone = self.base = None if base_classes: # base class self.base = wx.RadioBox(self, -1, ("base class"), choices=base_classes, style=wx.RA_VERTICAL) self.base.SetSelection(0) self.number = 1 self.class_names = set(_get_all_class_names(common.root)) self.toplevel_names = set(c.name for c in common.root.children) self.toplevel = toplevel # if this is True, the name must be unique, as the generated class will have it # class self._klass = klass if common.root.language.lower() != 'xrc': klass = self.get_next_class_name(klass) self.klass = wx.TextCtrl(self, -1, klass) self.klass.Bind(wx.EVT_TEXT, self.on_text) # for validation # for frame or standalone? this is used by the derived class below and just for menu bar and tool bar if self.parent_property and self.parent: # self.parent must be set by the derived class in this case; here we check whether it is set already choices = [ "Add to %s '%s'" % (self.parent.WX_CLASS[2:], self.parent.name), "Standalone" ] self.standalone = wx.RadioBox(self, -1, ("Type"), choices=choices, style=wx.RA_VERTICAL) self.standalone.Bind(wx.EVT_RADIOBOX, self.on_standalone) if self.parent.properties[self.parent_property].value: self.standalone.SetSelection(1) self.standalone.Disable() else: self.standalone.SetSelection(0) self.klass.Disable() # layout szr = wx.BoxSizer(wx.VERTICAL) if self.standalone: szr.Add(self.standalone, 0, wx.ALL | wx.EXPAND, 5) if self.base: szr.Add(self.base, 0, wx.ALL | wx.EXPAND, 5) hszr = wx.BoxSizer(wx.HORIZONTAL) hszr.Add(wx.StaticText( self, -1, _("class"), ), 0, wx.EXPAND | wx.ALL, 3) hszr.Add(self.klass, 2) szr.Add(hszr, 0, wx.EXPAND | wx.ALL, 5) # options if options: line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) szr.Add(line, 0, wx.EXPAND | wx.ALL, 5) self.options = [] for o, option in enumerate(options): cb = wx.CheckBox(self, -1, _(option)) cb.SetValue(defaults and defaults[o]) szr.Add(cb, 0, wx.ALL, 5) self.options.append(cb) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) szr.Add(line, 0, wx.EXPAND | wx.TOP | wx.LEFT, 5) # buttons btnbox = wx.StdDialogButtonSizer() self.btnOK = btnOK = wx.Button(self, wx.ID_OK) #, _('OK')) btnOK.SetDefault() btnCANCEL = wx.Button(self, wx.ID_CANCEL) #, _('Cancel')) btnbox.AddButton(btnOK) #, 0, wx.ALL, 3) btnbox.AddButton(btnCANCEL) #, 0, wx.ALL, 3) btnbox.Realize() szr.Add(btnbox, 0, wx.ALL | wx.ALIGN_CENTER, 5) self.SetAutoLayout(True) self.SetSizer(szr) szr.Fit(self)
def __init__(self, parent, freq, callbackCal): self.callback = callbackCal self.cal = 0 wx.Dialog.__init__(self, parent=parent, title="Auto Calibration", style=wx.CAPTION) self.Bind(wx.EVT_CLOSE, self.__on_close) title = wx.StaticText(self, label="Calibrate to a known stable signal") font = title.GetFont() font.SetPointSize(font.GetPointSize() + 2) title.SetFont(font) text = wx.StaticText(self, label="Frequency (MHz)") self.textFreq = masked.NumCtrl(self, value=freq, fractionWidth=3, min=F_MIN, max=F_MAX) self.buttonCal = wx.Button(self, label="Calibrate") if len(parent.devicesRtl) == 0: self.buttonCal.Disable() self.buttonCal.Bind(wx.EVT_BUTTON, self.__on_cal) self.textResult = wx.StaticText(self) self.buttonOk = wx.Button(self, wx.ID_OK, 'OK') self.buttonOk.Disable() self.buttonCancel = wx.Button(self, wx.ID_CANCEL, 'Cancel') self.buttonOk.Bind(wx.EVT_BUTTON, self.__on_close) self.buttonCancel.Bind(wx.EVT_BUTTON, self.__on_close) buttons = wx.StdDialogButtonSizer() buttons.AddButton(self.buttonOk) buttons.AddButton(self.buttonCancel) buttons.Realize() sizer = wx.GridBagSizer(10, 10) sizer.Add(title, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=10) sizer.Add(text, pos=(1, 0), flag=wx.ALL, border=10) sizer.Add(self.textFreq, pos=(1, 1), flag=wx.ALL, border=5) sizer.Add(self.buttonCal, pos=(2, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL | wx.EXPAND, border=10) sizer.Add(self.textResult, pos=(3, 0), span=(1, 2), flag=wx.ALL, border=10) sizer.Add(buttons, pos=(4, 0), span=(1, 2), flag=wx.ALL | wx.ALIGN_RIGHT, border=10) self.SetSizerAndFit(sizer)
def __init__(self, parent, solver, solvergui, fom_string): '''__init__(self, parent, solver, fom_string, mut_schemes,\ current_mut_scheme) parent - parent window, solver - the solver (Diffev alg.) fom_string - the fom function string ''' wx.Dialog.__init__(self, parent, -1, 'Optimizer settings') #self.SetAutoLayout(True) self.solver = solver self.solvergui = solvergui self.apply_change = None col_sizer = wx.BoxSizer(wx.HORIZONTAL) row_sizer1 = wx.BoxSizer(wx.VERTICAL) # Make the Diff. Ev. box de_box = wx.StaticBox(self, -1, "Diff. Ev.") de_box_sizer = wx.StaticBoxSizer(de_box, wx.VERTICAL) de_grid = wx.GridBagSizer(2, 2) km_sizer = wx.BoxSizer(wx.HORIZONTAL) km_text = wx.StaticText(self, -1, 'k_m ') self.km_control = NumCtrl(self, value = self.solver.km,\ fractionWidth = 2, integerWidth = 2) km_sizer.Add(km_text,0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) km_sizer.Add(self.km_control,1, \ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) km_sizer.Add((10, 20), 0, wx.EXPAND) de_grid.Add(km_sizer, (0,0),\ flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL,\ border = 5) kr_sizer = wx.BoxSizer(wx.HORIZONTAL) kr_sizer.Add((10, 20), 0, wx.EXPAND) kr_text = wx.StaticText(self, -1, 'k_r ') self.kr_control = NumCtrl(self, value = self.solver.kr,\ fractionWidth = 2, integerWidth = 2) kr_sizer.Add(kr_text, 1, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) kr_sizer.Add(self.kr_control, 0, \ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) de_grid.Add(kr_sizer, (0,1), \ flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL,\ border = 5) method_sizer = wx.BoxSizer(wx.HORIZONTAL) method_text = wx.StaticText(self, -1, 'Method ') mut_schemes = [f.__name__ for f in self.solver.mutation_schemes] self.method_choice = wx.Choice(self, -1,\ choices = mut_schemes) self.method_choice.SetSelection(self.solver.get_create_trial(True)) method_sizer.Add(method_text,0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) method_sizer.Add(self.method_choice,0,\ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) de_grid.Add(method_sizer, (1,0),(1,2), \ flag = wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND,\ border = 5) de_box_sizer.Add(de_grid, 0, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer1.Add(de_box_sizer, 0, wx.EXPAND, 5) #FOM BOX SIZER fom_box = wx.StaticBox(self, -1, "FOM") fom_box_sizer = wx.StaticBoxSizer(fom_box, wx.VERTICAL) # FOM choice fom_sizer = wx.BoxSizer(wx.HORIZONTAL) fom_text = wx.StaticText(self, -1, 'Figure of merit ') self.fom_choice = wx.Choice(self, -1, choices=fom_funcs.func_names) self.fom_choice.SetSelection(fom_funcs.func_names.index(fom_string)) fom_sizer.Add(fom_text,0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) fom_sizer.Add(self.fom_choice,0,\ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 10) fom_box_sizer.Add(fom_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # Errorbar level errorbar_sizer = wx.BoxSizer(wx.HORIZONTAL) errorbar_text = wx.StaticText(self, -1, 'Error bar level ') self.errorbar_control = NumCtrl(self, value =\ self.solvergui.fom_error_bars_level,\ fractionWidth = 2, integerWidth = 2) errorbar_sizer.Add(errorbar_text,0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) errorbar_sizer.Add(self.errorbar_control,1, \ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) errorbar_sizer.Add((10, 20), 0, wx.EXPAND) fom_box_sizer.Add(errorbar_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer1.Add(fom_box_sizer, 0, wx.EXPAND, 5) # Make the Fitting box fit_box = wx.StaticBox(self, -1, "Fitting") fit_box_sizer = wx.StaticBoxSizer(fit_box, wx.VERTICAL) # Make a sizer for the check boxes cb_sizer = wx.BoxSizer(wx.HORIZONTAL) fit_box_sizer.Add(cb_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # Check box for start guess startguess_control = wx.CheckBox(self, -1, "Start guess") cb_sizer.Add(startguess_control, 0, wx.ALIGN_CENTRE | wx.ALL, 5) startguess_control.SetValue(self.solver.use_start_guess) self.startguess_control = startguess_control # Check box for using boundaries bound_control = wx.CheckBox(self, -1, "Use (Max, Min)") cb_sizer.Add(bound_control, 0, wx.ALIGN_CENTRE | wx.ALL, 5) bound_control.SetValue(self.solver.use_boundaries) self.bound_control = bound_control # Check box and integer input for autosave autosave_sizer = wx.BoxSizer(wx.HORIZONTAL) use_autosave_control = wx.CheckBox(self, -1, "Autosave, interval ") use_autosave_control.SetValue(self.solver.use_autosave) autosave_sc = wx.SpinCtrl(self) autosave_sc.SetRange(1, 1000) autosave_sc.SetValue(self.solver.autosave_interval) autosave_sc.Enable(True) autosave_sizer.Add(use_autosave_control, 0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 5) autosave_sizer.Add(autosave_sc,0,\ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 5) self.autosave_sc = autosave_sc self.use_autosave_control = use_autosave_control fit_box_sizer.Add(autosave_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # Checkbox for saving all evals save_sizer = wx.BoxSizer(wx.HORIZONTAL) save_all_control = wx.CheckBox(self, -1, "Save evals, buffer ") save_all_control.SetValue(self.solvergui.save_all_evals) buffer_sc = wx.SpinCtrl(self) buffer_sc.SetRange(1000, 100000000) buffer_sc.SetValue(self.solver.max_log) buffer_sc.Enable(True) save_sizer.Add(save_all_control, 0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 5) save_sizer.Add(buffer_sc,0,\ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 5) self.buffer_sc = buffer_sc self.save_all_control = save_all_control fit_box_sizer.Add(save_sizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer1.Add(fit_box_sizer, 1, wx.EXPAND, 5) col_sizer.Add(row_sizer1, 1, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer2 = wx.BoxSizer(wx.VERTICAL) # Make the Population box pop_box = wx.StaticBox(self, -1, "Population size") pop_box_sizer = wx.StaticBoxSizer(pop_box, wx.VERTICAL) pop_grid = wx.FlexGridSizer(0, 2, 0, 0) multsize_radio = wx.RadioButton(self, -1, " Relative size ",\ style = wx.RB_GROUP ) fixedsize_radio = wx.RadioButton(self, -1, " Fixed size ") multsize_sc = wx.SpinCtrl(self) multsize_sc.SetRange(1, 1000) multsize_sc.SetValue(self.solver.pop_mult) multsize_sc.Enable(self.solver.use_pop_mult) fixedsize_sc = wx.SpinCtrl(self) fixedsize_sc.SetRange(1, 1000) fixedsize_sc.SetValue(self.solver.pop_size) fixedsize_sc.Enable(not self.solver.use_pop_mult) self.pop_multsize_radio = multsize_radio self.pop_fixedsize_radio = fixedsize_radio self.pop_multsize_sc = multsize_sc self.pop_fixedsize_sc = fixedsize_sc pop_grid.Add(multsize_radio, 0,\ wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) pop_grid.Add(multsize_sc, 0,\ wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) pop_grid.Add( fixedsize_radio, 0,\ wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) pop_grid.Add(fixedsize_sc, 0,\ wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) pop_box_sizer.Add(pop_grid, 0, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer2.Add(pop_box_sizer, 1, wx.EXPAND, 5) self.Bind(wx.EVT_RADIOBUTTON, self.on_pop_select, multsize_radio) self.Bind(wx.EVT_RADIOBUTTON, self.on_pop_select, fixedsize_radio) multsize_radio.SetValue(self.solver.use_pop_mult) fixedsize_radio.SetValue(not self.solver.use_pop_mult) # Make the Generation box gen_box = wx.StaticBox(self, -1, "Max Generations") gen_box_sizer = wx.StaticBoxSizer(gen_box, wx.VERTICAL) gen_grid = wx.FlexGridSizer(0, 2, 0, 0) gen_multsize_radio = wx.RadioButton( self, -1, " Relative size ",\ style = wx.RB_GROUP ) gen_fixedsize_radio = wx.RadioButton(self, -1, " Fixed size ") gen_multsize_sc = wx.SpinCtrl(self) gen_multsize_sc.SetRange(1, 10000) gen_multsize_sc.SetValue(self.solver.max_generation_mult) gen_multsize_sc.Enable(not self.solver.use_max_generations) gen_fixedsize_sc = wx.SpinCtrl(self) gen_fixedsize_sc.SetRange(1, 10000) gen_fixedsize_sc.SetValue(self.solver.max_generations) gen_fixedsize_sc.Enable(self.solver.use_max_generations) self.gen_multsize_radio = gen_multsize_radio self.gen_fixedsize_radio = gen_fixedsize_radio self.gen_multsize_sc = gen_multsize_sc self.gen_fixedsize_sc = gen_fixedsize_sc gen_grid.Add(gen_multsize_radio, 0,\ wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) gen_grid.Add(gen_multsize_sc, 0,\ wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) gen_grid.Add(gen_fixedsize_radio, 0,\ wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) gen_grid.Add(gen_fixedsize_sc, 0,\ wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) gen_box_sizer.Add(gen_grid, 0, wx.ALIGN_CENTRE | wx.ALL, 5) row_sizer2.Add(gen_box_sizer, 1, wx.EXPAND, 5) self.Bind(wx.EVT_RADIOBUTTON, self.on_gen_select, gen_multsize_radio) self.Bind(wx.EVT_RADIOBUTTON, self.on_gen_select, gen_fixedsize_radio) gen_fixedsize_radio.SetValue(self.solver.use_max_generations) gen_multsize_radio.SetValue(not self.solver.use_max_generations) ## # Make the parallel fitting box parallel_box = wx.StaticBox(self, -1, "Parallel processing") parallel_box_sizer = wx.StaticBoxSizer(parallel_box, wx.VERTICAL) use_parallel_control = wx.CheckBox(self, -1, "Parallel fitting") use_parallel_control.SetValue(self.solver.use_parallel_processing) use_parallel_control.Enable(diffev.__parallel_loaded__) self.use_parallel_control = use_parallel_control parallel_box_sizer.Add(use_parallel_control, 1,\ wx.ALIGN_CENTRE|wx.EXPAND, 5 ) processes_sc = wx.SpinCtrl(self, size=(80, -1)) processes_sc.SetRange(1, 100) processes_sc.SetValue(self.solver.processes) processes_sc.Enable(diffev.__parallel_loaded__) chunk_size_sc = wx.SpinCtrl(self, size=(80, -1)) chunk_size_sc.SetRange(1, 100) chunk_size_sc.SetValue(self.solver.chunksize) chunk_size_sc.Enable(diffev.__parallel_loaded__) self.processes_sc = processes_sc self.chunk_size_sc = chunk_size_sc parallel_sizer = wx.BoxSizer(wx.HORIZONTAL) p_text = wx.StaticText(self, -1, '# Processes') parallel_sizer.Add(p_text, 0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) parallel_sizer.Add((10, 20), 1, wx.EXPAND) parallel_sizer.Add(processes_sc, 0, \ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) parallel_box_sizer.Add(parallel_sizer, 1, wx.ALIGN_CENTRE | wx.EXPAND, 10) parallel_sizer = wx.BoxSizer(wx.HORIZONTAL) p_text = wx.StaticText(self, -1, ' Chunk size ') parallel_sizer.Add(p_text, 0, \ wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL, border = 10) parallel_sizer.Add((10, 20), 1, wx.EXPAND) parallel_sizer.Add(chunk_size_sc, 0, \ wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border = 10) parallel_box_sizer.Add(parallel_sizer, 1, wx.EXPAND, 10) row_sizer2.Add(parallel_box_sizer, 1, wx.EXPAND, 5) col_sizer.Add(row_sizer2, 1, wx.ALIGN_CENTRE | wx.ALL, 5) ## # Add the Dialog buttons button_sizer = wx.StdDialogButtonSizer() okay_button = wx.Button(self, wx.ID_OK) okay_button.SetDefault() button_sizer.AddButton(okay_button) apply_button = wx.Button(self, wx.ID_APPLY) apply_button.SetDefault() button_sizer.AddButton(apply_button) button_sizer.AddButton(wx.Button(self, wx.ID_CANCEL)) button_sizer.Realize() # Add some eventhandlers self.Bind(wx.EVT_BUTTON, self.on_apply_change, okay_button) self.Bind(wx.EVT_BUTTON, self.on_apply_change, apply_button) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(col_sizer, 1, wx.GROW | wx.ALIGN_CENTER_HORIZONTAL, 20) #sizer.Add(col_sizer, 1, wx.GROW|wx.ALL|wx.EXPAND, 20) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 20) sizer.Add(button_sizer,0,\ flag = wx.ALIGN_RIGHT, border = 20) self.SetSizer(sizer) sizer.Fit(self) self.Layout()
def __init__( self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, ): # Instead of calling wx.Dialog.__init__ we precreate the dialog # so we can set an extra style that must be set before # creation, and then we create the GUI object using the Create # method. pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) # This next step is the most important, it turns this Python # object into the real wrapper of the dialog (instead of pre) # as far as the wxPython extension is concerned. self.PostCreate(pre) # This extra style can be set after the UI object has been created. if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) # Now continue with the normal construction of the dialog # contents sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, "This is a wx.Dialog") label.SetHelpText("This is the help text for the label") sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Field #1:") label.SetHelpText("This is the help text for the label") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) text = wx.TextCtrl(self, -1, "", size=(80, -1)) text.SetHelpText("Here's some help text for field #1") box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Field #2:") label.SetHelpText("This is the help text for the label") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) text = wx.TextCtrl(self, -1, "", size=(80, -1)) text.SetHelpText("Here's some help text for field #2") box.Add(text, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() if wx.Platform != "__WXMSW__": btn = wx.ContextHelpButton(self) btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_OK) btn.SetHelpText("The OK button completes the dialog") btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_CANCEL) btn.SetHelpText("The Cancel button cnacels the dialog. (Cool, huh?)") btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
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 = wx.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(item=self.translist, proportion=1, flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND) # # buttons # btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(parent=panel, id=wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(parent=panel, id=wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(item=bodySizer, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) sizer.Add(item=btnsizer, proportion=0, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) sizer.Fit(panel) self.SetSize(self.GetBestSize()) self.Layout()
def __init__(self, parent, col_values, misc_values): wx.Dialog.__init__(self, parent, -1, 'Data loader settings') box_sizer = wx.BoxSizer(wx.HORIZONTAL) # Make the box for putting in the columns col_box = wx.StaticBox(self, -1, "Columns") col_box_sizer = wx.StaticBoxSizer(col_box, wx.VERTICAL) # col_values = {'y': 1,'x': 0,'y error': 1} col_grid = wx.GridBagSizer(len(col_values), 2) self.col_controls = col_values.copy() keys = list(col_values.keys()) keys.sort() for i, name in enumerate(keys): text = wx.StaticText(self, -1, name + ': ') control = wx.SpinCtrl(self) control.SetRange(0, 100) control.SetValue(col_values[name]) col_grid.Add(text, (i, 0), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=5) col_grid.Add(control, (i, 1), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=5) self.col_controls[name] = control col_box_sizer.Add(col_grid, 0, wx.ALIGN_CENTRE | wx.ALL, 5) box_sizer.Add(col_box_sizer, 0, wx.ALL | wx.EXPAND, 5) col_box = wx.StaticBox(self, -1, "Misc") col_box_sizer = wx.StaticBoxSizer(col_box, wx.VERTICAL) # Lets add another box for comments and rows to skip # misc_values = {'Comment': '#', 'Skip rows': 0,'Delimiter': 'None'} col_grid = wx.GridBagSizer(len(misc_values), 2) self.misc_controls = misc_values.copy() keys = list(misc_values.keys()) keys.sort() for i, name in enumerate(keys): text = wx.StaticText(self, -1, name + ': ') if type(misc_values[name]) == type(1): control = wx.SpinCtrl(self) control.SetRange(0, 100) control.SetValue(misc_values[name]) else: control = wx.TextCtrl(self, value=misc_values[name], style=wx.EXPAND) col_grid.Add(text, (i, 0), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=5) col_grid.Add(control, (i, 1), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=5) self.misc_controls[name] = control col_box_sizer.Add(col_grid, 0, wx.ALIGN_CENTRE | wx.ALL, 5) box_sizer.Add(col_box_sizer, 0, wx.ALL | wx.EXPAND, 5) button_sizer = wx.StdDialogButtonSizer() okay_button = wx.Button(self, wx.ID_OK) okay_button.SetDefault() button_sizer.AddButton(okay_button) button_sizer.AddButton(wx.Button(self, wx.ID_CANCEL)) button_sizer.Realize() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(box_sizer, 1, wx.GROW, 20) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW, 30) sizer.Add(button_sizer, 0, flag=wx.ALIGN_RIGHT, border=20) self.SetSizer(sizer) sizer.Fit(self) self.Layout()
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(1086, 756), style=wx.TAB_TRAVERSAL) bSizer1 = wx.BoxSizer(wx.VERTICAL) self.m_splitter2 = wx.SplitterWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SP_3D | wx.SP_LIVE_UPDATE) self.m_splitter2.Bind(wx.EVT_IDLE, self.m_splitter2OnIdle) self.m_splitter2.SetMinimumPaneSize(300) self.panel_manufacturers = wx.Panel(self.m_splitter2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer2 = wx.BoxSizer(wx.VERTICAL) bSizer4 = wx.BoxSizer(wx.HORIZONTAL) bSizer5 = wx.BoxSizer(wx.HORIZONTAL) self.button_add_manufacturer = wx.BitmapButton( self.panel_manufacturers, wx.ID_ANY, wx.Bitmap(u"resources/add.png", wx.BITMAP_TYPE_ANY), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW) bSizer5.Add(self.button_add_manufacturer, 0, wx.ALL, 5) self.button_edit_manufacturer = wx.BitmapButton( self.panel_manufacturers, wx.ID_ANY, wx.Bitmap(u"resources/edit.png", wx.BITMAP_TYPE_ANY), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW) bSizer5.Add(self.button_edit_manufacturer, 0, wx.ALL, 5) self.button_remove_manufacturer = wx.BitmapButton( self.panel_manufacturers, wx.ID_ANY, wx.Bitmap(u"resources/remove.png", wx.BITMAP_TYPE_ANY), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW) bSizer5.Add(self.button_remove_manufacturer, 0, wx.ALL, 5) bSizer4.Add(bSizer5, 1, wx.EXPAND, 5) bSizer6 = wx.BoxSizer(wx.HORIZONTAL) self.button_refresh_manufacturers = wx.BitmapButton( self.panel_manufacturers, wx.ID_ANY, wx.Bitmap(u"resources/refresh.png", wx.BITMAP_TYPE_ANY), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW) bSizer6.Add(self.button_refresh_manufacturers, 0, wx.ALL, 5) bSizer4.Add(bSizer6, 0, 0, 5) bSizer2.Add(bSizer4, 0, wx.EXPAND, 5) self.tree_manufacturers = wx.dataview.DataViewCtrl( self.panel_manufacturers, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) bSizer2.Add(self.tree_manufacturers, 1, wx.ALL | wx.EXPAND, 5) self.panel_manufacturers.SetSizer(bSizer2) self.panel_manufacturers.Layout() bSizer2.Fit(self.panel_manufacturers) self.panel_edit_manufacturer = wx.Panel(self.m_splitter2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer3 = wx.BoxSizer(wx.VERTICAL) fgSizer1 = wx.FlexGridSizer(0, 2, 0, 0) fgSizer1.AddGrowableCol(1) fgSizer1.SetFlexibleDirection(wx.BOTH) fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.m_staticText3 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Manufacturer", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText3.Wrap(-1) fgSizer1.Add(self.m_staticText3, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.edit_manufacturer_name = wx.TextCtrl(self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer1.Add(self.edit_manufacturer_name, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 5) self.m_staticText4 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Address", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText4.Wrap(-1) fgSizer1.Add(self.m_staticText4, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.edit_manufacturer_address = wx.TextCtrl( self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE) fgSizer1.Add(self.edit_manufacturer_address, 0, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 5) self.m_staticText6 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Website", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText6.Wrap(-1) fgSizer1.Add(self.m_staticText6, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.edit_manufacturer_website = wx.TextCtrl( self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer1.Add(self.edit_manufacturer_website, 1, wx.ALL | wx.EXPAND, 5) self.m_staticText8 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Email", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText8.Wrap(-1) fgSizer1.Add(self.m_staticText8, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.edit_manufacturer_email = wx.TextCtrl( self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer1.Add(self.edit_manufacturer_email, 1, wx.ALL | wx.EXPAND, 5) self.m_staticText9 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Phone", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText9.Wrap(-1) fgSizer1.Add(self.m_staticText9, 0, wx.ALL, 5) self.edit_manufacturer_phone = wx.TextCtrl( self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0) fgSizer1.Add(self.edit_manufacturer_phone, 1, wx.ALL | wx.EXPAND, 5) self.m_staticText11 = wx.StaticText(self.panel_edit_manufacturer, wx.ID_ANY, u"Comment", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText11.Wrap(-1) fgSizer1.Add(self.m_staticText11, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.edit_manufacturer_comment = wx.TextCtrl( self.panel_edit_manufacturer, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE) fgSizer1.Add(self.edit_manufacturer_comment, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5) bSizer3.Add(fgSizer1, 1, wx.EXPAND, 5) m_sdbSizer1 = wx.StdDialogButtonSizer() self.m_sdbSizer1Apply = wx.Button(self.panel_edit_manufacturer, wx.ID_APPLY) m_sdbSizer1.AddButton(self.m_sdbSizer1Apply) self.m_sdbSizer1Cancel = wx.Button(self.panel_edit_manufacturer, wx.ID_CANCEL) m_sdbSizer1.AddButton(self.m_sdbSizer1Cancel) m_sdbSizer1.Realize() bSizer3.Add(m_sdbSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND, 5) self.panel_edit_manufacturer.SetSizer(bSizer3) self.panel_edit_manufacturer.Layout() bSizer3.Fit(self.panel_edit_manufacturer) self.m_splitter2.SplitVertically(self.panel_manufacturers, self.panel_edit_manufacturer, 294) bSizer1.Add(self.m_splitter2, 1, wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() # Connect Events self.Bind(wx.EVT_INIT_DIALOG, self.onInitDialog) self.button_add_manufacturer.Bind(wx.EVT_BUTTON, self.onButtonAddManufacturerClick) self.button_edit_manufacturer.Bind(wx.EVT_BUTTON, self.onButtonEditManufacturerClick) self.button_remove_manufacturer.Bind( wx.EVT_BUTTON, self.onButtonRemoveManufacturerClick) self.button_refresh_manufacturers.Bind( wx.EVT_BUTTON, self.onButtonRefreshManufacturersClick) self.m_sdbSizer1Apply.Bind(wx.EVT_BUTTON, self.onApplyButtonClick) self.m_sdbSizer1Cancel.Bind(wx.EVT_BUTTON, self.onCancelButtonClick)
def handle_interaction(self, pixel_data): '''Run a UI that gets an angle from the user''' import wx if pixel_data.ndim == 2: # make a color matrix for consistency pixel_data = np.dstack((pixel_data,pixel_data,pixel_data)) pd_min = np.min(pixel_data) pd_max = np.max(pixel_data) if pd_min == pd_max: pixel_data[:,:,:] = 0 else: pixel_data = ((pixel_data - pd_min) * 255.0 / (pd_max - pd_min)) # # Make a 100 x 100 image so it's manageable # isize = 200 i,j,k = np.mgrid[0:isize, 0:int(isize*pixel_data.shape[1] / pixel_data.shape[0]), 0:3].astype(float) i *= float(pixel_data.shape[0])/float(isize) j *= float(pixel_data.shape[0])/float(isize) pixel_data = scind.map_coordinates(pixel_data,(i,j,k)) # # Make a dialog box that contains the image # dialog = wx.Dialog(None, title = "Rotate image") sizer = wx.BoxSizer(wx.VERTICAL) dialog.SetSizer(sizer) sizer.Add(wx.StaticText(dialog,label = "Drag image to rotate, hit OK to continue"), 0,wx.ALIGN_CENTER_HORIZONTAL) canvas = wx.StaticBitmap(dialog) canvas.SetDoubleBuffered(True) canvas.BackgroundColour = wx.Colour(0,0,0,wx.ALPHA_TRANSPARENT) sizer.Add(canvas, 0, wx.ALIGN_CENTER_HORIZONTAL| wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) angle = [ 0 ] angle_text = wx.StaticText(dialog, label = "Angle: %d"%angle[0]) sizer.Add(angle_text, 0, wx.ALIGN_CENTER_HORIZONTAL) def imshow(): angle_text.Label = "Angle: %d"%int(angle[0]) angle_text.Refresh() my_angle = -angle[0] * np.pi / 180.0 transform = np.array([[np.cos(my_angle),-np.sin(my_angle)], [np.sin(my_angle),np.cos(my_angle)]]) # Make it rotate about the center offset = affine_offset(pixel_data.shape, transform) x = np.dstack((scind.affine_transform(pixel_data[:,:,0], transform, offset, order=0), scind.affine_transform(pixel_data[:,:,1], transform, offset, order=0), scind.affine_transform(pixel_data[:,:,2], transform, offset, order=0))) buff = x.astype(np.uint8).tostring() bitmap = wx.BitmapFromBuffer(x.shape[1], x.shape[0], buff) canvas.SetBitmap(bitmap) imshow() # # Install handlers for mouse down, mouse move and mouse up # dragging = [False] initial_angle = [0] hand_cursor = wx.StockCursor(wx.CURSOR_HAND) arrow_cursor = wx.StockCursor(wx.CURSOR_ARROW) def get_angle(event): center = np.array(canvas.Size) / 2 point = np.array(event.GetPositionTuple()) offset = point - center return -np.arctan2(offset[1],offset[0]) * 180.0 / np.pi def on_mouse_down(event): canvas.Cursor = hand_cursor dragging[0] = True initial_angle[0] = get_angle(event) - angle[0] canvas.CaptureMouse() wx.EVT_LEFT_DOWN(canvas, on_mouse_down) def on_mouse_up(event): if dragging[0]: canvas.ReleaseMouse() dragging[0] = False canvas.Cursor = arrow_cursor wx.EVT_LEFT_UP(canvas, on_mouse_up) def on_mouse_lost(event): dragging[0] = False canvas.Cursor = arrow_cursor wx.EVT_MOUSE_CAPTURE_LOST(canvas, on_mouse_lost) def on_mouse_move(event): if dragging[0]: angle[0] = get_angle(event) - initial_angle[0] imshow() canvas.Refresh(eraseBackground=False) wx.EVT_MOTION(canvas, on_mouse_move) # # Put the OK and Cancel buttons on the bottom # btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(dialog, wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(dialog, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) dialog.Fit() result = dialog.ShowModal() dialog.Destroy() if result == wx.ID_OK: return angle[0] raise ValueError("Canceled by user in FlipAndRotate")
def __init__( self, parent, map, query=None, cats=None, line=None, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, pos=wx.DefaultPosition, action="add", ignoreError=False, ): """Standard dialog used to add/update/display attributes linked to the vector map. Attribute data can be selected based on layer and category number or coordinates. :param parent: :param map: vector map :param query: query coordinates and distance (used for v.edit) :param cats: {layer: cats} :param line: feature id (requested for cats) :param style: :param pos: :param action: (add, update, display) :param ignoreError: True to ignore errors """ self.parent = parent # mapdisplay.BufferedWindow self.map = map self.action = action # ids/cats of selected features # fid : {layer : cats} self.cats = {} self.fid = -1 # feature id # get layer/table/column information self.mapDBInfo = VectorDBInfo(self.map) layers = self.mapDBInfo.layers.keys() # get available layers # check if db connection / layer exists if len(layers) <= 0: if not ignoreError: dlg = wx.MessageDialog( parent=self.parent, message=_("No attribute table found.\n\n" "Do you want to create a new attribute table " "and defined a link to vector map <%s>?") % self.map, caption=_("Create table?"), style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, ) if dlg.ShowModal() == wx.ID_YES: lmgr = self.parent.lmgr lmgr.OnShowAttributeTable(event=None, selection="layers") dlg.Destroy() self.mapDBInfo = None wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY, title="", style=style, pos=pos) # dialog body mainSizer = wx.BoxSizer(wx.VERTICAL) # notebook self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) self.closeDialog = wx.CheckBox(parent=self, id=wx.ID_ANY, label=_("Close dialog on submit")) self.closeDialog.SetValue(True) if self.action == "display": self.closeDialog.Enable(False) # feature id (text/choice for duplicates) self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY, size=(150, -1)) self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature) self.fidText = StaticText(parent=self, id=wx.ID_ANY) self.noFoundMsg = StaticText(parent=self, id=wx.ID_ANY, label=_("No attributes found")) self.UpdateDialog(query=query, cats=cats) # set title if self.action == "update": self.SetTitle(_("Update attributes")) elif self.action == "add": self.SetTitle(_("Define attributes")) else: self.SetTitle(_("Display attributes")) # buttons btnCancel = Button(self, wx.ID_CANCEL) btnReset = Button(self, wx.ID_UNDO, _("&Reload")) btnSubmit = Button(self, wx.ID_OK, _("&Submit")) if self.action == "display": btnSubmit.Enable(False) btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) btnSizer.AddButton(btnReset) btnSizer.SetNegativeButton(btnReset) btnSubmit.SetDefault() btnSizer.AddButton(btnSubmit) btnSizer.Realize() mainSizer.Add(self.noFoundMsg, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(self.notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) fidSizer = wx.BoxSizer(wx.HORIZONTAL) fidSizer.Add( StaticText(parent=self, id=wx.ID_ANY, label=_("Feature id:")), proportion=0, border=5, flag=wx.ALIGN_CENTER_VERTICAL, ) fidSizer.Add(self.fidMulti, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) fidSizer.Add(self.fidText, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(fidSizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) mainSizer.Add( self.closeDialog, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5, ) mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) # bindigs btnReset.Bind(wx.EVT_BUTTON, self.OnReset) btnSubmit.Bind(wx.EVT_BUTTON, self.OnSubmit) btnCancel.Bind(wx.EVT_BUTTON, self.OnClose) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetSizer(mainSizer) mainSizer.Fit(self) # set min size for dialog w, h = self.GetBestSize() w += 50 if h < 200: self.SetMinSize((w, 200)) else: self.SetMinSize((w, h)) if self.notebook.GetPageCount() == 0: Debug.msg(2, "DisplayAttributesDialog(): Nothing found!")
def __init__(self, parent, settings): self.settings = settings self.index = 0 wx.Dialog.__init__(self, parent=parent, title="Preferences") self.colours = get_colours() self.winFunc = settings.winFunc self.background = settings.background self.checkSaved = wx.CheckBox(self, wx.ID_ANY, "Save warning") self.checkSaved.SetValue(settings.saveWarn) self.checkBackup = wx.CheckBox(self, wx.ID_ANY, "Backup") self.checkBackup.SetValue(settings.backup) self.checkBackup.SetToolTip('Backup data after crash') self.checkAlert = wx.CheckBox(self, wx.ID_ANY, "Level alert (dB)") self.checkAlert.SetValue(settings.alert) self.checkAlert.SetToolTip('Play alert when level exceeded') self.Bind(wx.EVT_CHECKBOX, self.__on_alert, self.checkAlert) self.spinLevel = wx.SpinCtrl(self, wx.ID_ANY, min=-100, max=20) self.spinLevel.SetValue(settings.alertLevel) self.spinLevel.Enable(settings.alert) self.spinLevel.SetToolTip('Alert threshold') textBackground = wx.StaticText(self, label='Background colour') self.buttonBackground = wx.Button(self, wx.ID_ANY) self.buttonBackground.SetBackgroundColour(self.background) self.Bind(wx.EVT_BUTTON, self.__on_background, self.buttonBackground) textColour = wx.StaticText(self, label="Colour map") self.choiceColour = wx.Choice(self, choices=self.colours) self.choiceColour.SetSelection(self.colours.index(settings.colourMap)) self.Bind(wx.EVT_CHOICE, self.__on_choice, self.choiceColour) self.colourBar = PanelColourBar(self, settings.colourMap) self.checkPoints = wx.CheckBox(self, wx.ID_ANY, "Limit points") self.checkPoints.SetValue(settings.pointsLimit) self.checkPoints.SetToolTip('Limit the resolution of plots') self.Bind(wx.EVT_CHECKBOX, self.__on_points, self.checkPoints) self.spinPoints = wx.SpinCtrl(self, wx.ID_ANY, min=1000, max=100000) self.spinPoints.Enable(settings.pointsLimit) self.spinPoints.SetValue(settings.pointsMax) self.spinPoints.SetToolTip('Maximum number of points to plot_line') textDpi = wx.StaticText(self, label='Export DPI') self.spinDpi = wx.SpinCtrl(self, wx.ID_ANY, min=72, max=6000) self.spinDpi.SetValue(settings.exportDpi) self.spinDpi.SetToolTip('DPI of exported images') self.checkTune = wx.CheckBox(self, wx.ID_ANY, "Tune SDR#") self.checkTune.SetValue(settings.clickTune) self.checkTune.SetToolTip('Double click plot_line to tune SDR#') textPlugin = HyperlinkCtrl(self, wx.ID_ANY, label="(Requires plugin)", url="http://eartoearoak.com/software/sdrsharp-net-remote") self.radioAvg = wx.RadioButton(self, wx.ID_ANY, 'Average Scans', style=wx.RB_GROUP) self.radioAvg.SetToolTip('Average level with each scan') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioAvg) self.radioRetain = wx.RadioButton(self, wx.ID_ANY, 'Retain previous scans') self.radioRetain.SetToolTip('Can be slow') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioRetain) self.radioRetain.SetValue(settings.retainScans) textMaxScans = wx.StaticText(self, label="Max scans") self.spinCtrlMaxScans = wx.SpinCtrl(self) self.spinCtrlMaxScans.SetRange(1, 5000) self.spinCtrlMaxScans.SetValue(settings.retainMax) self.spinCtrlMaxScans.SetToolTip('Maximum previous scans' ' to display') textWidth = wx.StaticText(self, label="Line width") self.ctrlWidth = NumCtrl(self, integerWidth=2, fractionWidth=1) self.ctrlWidth.SetValue(settings.lineWidth) self.__on_radio(None) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) gengrid = wx.GridBagSizer(10, 10) gengrid.Add(self.checkSaved, pos=(0, 0)) gengrid.Add(self.checkBackup, pos=(1, 0)) gengrid.Add(self.checkAlert, pos=(2, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.spinLevel, pos=(2, 1)) gengrid.Add(textBackground, pos=(3, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.buttonBackground, pos=(3, 1)) gengrid.Add(textColour, pos=(4, 0)) gengrid.Add(self.choiceColour, pos=(4, 1)) gengrid.Add(self.colourBar, pos=(4, 2)) gengrid.Add(self.checkPoints, pos=(5, 0)) gengrid.Add(self.spinPoints, pos=(5, 1)) gengrid.Add(textDpi, pos=(6, 0)) gengrid.Add(self.spinDpi, pos=(6, 1)) gengrid.Add(self.checkTune, pos=(7, 0)) gengrid.Add(textPlugin, pos=(7, 1)) genbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "General")) genbox.Add(gengrid, 0, wx.ALL | wx.ALIGN_CENTRE_VERTICAL, 10) congrid = wx.GridBagSizer(10, 10) congrid.Add(self.radioAvg, pos=(0, 0)) congrid.Add(self.radioRetain, pos=(1, 0)) congrid.Add(textMaxScans, pos=(2, 0), flag=wx.ALIGN_CENTRE_VERTICAL) congrid.Add(self.spinCtrlMaxScans, pos=(2, 1)) conbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Continuous Scans"), wx.VERTICAL) conbox.Add(congrid, 0, wx.ALL | wx.EXPAND, 10) plotgrid = wx.GridBagSizer(10, 10) plotgrid.Add(textWidth, pos=(0, 0)) plotgrid.Add(self.ctrlWidth, pos=(0, 1)) plotbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Plot View"), wx.HORIZONTAL) plotbox.Add(plotgrid, 0, wx.ALL | wx.EXPAND, 10) grid = wx.GridBagSizer(10, 10) grid.Add(genbox, pos=(0, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(conbox, pos=(1, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(plotbox, pos=(2, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(sizerButtons, pos=(3, 1), flag=wx.EXPAND) box = wx.BoxSizer() box.Add(grid, flag=wx.ALL | wx.ALIGN_CENTRE, border=10) self.SetSizerAndFit(box)
def __init__(self, parent): wx.Dialog.__init__(self, parent) wx.EVT_CLOSE(self, self._on_frame_close) self.Bind(wx.EVT_CHAR_HOOK, self._on_escape) self.panel = wx.Panel(self, -1) _sz_main = wx.BoxSizer(wx.VERTICAL) _sz_fields = wx.FlexGridSizer(cols=2, hgap=5, vgap=5) _sz_fields.AddGrowableCol(1) _sz_fields.AddGrowableRow(5) self._search_notes = self._add_a_checkbox( _sz_fields, _("Search inside notes") + ":") self._search_passwd = self._add_a_checkbox( _sz_fields, _("Search inside passwords") + ":") self._sc_length = self._add_a_spincontrol( _sz_fields, _("Generated Password Length") + ":", 4, 128) _sz_main.Add(_sz_fields, 1, wx.EXPAND | wx.GROW) self._cb_reduction = self._add_a_checkbox( _sz_fields, _("Avoid easy to mistake chars") + ":") self._tc_alphabet = self._add_a_textcontrol(_sz_fields, _("Alphabet") + ":", config.alphabet) _ln_line = wx.StaticLine(self.panel, -1, size=(20, -1), style=wx.LI_HORIZONTAL) _sz_main.Add(_ln_line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(self.panel, wx.ID_CANCEL) wx.EVT_BUTTON(self, wx.ID_CANCEL, self._on_cancel) btnsizer.AddButton(btn) btn = wx.Button(self.panel, wx.ID_OK) wx.EVT_BUTTON(self, wx.ID_OK, self._on_ok) btn.SetDefault() btnsizer.AddButton(btn) btnsizer.Realize() _sz_main.Add(btnsizer, 0, wx.ALIGN_RIGHT | wx.TOP | wx.BOTTOM, 5) self.panel.SetSizer(_sz_main) _sz_frame = wx.BoxSizer() _sz_frame.Add(self.panel, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(_sz_frame) self.SetTitle("Loxodo - " + _("Settings")) self.Layout() self.Fit() self.SetMinSize(self.GetSize()) self.set_initial_focus() self.update_fields()
def __init__(self, data=None): wx.Dialog.__init__(self, None, -1, "Volume", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) style = wx.TR_HAS_BUTTONS # | wx.TR_HIDE_ROOT | wx.TR_MULTIPLE # wx.TR_NO_LINES | | wx.TR_FULL_ROW_HIGHLIGHT# |wx.TR_HAS_BUTTONS style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_FULL_ROW_HIGHLIGHT self.tree = tree = wx.TreeCtrl(self, -1, size=(250, 200), style=style) tree.SetMinSize((250, 200)) self.root = root = tree.AddRoot("Functions") #traverse(tree, root, gTreeData, "") #tree.Expand(root) self.Traverse() tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged) panel = wx.Panel(self, -1, size=(250, -1)) panel.SetMinSize((250, -1)) self.funcText = wx.TextCtrl(panel, -1, size=(200, -1), style=wx.TE_READONLY) self.funcText.SetMinSize((200, -1)) self.funcText.SetBackgroundColour(self.GetBackgroundColour()) self.docText = wx.TextCtrl(panel, -1, size=(200, 200), style=wx.TE_READONLY | wx.TE_MULTILINE) self.docText.SetBackgroundColour(self.GetBackgroundColour()) okButton = wx.Button(self, wx.ID_OK, lang.ok) okButton.SetDefault() #okButton.Bind(wx.EVT_BUTTON, self.OnOK) cancelButton = wx.Button(self, wx.ID_CANCEL, lang.cancel) #cancelButton.Bind(wx.EVT_BUTTON, self.OnCancel) stdbtnsizer = wx.StdDialogButtonSizer() stdbtnsizer.AddButton(okButton) stdbtnsizer.AddButton(cancelButton) stdbtnsizer.Realize() btnrowSizer = wx.BoxSizer(wx.HORIZONTAL) btnrowSizer.Add((5, 5), 1) btnrowSizer.Add(stdbtnsizer, 0, wx.TOP | wx.BOTTOM, 6) btnrowSizer.Add((2, 2), 0) panelSizer = wx.BoxSizer(wx.VERTICAL) panelSizer.Add(self.funcText, 0, wx.EXPAND) panelSizer.Add(self.docText, 1, wx.EXPAND) panel.SetSizer(panelSizer) panel.SetAutoLayout(True) panelSizer.Fit(panel) middleSizer = wx.BoxSizer(wx.HORIZONTAL) middleSizer.Add(tree, 0, wx.EXPAND) middleSizer.Add(panel, 1, wx.EXPAND) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(middleSizer, 1, wx.EXPAND) mainSizer.Add(btnrowSizer, 0, wx.EXPAND) self.SetSizer(mainSizer) self.SetAutoLayout(True) mainSizer.Fit(self) minSize = self.GetSize() self.SetMinSize(minSize) self.Show()
def __init__(self, parent, char_name): wx.Dialog.__init__(self, parent, -1, "Login to EVE-Central", style=wx.DEFAULT_DIALOG_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText( self, -1, "Please enter your username and password as registered\non EVE-central.com" ) sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.anon_cb = wx.CheckBox(self, -1, "Anonymous login - no username") self.Bind(wx.EVT_CHECKBOX, self.OnAnonCb, self.anon_cb) sizer.Add(self.anon_cb, 0, wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Username:"******"This is the help text for the label") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.uname = wx.TextCtrl(self, -1, "", size=(80, -1)) self.uname.SetHelpText("Here's some help text for field #1") box.Add(self.uname, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Password: "******"This is the help text for the label") box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.passwd = wx.TextCtrl(self, -1, "", size=(80, -1), style=wx.TE_PASSWORD) self.passwd.SetHelpText("Here's some help text for field #2") box.Add(self.passwd, 1, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() if wx.Platform != "__WXMSW__": btn = wx.ContextHelpButton(self) btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_OK) btn.SetHelpText("The OK button completes the dialog") btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_CANCEL) btn.SetHelpText("The Cancel button cancels the dialog. ") btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) if char_name == "Anonymous": self.anon_cb.SetValue(True) self.uname.Enable(False) self.passwd.Enable(False) else: self.uname.SetValue(char_name)