def __init__(self, buildSys, generatorName, workspaceNames): wx.Frame.__init__(self, None, -1, 'Nebula 2 Build System', style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN | wx.RESIZE_BORDER) # load & set the Nebula icon try: self.SetIcon( wx.Icon(os.path.join('bin', 'win32', 'nebula.ico'), wx.BITMAP_TYPE_ICO)) finally: pass self.buildSys = buildSys # create the main menu self.mainMenu = wx.MenuBar() # main menu -> File self.mainMenuFile = wx.Menu() self.mainMenuFile.Append(wx.ID_EXIT, 'E&xit\tAlt-X', 'Exit the application.') self.Bind(wx.EVT_MENU, self.OnMainMenuFileExit, id=wx.ID_EXIT) # main menu -> Help self.mainMenuHelp = wx.Menu() self.mainMenuHelp.Append(wx.ID_HELP, '&Manual', 'Display user manual.') self.Bind(wx.EVT_MENU, self.OnMainMenuHelpManual, id=wx.ID_HELP) self.mainMenuHelp.Append(wx.ID_ABOUT, '&About', 'Display about box.') self.Bind(wx.EVT_MENU, self.OnMainMenuHelpAbout, id=wx.ID_ABOUT) # attach the menus self.mainMenu.Append(self.mainMenuFile, '&File') self.mainMenu.Append(self.mainMenuHelp, '&Help') self.SetMenuBar(self.mainMenu) # create the status bar self.CreateStatusBar() # A Panel for all the controls self.mainPanel = wx.Panel(self) # Line to separate the main menu from the controls self.staticLine = wx.StaticLine(self.mainPanel, -1, style=wx.HORIZONTAL) # The tab group self.tabGroup = wx.Notebook(self.mainPanel, -1) self.workspacesTab = WorkspacesPanel(self.tabGroup, self.buildSys, generatorName, workspaceNames) self.classBuilderTab = ClassBuilderPanel(self.tabGroup, self.buildSys) self.cmdEditorTab = CmdEditorPanel(self.tabGroup, self.buildSys) self.tabGroup.AddPage(self.workspacesTab, 'Workspace Generation') self.tabGroup.AddPage(self.classBuilderTab, 'Class Builder') self.tabGroup.AddPage(self.cmdEditorTab, 'Cmd Editor') # Log window self.buildLogPanel = BuildLogPanel(self.mainPanel, self.buildSys) self.closeBtn = wx.Button(self.mainPanel, -1, 'Close') self.Bind(wx.EVT_BUTTON, self.OnCloseBtn, self.closeBtn) self.Bind(wx.EVT_CLOSE, self.OnClose) # More Events self.Bind(EVT_CREATE_EXTERN_TASK_DLG_PROXY, self.OnCreateExternalTaskDialogProxy) # Layout the controls... # top level sizer sizerA = wx.BoxSizer(wx.VERTICAL) sizerA.Add(self.staticLine, 0, wx.EXPAND) sizerA.Add(self.tabGroup, 1, wx.EXPAND) sizerA.Add(self.buildLogPanel, 0, wx.EXPAND | wx.ALL, 4) sizerA.Add(self.closeBtn, 0, wx.CENTER | wx.ALL, 5) # get the sizers to sort out the frame's size sizerA.Fit(self.mainPanel) self.mainPanel.SetSizer(sizerA) self.mainPanel.Layout() self.Fit() # Load the workspace list in a separate thread thread.start_new_thread(self.LoadWorkspaceList, ())
def __init__(self, *args, **kwds): # begin wxGlade: All_Widgets_Frame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menu Bar self.All_Widgets_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_OPEN, _("&Open"), _("Open an existing document")) wxglade_tmp_menu.Append(wx.ID_CLOSE, _("&Close file"), _("Close current document")) wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(wx.ID_EXIT, _("E&xit"), _("Finish program")) self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&File")) wxglade_tmp_menu = wx.Menu() self.All_Widgets_menubar.mn_Unix = wxglade_tmp_menu.Append( wx.ID_ANY, _("Unix"), _("Use Unix line endings"), wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onSelectUnix, id=self.All_Widgets_menubar.mn_Unix.GetId()) self.All_Widgets_menubar.mn_Windows = wxglade_tmp_menu.Append( wx.ID_ANY, _("Windows"), _("Use Windows line endings"), wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onSelectWindows, id=self.All_Widgets_menubar.mn_Windows.GetId()) wxglade_tmp_menu.AppendSeparator() self.All_Widgets_menubar.mn_RemoveTabs = wxglade_tmp_menu.Append( wx.ID_ANY, _("Remove Tabs"), _("Remove all leading tabs"), wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.onRemoveTabs, id=self.All_Widgets_menubar.mn_RemoveTabs.GetId()) self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Edit")) wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.ID_HELP, _("Manual"), _("Show the application manual")) self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP) wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(wx.ID_ABOUT, _("About"), _("Show the About dialog")) self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Help")) self.SetMenuBar(self.All_Widgets_menubar) # Menu Bar end self.All_Widgets_statusbar = self.CreateStatusBar( 1, wx.STB_ELLIPSIZE_MIDDLE | wx.STB_SHOW_TIPS | wx.STB_SIZEGRIP) # Tool Bar self.All_Widgets_toolbar = wx.ToolBar(self, -1) self.SetToolBar(self.All_Widgets_toolbar) self.All_Widgets_toolbar.AddLabelTool( wx.ID_UP, _("UpDown"), wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)), wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_OTHER, (32, 32)), wx.ITEM_CHECK, _("Up or Down"), _("Up or Down")) self.All_Widgets_toolbar.AddLabelTool(wx.ID_OPEN, _("Open"), wx.EmptyBitmap(32, 32), wx.NullBitmap, wx.ITEM_NORMAL, _("Open a new file"), _("Open a new file")) # Tool Bar end self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=wx.NB_BOTTOM) self.notebook_1_wxBitmapButton = wx.Panel(self.notebook_1, wx.ID_ANY) self.bitmap_button_icon1 = wx.BitmapButton( self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY)) self.bitmap_button_empty1 = wx.BitmapButton( self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.EmptyBitmap(10, 10)) self.bitmap_button_icon2 = wx.BitmapButton( self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY), style=wx.BORDER_NONE | wx.BU_BOTTOM) self.bitmap_button_art = wx.BitmapButton( self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)), style=wx.BORDER_NONE | wx.BU_BOTTOM) self.notebook_1_wxButton = wx.Panel(self.notebook_1, wx.ID_ANY) self.button_3 = wx.Button(self.notebook_1_wxButton, wx.ID_BOLD, "") self.notebook_1_wxCalendarCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.calendar_ctrl_1 = wx.calendar.CalendarCtrl( self.notebook_1_wxCalendarCtrl, wx.ID_ANY, style=wx.calendar.CAL_MONDAY_FIRST | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION | wx.calendar.CAL_SHOW_SURROUNDING_WEEKS | wx.calendar.CAL_SHOW_WEEK_NUMBERS) self.notebook_1_wxGenericCalendarCtrl = wx.Panel( self.notebook_1, wx.ID_ANY) self.generic_calendar_ctrl_1 = wx.calendar.GenericCalendarCtrl( self.notebook_1_wxGenericCalendarCtrl, wx.ID_ANY, style=wx.calendar.CAL_MONDAY_FIRST | wx.calendar.CAL_SHOW_HOLIDAYS) self.notebook_1_wxCheckBox = wx.Panel(self.notebook_1, wx.ID_ANY) self.checkbox_1 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("one (unchecked)")) self.checkbox_2 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("two (checked)")) self.checkbox_3 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("three"), style=wx.CHK_2STATE) self.checkbox_4 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("four (unchecked)"), style=wx.CHK_3STATE) self.checkbox_5 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("five (checked)"), style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER) self.checkbox_6 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY, _("six (undetermined)"), style=wx.CHK_3STATE | wx.CHK_ALLOW_3RD_STATE_FOR_USER) self.notebook_1_wxCheckListBox = wx.Panel(self.notebook_1, wx.ID_ANY) self.check_list_box_1 = wx.CheckListBox( self.notebook_1_wxCheckListBox, wx.ID_ANY, choices=[_("one"), _("two"), _("three"), _("four")]) self.notebook_1_wxChoice = wx.Panel(self.notebook_1, wx.ID_ANY) self.choice_empty = wx.Choice(self.notebook_1_wxChoice, wx.ID_ANY, choices=[]) self.choice_filled = wx.Choice( self.notebook_1_wxChoice, wx.ID_ANY, choices=[_("Item 1"), _("Item 2 (pre-selected)")]) self.notebook_1_wxComboBox = wx.Panel(self.notebook_1, wx.ID_ANY) self.combo_box_empty = wx.ComboBox(self.notebook_1_wxComboBox, wx.ID_ANY, choices=[], style=0) self.combo_box_filled = wx.ComboBox( self.notebook_1_wxComboBox, wx.ID_ANY, choices=[_("Item 1 (pre-selected)"), _("Item 2")], style=wx.CB_DROPDOWN) self.notebook_1_wxDatePickerCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.datepicker_ctrl_1 = wx.DatePickerCtrl( self.notebook_1_wxDatePickerCtrl, wx.ID_ANY, style=wx.DP_SHOWCENTURY) self.notebook_1_wxGauge = wx.Panel(self.notebook_1, wx.ID_ANY) self.gauge_1 = wx.Gauge(self.notebook_1_wxGauge, wx.ID_ANY, 20) self.notebook_1_wxGrid = wx.Panel(self.notebook_1, wx.ID_ANY) self.grid_1 = wx.grid.Grid(self.notebook_1_wxGrid, wx.ID_ANY, size=(1, 1)) self.notebook_1_wxHyperlinkCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.hyperlink_1 = wx.HyperlinkCtrl(self.notebook_1_wxHyperlinkCtrl, wx.ID_ANY, _("Homepage wxGlade"), _("http://wxglade.sf.net")) self.notebook_1_wxListBox = wx.Panel(self.notebook_1, wx.ID_ANY) self.list_box_empty = wx.ListBox(self.notebook_1_wxListBox, wx.ID_ANY, choices=[]) self.list_box_filled = wx.ListBox( self.notebook_1_wxListBox, wx.ID_ANY, choices=[_("Item 1"), _("Item 2 (pre-selected)")], style=wx.LB_MULTIPLE | wx.LB_SORT) self.notebook_1_wxListCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.list_ctrl_1 = wx.ListCtrl(self.notebook_1_wxListCtrl, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_REPORT) self.notebook_1_wxPropertyGridManager = wx.Panel( self.notebook_1, wx.ID_ANY) self.property_grid_2 = wx.propgrid.PropertyGridManager( self.notebook_1_wxPropertyGridManager, wx.ID_ANY, style=wx.propgrid.PG_ALPHABETIC_MODE) self.notebook_1_wxRadioBox = wx.Panel(self.notebook_1, wx.ID_ANY) self.radio_box_empty1 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_empty1"), choices=[""], majorDimension=1, style=wx.RA_SPECIFY_ROWS) self.radio_box_filled1 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_filled1"), choices=[ _("choice 1"), _("choice 2 (pre-selected)"), _("choice 3") ], majorDimension=0, style=wx.RA_SPECIFY_ROWS) self.radio_box_empty2 = wx.RadioBox(self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_empty2"), choices=[""], majorDimension=1, style=wx.RA_SPECIFY_COLS) self.radio_box_filled2 = wx.RadioBox( self.notebook_1_wxRadioBox, wx.ID_ANY, _("radio_box_filled2"), choices=[_("choice 1"), _("choice 2 (pre-selected)")], majorDimension=0, style=wx.RA_SPECIFY_COLS) self.notebook_1_wxRadioButton = wx.Panel(self.notebook_1, wx.ID_ANY) self.radio_btn_1 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Alice"), style=wx.RB_GROUP) self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "") self.radio_btn_2 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Bob")) self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "") self.radio_btn_3 = wx.RadioButton(self.notebook_1_wxRadioButton, wx.ID_ANY, _("Malroy")) self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_wxRadioButton, wx.ID_ANY, "") self.notebook_1_wxSlider = wx.Panel(self.notebook_1, wx.ID_ANY) self.slider_1 = wx.Slider(self.notebook_1_wxSlider, wx.ID_ANY, 5, 0, 10) self.notebook_1_wxSpinButton = wx.Panel(self.notebook_1, wx.ID_ANY) self.spin_button_vertical = wx.SpinButton(self.notebook_1_wxSpinButton, wx.ID_ANY) self.spin_button_horizontal = wx.SpinButton( self.notebook_1_wxSpinButton, wx.ID_ANY, style=wx.SP_HORIZONTAL) self.notebook_1_wxSpinCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.spin_ctrl_1 = wx.SpinCtrl(self.notebook_1_wxSpinCtrl, wx.ID_ANY, "4", min=0, max=100, style=wx.SP_ARROW_KEYS | wx.TE_RIGHT) self.notebook_1_wxSplitterWindow_horizontal = wx.ScrolledWindow( self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL) self.splitter_1 = wx.SplitterWindow( self.notebook_1_wxSplitterWindow_horizontal, wx.ID_ANY) self.splitter_1_pane_1 = wx.Panel(self.splitter_1, wx.ID_ANY) self.label_top_pane = wx.StaticText(self.splitter_1_pane_1, wx.ID_ANY, _("top pane")) self.splitter_1_pane_2 = wx.Panel(self.splitter_1, wx.ID_ANY) self.label_buttom_pane = wx.StaticText(self.splitter_1_pane_2, wx.ID_ANY, _("bottom pane")) self.notebook_1_wxSplitterWindow_vertical = wx.ScrolledWindow( self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL) self.splitter_2 = wx.SplitterWindow( self.notebook_1_wxSplitterWindow_vertical, wx.ID_ANY) self.splitter_2_pane_1 = wx.Panel(self.splitter_2, wx.ID_ANY) self.label_left_pane = wx.StaticText(self.splitter_2_pane_1, wx.ID_ANY, _("left pane")) self.splitter_2_pane_2 = wx.Panel(self.splitter_2, wx.ID_ANY) self.label_right_pane = wx.StaticText(self.splitter_2_pane_2, wx.ID_ANY, _("right pane")) self.notebook_1_wxStaticBitmap = wx.Panel(self.notebook_1, wx.ID_ANY) self.bitmap_empty = wx.StaticBitmap(self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.EmptyBitmap(32, 32)) self.bitmap_file = wx.StaticBitmap( self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY)) self.bitmap_art = wx.StaticBitmap( self.notebook_1_wxStaticBitmap, wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, (32, 32))) self.notebook_1_wxStaticLine = wx.Panel(self.notebook_1, wx.ID_ANY) self.static_line_2 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY, style=wx.LI_VERTICAL) self.static_line_3 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY, style=wx.LI_VERTICAL) self.static_line_4 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY) self.static_line_5 = wx.StaticLine(self.notebook_1_wxStaticLine, wx.ID_ANY) self.notebook_1_wxStaticText = wx.Panel(self.notebook_1, wx.ID_ANY) self.label_1 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("red text (RGB)"), style=wx.ALIGN_CENTER) self.label_4 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("black on red (RGB)"), style=wx.ALIGN_CENTER) self.label_5 = wx.StaticText(self.notebook_1_wxStaticText, wx.ID_ANY, _("green on pink (RGB)"), style=wx.ALIGN_CENTER) self.notebook_1_Spacer = wx.Panel(self.notebook_1, wx.ID_ANY) self.label_3 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY, _("Two labels with a")) self.label_2 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY, _("spacer between")) self.notebook_1_wxTextCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.text_ctrl = wx.TextCtrl(self.notebook_1_wxTextCtrl, wx.ID_ANY, _("This\nis\na\nmultiline\nwxTextCtrl"), style=wx.TE_CHARWRAP | wx.TE_MULTILINE | wx.TE_WORDWRAP) self.notebook_1_wxToggleButton = wx.Panel(self.notebook_1, wx.ID_ANY) self.button_2 = wx.ToggleButton(self.notebook_1_wxToggleButton, wx.ID_ANY, _("Toggle Button 1")) self.button_4 = wx.ToggleButton(self.notebook_1_wxToggleButton, wx.ID_ANY, _("Toggle Button 2"), style=wx.BU_BOTTOM | wx.BU_EXACTFIT) self.notebook_1_wxTreeCtrl = wx.Panel(self.notebook_1, wx.ID_ANY) self.tree_ctrl_1 = wx.TreeCtrl(self.notebook_1_wxTreeCtrl, wx.ID_ANY) self.static_line_1 = wx.StaticLine(self, wx.ID_ANY) self.button_5 = wx.Button(self, wx.ID_CLOSE, "") self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_NAVIGATION_KEY, self.OnBitmapButtonPanelNavigationKey) self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNotebookPageChanged, self.notebook_1) self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnNotebookPageChanging, self.notebook_1) self.Bind(wx.EVT_BUTTON, self.onStartConverting, self.button_1)
def OnInit(self): self.SetExitOnFrameDelete(False) self.SetAppName("Eelbrain") self.SetAppDisplayName("Eelbrain") # File Menu m = file_menu = wx.Menu() m.Append(wx.ID_OPEN, '&Open... \tCtrl+O') m.AppendSeparator() m.Append(wx.ID_CLOSE, '&Close Window \tCtrl+W') m.Append(wx.ID_SAVE, "Save \tCtrl+S") m.Append(wx.ID_SAVEAS, "Save As... \tCtrl+Shift+S") # Edit Menu m = edit_menu = wx.Menu() m.Append(ID.UNDO, '&Undo \tCtrl+Z') m.Append(ID.REDO, '&Redo \tCtrl+Shift+Z') m.AppendSeparator() m.Append(wx.ID_CUT, 'Cut \tCtrl+X') m.Append(wx.ID_COPY, 'Copy \tCtrl+C') m.Append(wx.ID_PASTE, 'Paste \tCtrl+V') m.AppendSeparator() m.Append(wx.ID_CLEAR, 'Cle&ar') # View Menu m = view_menu = wx.Menu() m.Append(ID.SET_VLIM, "Set Y-Axis Limit... \tCtrl+l", "Change the Y-" "axis limit in epoch plots") m.Append(ID.SET_MARKED_CHANNELS, "Mark Channels...", "Mark specific " "channels in plots.") m.AppendSeparator() m.Append(ID.SET_LAYOUT, "&Set Layout... \tCtrl+Shift+l", "Change the " "page layout") m.AppendCheckItem(ID.PLOT_RANGE, "&Plot Data Range \tCtrl+r", "Plot " "data range instead of individual sensor traces") # Go Menu m = go_menu = wx.Menu() m.Append(wx.ID_FORWARD, '&Forward \tCtrl+]', 'Go One Page Forward') m.Append(wx.ID_BACKWARD, '&Back \tCtrl+[', 'Go One Page Back') m.AppendSeparator() m.Append(ID.YIELD_TO_TERMINAL, '&Yield to Terminal \tAlt+Ctrl+Q') # Window Menu m = window_menu = wx.Menu() m.Append(ID.WINDOW_MINIMIZE, '&Minimize \tCtrl+M') m.Append(ID.WINDOW_ZOOM, '&Zoom') m.AppendSeparator() self.window_menu_window_items = [] # Help Menu m = help_menu = wx.Menu() m.Append(ID.HELP_EELBRAIN, 'Eelbrain Help') m.Append(ID.HELP_PYTHON, "Python Help") m.AppendSeparator() m.Append(wx.ID_ABOUT, '&About Eelbrain') # Menu Bar menu_bar = wx.MenuBar() menu_bar.Append(file_menu, "File") menu_bar.Append(edit_menu, "Edit") menu_bar.Append(view_menu, "View") menu_bar.Append(go_menu, "Go") menu_bar.Append(window_menu, "Window") menu_bar.Append(help_menu, self.GetMacHelpMenuTitleName()) wx.MenuBar.MacSetCommonMenuBar(menu_bar) self.menubar = menu_bar # Bind Menu Commands self.Bind(wx.EVT_MENU_OPEN, self.OnMenuOpened) self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) self.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.OnClear, id=wx.ID_CLEAR) self.Bind(wx.EVT_MENU, self.OnCloseWindow, id=wx.ID_CLOSE) self.Bind(wx.EVT_MENU, self.OnCopy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.OnCut, id=wx.ID_CUT) self.Bind(wx.EVT_MENU, self.OnOnlineHelp, id=ID.HELP_EELBRAIN) self.Bind(wx.EVT_MENU, self.OnOnlineHelp, id=ID.HELP_PYTHON) self.Bind(wx.EVT_MENU, self.OnPaste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.OnRedo, id=ID.REDO) self.Bind(wx.EVT_MENU, self.OnSave, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.OnSaveAs, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.OnSetLayout, id=ID.SET_LAYOUT) self.Bind(wx.EVT_MENU, self.OnSetMarkedChannels, id=ID.SET_MARKED_CHANNELS) self.Bind(wx.EVT_MENU, self.OnSetVLim, id=ID.SET_VLIM) self.Bind(wx.EVT_MENU, self.OnTogglePlotRange, id=ID.PLOT_RANGE) self.Bind(wx.EVT_MENU, self.OnUndo, id=ID.UNDO) self.Bind(wx.EVT_MENU, self.OnWindowMinimize, id=ID.WINDOW_MINIMIZE) self.Bind(wx.EVT_MENU, self.OnWindowZoom, id=ID.WINDOW_ZOOM) self.Bind(wx.EVT_MENU, self.OnQuit, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.OnYieldToTerminal, id=ID.YIELD_TO_TERMINAL) # bind update UI self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIBackward, id=wx.ID_BACKWARD) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIClear, id=wx.ID_CLEAR) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIClose, id=wx.ID_CLOSE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUICopy, id=wx.ID_COPY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUICut, id=wx.ID_CUT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIForward, id=wx.ID_FORWARD) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIOpen, id=wx.ID_OPEN) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIPaste, id=wx.ID_PASTE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIPlotRange, id=ID.PLOT_RANGE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIRedo, id=ID.REDO) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUISave, id=wx.ID_SAVE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUISaveAs, id=wx.ID_SAVEAS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUISetLayout, id=ID.SET_LAYOUT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUISetMarkedChannels, id=ID.SET_MARKED_CHANNELS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUISetVLim, id=ID.SET_VLIM) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUIUndo, id=ID.UNDO) return True
def createMenuBar(self, menu_list): # menubar = wxObjects().getMenuBar() menubar = wx.MenuBar() return self.addMenusToMenuBar(menu_list, menubar)
def __init__(self, parent, id=wx.ID_ANY, title='', size=(200, 200)): wx.Frame.__init__(self, parent, id, title, size=size) self.SetBackgroundColour(wx.Colour(240, 240, 240)) self.fname = None self.updated = False self.firstTime = True self.lastUpdateTime = None self.sources = [] self.errors = [] self.filehistory = wx.FileHistory(16) dataDir = Utils.getHomeDir() configFileName = os.path.join(dataDir, 'CallupSeedingMgr.cfg') self.config = wx.Config(appName="CallupSeedingMgr", vendorName="SmartCyclingSolutions", localFilename=configFileName) self.filehistory.Load(self.config) ID_MENU_UPDATE = wx.NewIdRef() ID_MENU_HELP = wx.NewIdRef() self.menuBar = wx.MenuBar(wx.MB_DOCKABLE) if 'WXMAC' in wx.Platform: self.appleMenu = self.menuBar.OSXGetAppleMenu() self.appleMenu.SetTitle("CallupSeedingMgr") self.appleMenu.Insert(0, wx.ID_ABOUT, "&About") self.Bind(wx.EVT_MENU, self.OnAboutBox, id=wx.ID_ABOUT) self.editMenu = wx.Menu() self.editMenu.Append( wx.MenuItem(self.editMenu, ID_MENU_UPDATE, "&Update")) self.Bind(wx.EVT_MENU, self.doUpdate, id=ID_MENU_UPDATE) self.menuBar.Append(self.editMenu, "&Edit") self.helpMenu = wx.Menu() self.helpMenu.Append( wx.MenuItem(self.helpMenu, ID_MENU_HELP, "&Help")) self.menuBar.Append(self.helpMenu, "&Help") self.Bind(wx.EVT_MENU, self.onTutorial, id=ID_MENU_HELP) else: self.fileMenu = wx.Menu() self.fileMenu.Append( wx.MenuItem(self.fileMenu, ID_MENU_UPDATE, "&Update")) self.fileMenu.Append(wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.doUpdate, id=ID_MENU_UPDATE) self.Bind(wx.EVT_MENU, self.onClose, id=wx.ID_EXIT) self.menuBar.Append(self.fileMenu, "&File") self.helpMenu = wx.Menu() self.helpMenu.Insert(0, wx.ID_ABOUT, "&About") self.helpMenu.Insert(1, ID_MENU_HELP, "&Help") self.Bind(wx.EVT_MENU, self.OnAboutBox, id=wx.ID_ABOUT) self.Bind(wx.EVT_MENU, self.onTutorial, id=ID_MENU_HELP) self.menuBar.Append(self.helpMenu, "&Help") self.SetMenuBar(self.menuBar) inputBox = wx.StaticBox(self, label=_('Input')) inputBoxSizer = wx.StaticBoxSizer(inputBox, wx.VERTICAL) self.fileBrowse = filebrowse.FileBrowseButtonWithHistory( self, labelText=_('Excel File'), buttonText=('Browse...'), startDirectory=os.path.expanduser('~'), fileMask= 'Excel Spreadsheet (*.xlsx; *.xlsm; *.xls)|*.xlsx; *.xlsml; *.xls', size=(400, -1), history=lambda: [ self.filehistory.GetHistoryFile(i) for i in range(self.filehistory.GetCount()) ], changeCallback=self.doChangeCallback, ) inputBoxSizer.Add(self.fileBrowse, 0, flag=wx.EXPAND | wx.ALL, border=4) horizontalControlSizer = wx.BoxSizer(wx.HORIZONTAL) #------------------------------------------------------------------------------------------- verticalControlSizer = wx.BoxSizer(wx.VERTICAL) self.useUciIdCB = wx.CheckBox(self, label=_("Use UCI ID (assume no errors)")) self.useUciIdCB.SetValue(True) verticalControlSizer.Add(self.useUciIdCB, flag=wx.ALL, border=4) self.useLicenseCB = wx.CheckBox( self, label=_("Use License (assume no errors)")) self.useLicenseCB.SetValue(True) verticalControlSizer.Add(self.useLicenseCB, flag=wx.ALL, border=4) self.soundalikeCB = wx.CheckBox( self, label=_("Match misspelled names with Sound-Alike")) self.soundalikeCB.SetValue(True) verticalControlSizer.Add(self.soundalikeCB, flag=wx.ALL, border=4) self.callupSeedingRB = wx.RadioBox( self, style=wx.RA_SPECIFY_COLS, majorDimension=1, label=_("Sequence"), choices=[ _("Callups: Highest ranked FIRST (Cyclo-cross, MTB)"), _("Seeding: Highest ranked LAST (Time Trials)"), ], ) verticalControlSizer.Add(self.callupSeedingRB, flag=wx.EXPAND | wx.ALL, border=4) verticalControlSizer.Add(wx.StaticText( self, label=_('Riders with no criteria will be sequenced randomly.')), flag=wx.ALL, border=4) horizontalControlSizer.Add(verticalControlSizer, flag=wx.EXPAND) self.updateButton = RoundButton(self, size=(96, 96)) self.updateButton.SetLabel(_('Update')) self.updateButton.SetFontToFitLabel() self.updateButton.SetForegroundColour(wx.Colour(0, 100, 0)) self.updateButton.Bind(wx.EVT_BUTTON, self.doUpdate) horizontalControlSizer.Add(self.updateButton, flag=wx.ALL, border=4) horizontalControlSizer.AddSpacer(48) vs = wx.BoxSizer(wx.VERTICAL) self.tutorialButton = wx.Button(self, label=_('Help/Tutorial...')) self.tutorialButton.Bind(wx.EVT_BUTTON, self.onTutorial) vs.Add(self.tutorialButton, flag=wx.ALL, border=4) branding = wx.adv.HyperlinkCtrl( self, id=wx.ID_ANY, label=u"Powered by CrossMgr", url=u"http://www.sites.google.com/site/crossmgrsoftware/") vs.Add(branding, flag=wx.ALL, border=4) horizontalControlSizer.Add(vs) inputBoxSizer.Add(horizontalControlSizer, flag=wx.EXPAND) self.sourceList = wx.ListCtrl(self, style=wx.LC_REPORT, size=(-1, 100)) inputBoxSizer.Add(self.sourceList, flag=wx.ALL | wx.EXPAND, border=4) self.sourceList.InsertColumn(0, "Sheet") self.sourceList.InsertColumn(1, "Data Columns and Derived Information") self.sourceList.InsertColumn(2, "Key Fields") self.sourceList.InsertColumn(3, "Rows", wx.LIST_FORMAT_RIGHT) self.sourceList.InsertColumn(4, "Errors/Warnings", wx.LIST_FORMAT_RIGHT) self.sourceList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onItemSelected) instructions = [ _('Drag-and-Drop the row numbers on the Left to change the sequence.' ), _('Click on Points or Position cells for details.'), _('Orange Cells: Multiple Matches. Click on the cell to see what you need to fix in the spreadsheet.' ), _('Yellow Cells: Soundalike Matches. Click on the cell to validate if the names are matched correctly.' ), ] self.grid = ReorderableGrid(self) self.grid.CreateGrid(0, 1) self.grid.SetColLabelValue(0, u'') self.grid.EnableDragRowSize(False) self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.onGridCellClick) #self.grid.Bind( wx.EVT_MOTION, self.onMouseOver ) outputBox = wx.StaticBox(self, label=_('Output')) outputBoxSizer = wx.StaticBoxSizer(outputBox, wx.VERTICAL) hs = wx.BoxSizer(wx.HORIZONTAL) self.excludeUnrankedCB = wx.CheckBox( self, label=_("Exclude riders with no ranking info")) hs.Add(self.excludeUnrankedCB, flag=wx.ALL | wx.ALIGN_CENTRE_VERTICAL, border=4) hs.AddSpacer(24) hs.Add(wx.StaticText(self, label=_("Output:")), flag=wx.ALL | wx.ALIGN_CENTRE_VERTICAL, border=4) self.topRiders = wx.Choice(self, choices=[ _('All Riders'), _('Top 5'), _('Top 10'), _('Top 15'), _('Top 20'), _('Top 25') ]) self.topRiders.SetSelection(0) hs.Add(self.topRiders, flag=wx.ALIGN_CENTRE_VERTICAL) self.saveAsExcel = wx.Button(self, label=_('Save as Excel...')) self.saveAsExcel.Bind(wx.EVT_BUTTON, self.doSaveAsExcel) hs.AddSpacer(48) hs.Add(self.saveAsExcel, flag=wx.ALL, border=4) outputBoxSizer.Add(hs) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(inputBoxSizer, flag=wx.EXPAND | wx.ALL, border=4) for i, instruction in enumerate(instructions): flag = wx.LEFT | wx.RIGHT if i == len(instructions) - 1: flag |= wx.BOTTOM mainSizer.Add(wx.StaticText(self, label=instruction), flag=flag, border=8) mainSizer.Add(self.grid, 1, flag=wx.EXPAND | wx.ALL, border=4) mainSizer.Add(outputBoxSizer, flag=wx.EXPAND | wx.ALL, border=4) self.SetSizer(mainSizer)
def test_mdiChildFrame2(self): f = wx.MDIParentFrame(None, title="MDI Parent") f.SetMenuBar(wx.MenuBar()) c = wx.MDIChildFrame() c.Create(f, title="MDI Child") f.Close()
def __init__(self, *args, **kwds): kwds['style'] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menubar menuBar = wx.MenuBar() self.itemMenu = wx.Menu() self.itemMenu.Append(wx.ID_NEW, '&New\tCtrl-N', 'Create a new item') self.itemMenu.Append(wx.ID_EDIT, '&Edit\tCtrl-E', 'Edit selected item') self.itemMenu.Append(wx.ID_DELETE, '&Delete\tCtrl-D', 'Delete selected item') self.itemMenu.AppendSeparator() self.itemMenu.Append(wx.ID_SAVE, '&Sync\tCtrl-S', 'Save changes to dropbox') self.itemMenu.AppendSeparator() self.itemMenu.Append(wx.ID_EXIT, '&Quit\tCtrl-Q') menuBar.Append(self.itemMenu, '&Item') self.accountMenu = wx.Menu() self.accountMenu.Append(ID_UNLINK, '&Unlink\tCtrl-U', 'Unlink Current Account') menuBar.Append(self.accountMenu, '&Account') self.SetMenuBar(menuBar) # Statusbar self.statusbar = self.CreateStatusBar() # Toolbar icon_size = (15,15) self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) artBmp = wx.ArtProvider.GetBitmap self.toolbar.AddSimpleTool( wx.ID_NEW, artBmp(wx.ART_NEW, wx.ART_TOOLBAR, icon_size), 'New') self.toolbar.AddSimpleTool( wx.ID_EDIT, artBmp(wx.ART_LIST_VIEW, wx.ART_TOOLBAR, icon_size), 'Edit') self.toolbar.AddSimpleTool( wx.ID_DELETE, artBmp(wx.ART_DELETE, wx.ART_TOOLBAR, icon_size), 'Delete') self.toolbar.AddSimpleTool( wx.ID_SAVE, wx.Bitmap('sync.png', wx.BITMAP_TYPE_PNG) , 'Sync') self.toolbar.Realize() # Associate menu/toolbar items with their handlers. menuHandlers = [ (wx.ID_NEW, self.doNew), (wx.ID_EDIT, self.doEditItem), (wx.ID_DELETE, self.doDelete), (wx.ID_SAVE, self.doSave), (wx.ID_EXIT, self.doExit), (ID_UNLINK, self.doUnlink)] for combo in menuHandlers: id, handler = combo[:2] self.Bind(wx.EVT_MENU, handler, id = id) self.Bind(wx.EVT_CLOSE, self.doExit) # Setup our top-most panel. This holds the entire contents of the # window, excluding the menu bar. self.topPanel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) # Setup the list control. self.listCtrl = wx.ListCtrl(self.topPanel, wx.ID_VIEW_LIST, style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.SUNKEN_BORDER) self.listCtrl.InsertColumn(0, 'Title', width=150) self.listCtrl.InsertColumn(1, 'Armature', width=100) self.listCtrl.InsertColumn(2, 'File', width=200) self.listCtrl.InsertColumn(3, 'Summary', width=100) self.listCtrl.InsertColumn(4, 'Description', width=250) self.listCtrl.InsertColumn(5, 'Caption', width=100) self.listCtrl.InsertColumn(6, 'Thumbnail', width=150) self.listCtrl.InsertColumn(7, 'RelatedItem', width=150) self.listCtrl.InsertColumn(8, 'Home Grid') self.listCtrl.InsertColumn(9, 'Order') self.listCtrl.SetBackgroundColour(wx.WHITE) self.listCtrl.Bind(wx.EVT_LEFT_DCLICK, self.doEditItem) self.listCtrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) self.listCtrl.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected) # Position everything in the window. topSizer = wx.BoxSizer(wx.HORIZONTAL) topSizer.Add(self.listCtrl, 1, wx.EXPAND) self.topPanel.SetAutoLayout(True) self.topPanel.SetSizer(topSizer) # self.SetSizeHints(250, 200) self.SetSize(wx.Size(600, 400)) self.SetTitle('File Manager ' + VERSION_NO) self.needSave = False self.database = DbxDataAdapter(APP_KEY, APP_SECRET) if not self.database.is_linked(): url = self.database.get_authorize_url() dlg = wx.TextEntryDialog(self, "1. Authorize this app on the opened webpage.\n2. Enter the code below and press ENTER.", "App Authorization", " ") webbrowser.open(url,new=2) if dlg.ShowModal() == wx.ID_OK: auth_code = dlg.GetValue() self.database.link(auth_code) else: dlg.Destroy() self.Destroy() return dlg.Destroy() self.database.connect() self.media_info_list = self.database.read_data() self._updateList() self._updateMenu(False) self.config = ConfigParser.ConfigParser() if not os.path.exists('config.cfg'): self._setDropboxPath() else: self.config.read('config.cfg') try: self.dbxPath = self.config.get('Setting', 'DropboxPath') except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): os.remove('config.cfg') self._setDropboxPath()
def __init__(self): '''Constructeur.''' self.stop = False # TODO ? self.thread_analyze = None self.thread_maj = None # Frame # - Application wx.Frame.__init__(self, None, title='Synchonizer', size=(500, 700)) self.SetMinSize((300, 500)) self.CenterOnScreen() # - Preferences self.preferences = Preferences(self) # Menu bar menuBar = wx.MenuBar() self.SetMenuBar(menuBar) # - File menuBar_file = wx.Menu() menuBar.Append(menuBar_file, '&File') # * Exit menuBar_file_exit = wx.MenuItem(menuBar_file, wx.ID_ANY, '&Exit\tAlt-F4') menuBar_file_exit.SetBitmap( wx.Bitmap('icons/exit.png', wx.BITMAP_TYPE_PNG)) self.Bind(wx.EVT_MENU, lambda event: self.Close(), menuBar_file_exit) menuBar_file.AppendItem(menuBar_file_exit) # - Action menuBar_action = wx.Menu() menuBar.Append(menuBar_action, 'Action') # * Stop self.menuBar_action_stop = wx.MenuItem(menuBar_action, wx.ID_ANY, 'Stop') self.menuBar_action_stop.Enable(False) self.menuBar_action_stop.SetBitmap( wx.Bitmap('icons/stop.png', wx.BITMAP_TYPE_PNG)) self.Bind(wx.EVT_MENU, lambda event: self.Stop(), self.menuBar_action_stop) menuBar_action.AppendItem(self.menuBar_action_stop) # * Analyze self.menuBar_action_analyze = wx.MenuItem(menuBar_action, wx.ID_ANY, 'Analyze') self.menuBar_action_analyze.SetBitmap( wx.Bitmap('icons/analyze.png', wx.BITMAP_TYPE_PNG)) self.Bind(wx.EVT_MENU, lambda event: self.OnAnalyze(), self.menuBar_action_analyze) menuBar_action.AppendItem(self.menuBar_action_analyze) # * Run self.menuBar_action_run = wx.MenuItem(menuBar_action, wx.ID_ANY, 'Run') self.menuBar_action_run.SetBitmap( wx.Bitmap('icons/execute.png', wx.BITMAP_TYPE_PNG)) self.Bind(wx.EVT_MENU, lambda event: self.OnExecute(), self.menuBar_action_run) menuBar_action.AppendItem(self.menuBar_action_run) # - Utils menuBar_utils = wx.Menu() menuBar.Append(menuBar_utils, '&Utils') # TODO: rename # * Préférences menuBar_utils_preference = wx.MenuItem(menuBar_utils, wx.ID_ANY, 'Preferences') menuBar_utils_preference.SetBitmap( wx.Bitmap('icons/preferences.png', wx.BITMAP_TYPE_PNG)) self.Bind(wx.EVT_MENU, self.OnMenu_utils_preferences, menuBar_utils_preference) menuBar_utils.AppendItem(menuBar_utils_preference) # - Help menuBar_help = wx.Menu() menuBar.Append(menuBar_help, '&?') # * About menuBar_help_about = wx.MenuItem(menuBar_help, wx.ID_ANY, 'About') self.Bind(wx.EVT_MENU, self.OnMenu_help_about, menuBar_help_about) menuBar_help.AppendItem(menuBar_help_about) # Panel & Sizer sizer_frame = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer_frame) self.panel_fenetre = wx.Panel(self) sizer_frame.Add(self.panel_fenetre, 1, wx.EXPAND, 5) self.sizer_panel = wx.BoxSizer(wx.VERTICAL) self.panel_fenetre.SetSizer(self.sizer_panel) # Tool bar self.tBar = wx.ToolBar(self.panel_fenetre, style=wx.TB_FLAT) self.sizer_panel.Add(self.tBar, flag=wx.EXPAND) # - Exit tool_exit = self.tBar.AddLabelTool(wx.ID_ANY, 'Exit', wx.Bitmap('icons/exit.png', wx.BITMAP_TYPE_PNG), shortHelp='Exit') self.tBar.Bind(wx.EVT_TOOL, lambda event: self.Close(), tool_exit) # | self.tBar.AddSeparator() # - Delete selected lines tool_deleteSelectedLines = self.tBar.AddLabelTool( wx.ID_ANY, 'Delete selected lines', wx.Bitmap('icons/delete.png', wx.BITMAP_TYPE_PNG), shortHelp='Delete selected liness') self.tBar.Bind(wx.EVT_TOOL, lambda event: self.lCtrl.DeleteSelectedLines(), tool_deleteSelectedLines) # | self.tBar.AddSeparator() # - Stop self.tool_stop = self.tBar.AddLabelTool(wx.ID_ANY, 'Stop', wx.Bitmap( 'icons/stop.png', wx.BITMAP_TYPE_PNG), shortHelp='Stop') self.tBar.Bind(wx.EVT_TOOL, lambda event: self.Stop(), self.tool_stop) # - Analyse self.tool_analyse = self.tBar.AddLabelTool(wx.ID_ANY, 'Analyse', wx.Bitmap( 'icons/analyze.png', wx.BITMAP_TYPE_PNG), shortHelp='Analyze') self.tBar.Bind(wx.EVT_TOOL, lambda event: self.OnAnalyze(), self.tool_analyse) # - Execute self.tool_execute = self.tBar.AddLabelTool(wx.ID_ANY, 'Execture', wx.Bitmap( 'icons/execute.png', wx.BITMAP_TYPE_PNG), shortHelp='Execute') self.tBar.Bind(wx.EVT_TOOL, lambda event: self.Run(), self.tool_execute) # self.tBar.Realize() # _____ ligne_titre_options = wx.StaticLine(self.panel_fenetre) self.sizer_panel.Add(ligne_titre_options, flag=wx.ALL | wx.EXPAND, border=5) # Options # - Title sText_options = wx.StaticText(self.panel_fenetre, label='Options') font_titre_options = wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD) sText_options.SetFont(font_titre_options) self.sizer_panel.Add(sText_options, flag=wx.ALL, border=5) # - Sizer gSizer_options = wx.GridSizer(cols=3) self.sizer_panel.Add(gSizer_options, flag=wx.ALL | wx.EXPAND, border=5) # * Input title sText_src = wx.StaticText(self.panel_fenetre, label='Input folder:') gSizer_options.Add(sText_src, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5) # * Input value self.tCtrl_src = wx.TextCtrl(self.panel_fenetre, style=wx.TE_READONLY) gSizer_options.Add(self.tCtrl_src, flag=wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, border=5) # * Input browse self.button_src = wx.Button(self.panel_fenetre, label='Browse') self.button_src.Bind(wx.EVT_BUTTON, lambda event: self.BrowseSrc()) gSizer_options.Add(self.button_src, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5) # * Target title sText_tgt = wx.StaticText(self.panel_fenetre, label='Target folder:') gSizer_options.Add(sText_tgt, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5) # * Target value self.tCtrl_tgt = wx.TextCtrl(self.panel_fenetre, style=wx.TE_READONLY) gSizer_options.Add(self.tCtrl_tgt, flag=wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, border=5) # * Target browse self.button_tgt = wx.Button(self.panel_fenetre, label='Browse') self.button_tgt.Bind(wx.EVT_BUTTON, lambda event: self.BrowseTgt()) gSizer_options.Add(self.button_tgt, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5) # _____ ligne_options_modifications = wx.StaticLine(self.panel_fenetre) self.sizer_panel.Add(ligne_options_modifications, flag=wx.ALL | wx.EXPAND, border=5) # Actions # Title sText_modifications = wx.StaticText(self.panel_fenetre, label='Modifications:') font_titre_modifications = wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD) sText_modifications.SetFont(font_titre_modifications) self.sizer_panel.Add(sText_modifications, flag=wx.ALL, border=5) # List self.lCtrl = MyListCtrl(self.panel_fenetre) self.sizer_panel.Add(self.lCtrl, 1, wx.ALL | wx.EXPAND, 5) # _____ self.ligne_modifications_actions = wx.StaticLine(self.panel_fenetre) self.sizer_panel.Add(self.ligne_modifications_actions, flag=wx.ALL | wx.EXPAND, border=5) # Loading bar self.chargement = wx.Gauge(self.panel_fenetre) self.sizer_panel.Add(self.chargement, 0, wx.ALL | wx.EXPAND, 5) # Events self.Bind(wx.EVT_CLOSE, self.OnClose) self.init() # TODO: delete me # Disable actions self.tool_analyse.Enable(False) self.tool_execute.Enable(False) self.tool_stop.Enable(True)
def __init__(self, parent, title): super(MainFrame, self).__init__(parent, title=title, size=(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT), style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX) self.input_file_path = u'' self.output_folder_path = u'' self.status_log = u'' self.validate = False self.overwrite = False self.worker = None self.result_thread = None self.progress_thread = None self.about_window = None self.menu_bar = wx.MenuBar() self.file_menu = wx.Menu() self.help_menu = wx.Menu() self.quit_menu_item = wx.MenuItem(self.file_menu, APP_QUIT, '&Quit\tCtrl+Q') self.about_menu_item = wx.MenuItem(self.help_menu, APP_ABOUT, '&About ' + TITLE) self.file_menu.Append(self.quit_menu_item) self.help_menu.Append(self.about_menu_item) self.menu_bar.Append(self.file_menu, '&File') self.menu_bar.Append(self.help_menu, '&About') self.Bind(wx.EVT_MENU, self.on_quit, id=APP_QUIT) self.Bind(wx.EVT_MENU, self.on_about, id=APP_ABOUT) self.Bind(wx.EVT_CLOSE, self.on_quit) self.SetMenuBar(self.menu_bar) self.parent_panel = wx.ScrolledWindow(self) self.parent_panel.SetScrollbars(1, 1, 1, 1) self.parent_box_sizer = wx.BoxSizer(wx.VERTICAL) self.about_button = wx.Button(self.parent_panel, label='About') self.about_button.Bind(wx.EVT_BUTTON, self.on_about) self.quit_button = wx.Button(self.parent_panel, label='Quit') self.quit_button.Bind(wx.EVT_BUTTON, self.on_quit) # header self.header_box_sizer = wx.BoxSizer(wx.HORIZONTAL) self.header_box_sizer.AddStretchSpacer() self.header_box_sizer.Add(self.about_button, proportion=0, flag=wx.LEFT | wx.RIGHT, border=5) self.header_box_sizer.Add(self.quit_button, proportion=0, flag=wx.LEFT | wx.RIGHT, border=5) # choose input file self.choose_input_static_box = wx.StaticBox( self.parent_panel, label='1. Choose XLSForm (.xls or .xlsx) for conversion') self.choose_input_static_box_sizer = wx.StaticBoxSizer( self.choose_input_static_box, wx.HORIZONTAL) self.choose_file_button = wx.Button(self.parent_panel, label='Choose file...') self.choose_file_button.Bind(wx.EVT_BUTTON, self.on_open_file) self.chosen_file_text = wx.StaticText(self.parent_panel, label='', size=(-1, -1)) self.choose_file_box_sizer = wx.BoxSizer(wx.HORIZONTAL) self.choose_file_box_sizer.Add(self.choose_file_button, proportion=0, flag=wx.LEFT | wx.RIGHT, border=0) self.choose_file_box_sizer.AddSpacer(CHOOSE_SPACER) self.choose_file_box_sizer.Add(self.chosen_file_text, proportion=1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=CHOOSE_BORDER) self.choose_file_box_sizer.AddSpacer(CHOOSE_SPACER) self.choose_input_static_box_sizer.Add(self.choose_file_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) # choose output folder self.choose_folder_label = '2. Choose location for output file(s)' self.choose_output_static_box = wx.StaticBox( self.parent_panel, label=self.choose_folder_label) self.choose_output_static_box_sizer = wx.StaticBoxSizer( self.choose_output_static_box, wx.HORIZONTAL) self.choose_folder_button = wx.Button(self.parent_panel, label='Choose location...') self.choose_folder_button.Bind(wx.EVT_BUTTON, self.on_open_folder) self.chosen_folder_text = wx.StaticText(self.parent_panel, label='', size=(-1, -1)) self.choose_folder_box_sizer = wx.BoxSizer(wx.HORIZONTAL) self.choose_folder_box_sizer.Add(self.choose_folder_button, proportion=0, flag=wx.LEFT | wx.RIGHT, border=0) self.choose_folder_box_sizer.AddSpacer(CHOOSE_SPACER) self.choose_folder_box_sizer.Add(self.chosen_folder_text, proportion=1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=CHOOSE_BORDER) self.choose_folder_box_sizer.AddSpacer(CHOOSE_SPACER) self.choose_output_static_box_sizer.Add(self.choose_folder_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) # set conversion options self.set_options_static_box = wx.StaticBox( self.parent_panel, label='3. Set conversion options') self.set_options_static_box_sizer = wx.StaticBoxSizer( self.set_options_static_box, wx.VERTICAL) self.overwrite_label = 'Overwrite existing output file(s)' self.overwrite_checkbox = wx.CheckBox(self.parent_panel, label=self.overwrite_label, size=(-1, -1)) self.overwrite_checkbox.SetValue(self.overwrite) self.Bind(wx.EVT_CHECKBOX, self.toggle_overwrite, id=self.overwrite_checkbox.GetId()) self.validate_label = 'Validate converted XForm with ODK Validate' if self.is_java_installed(): self.validate = True self.validate_checkbox = wx.CheckBox(self.parent_panel, label=self.validate_label, size=(-1, -1)) self.Bind(wx.EVT_CHECKBOX, self.toggle_validate, id=self.validate_checkbox.GetId()) else: self.validate = False self.validate_checkbox = wx.CheckBox(self.parent_panel, label=self.validate_label + ' (Requires Java)') self.validate_checkbox.Disable() self.Bind(wx.EVT_CHECKBOX, self.toggle_validate, id=self.validate_checkbox.GetId()) self.validate_checkbox.SetValue(self.validate) self.set_options_static_box_sizer.Add(self.overwrite_checkbox, flag=wx.LEFT | wx.TOP, border=5) self.set_options_static_box_sizer.AddStretchSpacer() self.set_options_static_box_sizer.Add(self.validate_checkbox, flag=wx.LEFT | wx.TOP, border=5) self.set_options_static_box_sizer.AddStretchSpacer() self.set_options_static_box_sizer.AddSpacer(OPTIONS_SPACER) # start conversion self.start_conversion_static_box = wx.StaticBox( self.parent_panel, label='4. Run conversion') self.start_conversion_box_sizer = wx.StaticBoxSizer( self.start_conversion_static_box, wx.VERTICAL) self.status_text_ctrl = wx.TextCtrl(self.parent_panel, size=(-1, 200), style=wx.TE_MULTILINE | wx.TE_LEFT) self.status_text_ctrl.SetEditable(False) self.status_text_ctrl.SetValue(self.status_log) self.status_gauge = wx.Gauge(self.parent_panel, range=1, size=(-1, -1)) self.action_button = wx.Button(self.parent_panel, label='Run') self.action_button.Bind(wx.EVT_BUTTON, self.on_action) self.action_button.Disable() self.status_gauge_box_sizer = wx.BoxSizer(wx.HORIZONTAL) self.status_gauge_box_sizer.Add(self.status_gauge, proportion=1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) self.status_gauge_box_sizer.AddSpacer(CHOOSE_SPACER) self.status_gauge_box_sizer.Add(self.action_button, proportion=0, flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, border=2.5) self.status_gauge_box_sizer.AddSpacer(CHOOSE_SPACER) self.start_conversion_box_sizer.Add(self.status_gauge_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) self.start_conversion_box_sizer.Add(self.status_text_ctrl, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) # build ui self.parent_box_sizer.AddSpacer(15) self.parent_box_sizer.Add(self.header_box_sizer, proportion=0, flag=wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) self.parent_box_sizer.AddSpacer(HEADER_SPACER) self.parent_box_sizer.Add(self.choose_input_static_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) self.parent_box_sizer.Add(self.choose_output_static_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) self.parent_box_sizer.Add(self.set_options_static_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) self.parent_box_sizer.Add(self.start_conversion_box_sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) self.parent_panel.SetSizer(self.parent_box_sizer) worker.evt_result(self, self.on_result) worker.evt_progress(self, self.on_progress) self.Centre() self.Show()
def __init__(self, parent): # begin wxGlade: mainFrame.__init__ wx.Frame.__init__(self, parent=parent) self.SetSize((1280, 720)) #------------------# # design codes # #------------------# self.frame_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() item = wxglade_tmp_menu.Append(wx.ID_ANY, "New case", "") self.Bind(wx.EVT_MENU, self.onNewCase, id=item.GetId()) item = wxglade_tmp_menu.Append(wx.ID_ANY, "Open case", "") self.Bind(wx.EVT_MENU, self.onOpenCase, id=item.GetId()) wxglade_tmp_menu.AppendSeparator() itemAddEvidenceBtn = wxglade_tmp_menu.Append(wx.ID_ANY, "Add PCAP File", "") self.Bind(wx.EVT_MENU, self.onAddEvidence, id=itemAddEvidenceBtn.GetId()) wxglade_tmp_menu.AppendSeparator() item = wxglade_tmp_menu.Append(wx.ID_ANY, "Quit", "") self.Bind(wx.EVT_MENU, self.onQuit, id=item.GetId()) self.frame_menubar.Append(wxglade_tmp_menu, "File") wxglade_tmp_menu = wx.Menu() item = wxglade_tmp_menu.Append(wx.ID_ANY, "Clear GUI", "") self.Bind(wx.EVT_MENU, self.onClearGUI, id=item.GetId()) self.frame_menubar.Append(wxglade_tmp_menu, "Tools") self.SetMenuBar(self.frame_menubar) #splitter window self.window_1 = wx.SplitterWindow(self, wx.ID_ANY) #left panel self.windowLeftPanel = wx.Panel(self.window_1, wx.ID_ANY) self.tree_ctrl_1 = wx.TreeCtrl(self.windowLeftPanel, wx.ID_ANY, style=wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE) #right panel self.windowRightPanel = wx.Panel(self.window_1, wx.ID_ANY) self.searchBtn = wx.Button(self.windowRightPanel, id=wx.ID_ANY, label="Search", pos=wx.DefaultPosition, size=(100, -1), style=0, validator=wx.DefaultValidator) self.auiNotebook = wx.aui.AuiNotebook(self.windowRightPanel) self.paneltest = wx.Panel(self.auiNotebook, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) #bind events self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onItemSel, self.tree_ctrl_1) self.Bind(wx.EVT_BUTTON, self.onSearchBtn, self.searchBtn) self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onAuiClose, self.auiNotebook) #properties self.SetTitle("Forensic Pi") self.tree_ctrl_1.SetBackgroundColour(wx.Colour(240, 240, 240)) self.windowLeftPanel.SetMinSize((180, -1)) self.windowRightPanel.SetMinSize((980, -1)) self.window_1.SetMinimumPaneSize(20) #layout mainSizer = wx.BoxSizer(wx.VERTICAL) #left panel sizer panel1Sizer = wx.BoxSizer(wx.HORIZONTAL) panel1Sizer.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0) self.windowLeftPanel.SetSizer(panel1Sizer) #right panel sizer self.panel2Sizer = wx.BoxSizer(wx.VERTICAL) self.panel2Sizer.Add(self.searchBtn, 0, wx.ALIGN_RIGHT, 0) self.panel2Sizer.Add(self.auiNotebook, 1, wx.EXPAND, 0) self.windowRightPanel.SetSizer(self.panel2Sizer) #splitter self.window_1.SplitVertically(self.windowLeftPanel, self.windowRightPanel) mainSizer.Add(self.window_1, 1, wx.EXPAND, 0) self.SetSizer(mainSizer) self.Layout() #database self.conn = None #self.evidence = None self.evidenceDetails = None
def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) wx.EVT_CLOSE(self, self._on_frame_close) self.panel = wx.Panel(self, -1) self._searchbox = wx.SearchCtrl(self.panel, size=(200, -1)) self._searchbox.ShowCancelButton(True) self.list = self.VaultListCtrl(self.panel, -1, size=(640, 240), style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_VIRTUAL|wx.LC_EDIT_LABELS) self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self._on_list_contextmenu) self.list.Bind(wx.EVT_RIGHT_UP, self._on_list_contextmenu) self.list.Bind(wx.EVT_CHAR, self._on_list_box_char) self.statusbar = self.CreateStatusBar(1, wx.STB_SIZEGRIP) # Set up menus filemenu = wx.Menu() temp_id = wx.NewId() filemenu.Append(temp_id, _("Change &Password") + "...") wx.EVT_MENU(self, temp_id, self._on_change_password) temp_id = wx.NewId() filemenu.Append(temp_id, _("&Merge Records from") + "...") wx.EVT_MENU(self, temp_id, self._on_merge_vault) filemenu.Append(wx.ID_ABOUT, _("&About")) wx.EVT_MENU(self, wx.ID_ABOUT, self._on_about) filemenu.Append(wx.ID_PREFERENCES, _("&Settings")) wx.EVT_MENU(self, wx.ID_PREFERENCES, self._on_settings) filemenu.AppendSeparator() filemenu.Append(wx.ID_EXIT, _("E&xit")) wx.EVT_MENU(self, wx.ID_EXIT, self._on_exit) self._recordmenu = wx.Menu() self._recordmenu.Append(wx.ID_ADD, _("&Add\tCtrl+Shift+A")) wx.EVT_MENU(self, wx.ID_ADD, self._on_add) self._recordmenu.Append(wx.ID_DELETE, _("&Delete\tCtrl+Del")) wx.EVT_MENU(self, wx.ID_DELETE, self._on_delete) self._recordmenu.AppendSeparator() self._recordmenu.Append(wx.ID_PROPERTIES, _("&Edit\tCtrl+E")) wx.EVT_MENU(self, wx.ID_PROPERTIES, self._on_edit) self._recordmenu.AppendSeparator() temp_id = wx.NewId() self._recordmenu.Append(temp_id, _("Copy &Username\tCtrl+Shift+C")) wx.EVT_MENU(self, temp_id, self._on_copy_username) temp_id = wx.NewId() self._recordmenu.Append(temp_id, _("Copy &Password\tCtrl+C")) wx.EVT_MENU(self, temp_id, self._on_copy_password) temp_id = wx.NewId() self._recordmenu.Append(temp_id, _("Open UR&L\tCtrl+L")) wx.EVT_MENU(self, temp_id, self._on_open_url) temp_id = wx.NewId() self._recordmenu.Append(temp_id, _("Search &For Entry\tCtrl+F")) wx.EVT_MENU(self, temp_id, self._on_search_for_entry) menu_bar = wx.MenuBar() menu_bar.Append(filemenu, _("&Vault")) menu_bar.Append(self._recordmenu, _("&Record")) self.SetMenuBar(menu_bar) self.SetTitle("Loxodo - " + _("Vault Contents")) self.statusbar.SetStatusWidths([-1]) statusbar_fields = [""] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) sizer = wx.BoxSizer(wx.VERTICAL) _rowsizer = wx.BoxSizer(wx.HORIZONTAL) self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self._on_search_cancel, self._searchbox) self.Bind(wx.EVT_TEXT, self._on_search_do, self._searchbox) self._searchbox.Bind(wx.EVT_CHAR, self._on_searchbox_char) _rowsizer.Add(self._searchbox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT, 5) sizer.Add(_rowsizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5) sizer.Add(self.list, 1, wx.EXPAND, 0) self.panel.SetSizer(sizer) _sz_frame = wx.BoxSizer() _sz_frame.Add(self.panel, 1, wx.EXPAND) self.SetSizer(_sz_frame) sizer.Fit(self) self.Layout() self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._on_list_item_activated, self.list) self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self._on_list_item_label_edit, self.list) self.Bind(wx.EVT_LIST_COL_CLICK, self._on_list_column_click, self.list) self._searchbox.SetFocus() self.vault_file_name = None self.vault_password = None self.vault = None self._is_modified = False
def __createMenus(self): # File Menu m = self.fileMenu = wx.Menu() m.Append(ID_NEW, '&New \tCtrl+N', 'New file') m.Append(ID_OPEN, '&Open... \tCtrl+O', 'Open file') m.AppendSeparator() m.Append(ID_REVERT, '&Revert \tCtrl+R', 'Revert to last saved version') m.Append(ID_CLOSE, '&Close \tCtrl+W', 'Close file') m.AppendSeparator() m.Append(ID_SAVE, '&Save... \tCtrl+S', 'Save file') m.Append(ID_SAVEAS, 'Save &As \tCtrl+Shift+S', 'Save file with new name') if self.shellName in ['PySlices', 'SymPySlices']: m.Append( ID_SAVEACOPY, 'Save A Cop&y', 'Save a copy of the file without changing the current file') m.AppendSeparator() m.Append(ID_PRINT, '&Print... \tCtrl+P', 'Print file') m.AppendSeparator() m.Append(ID_NAMESPACE, '&Update Namespace \tCtrl+Shift+N', 'Update namespace for autocompletion and calltips') m.AppendSeparator() m.Append(ID_EXIT, 'E&xit\tCtrl+Q', 'Exit Program') # Edit m = self.editMenu = wx.Menu() m.Append(ID_UNDO, '&Undo \tCtrl+Z', 'Undo the last action') m.Append(ID_REDO, '&Redo \tCtrl+Y', 'Redo the last undone action') m.AppendSeparator() m.Append(ID_CUT, 'Cu&t \tCtrl+X', 'Cut the selection') m.Append(ID_COPY, '&Copy \tCtrl+C', 'Copy the selection') m.Append(ID_COPY_PLUS, 'Cop&y Plus \tCtrl+Shift+C', 'Copy the selection - retaining prompts') m.Append(ID_PASTE, '&Paste \tCtrl+V', 'Paste from clipboard') m.Append(ID_PASTE_PLUS, 'Past&e Plus \tCtrl+Shift+V', 'Paste and run commands') m.AppendSeparator() m.Append(ID_CLEAR, 'Cle&ar', 'Delete the selection') m.Append(ID_SELECTALL, 'Select A&ll \tCtrl+A', 'Select all text') m.AppendSeparator() m.Append(ID_EMPTYBUFFER, 'E&mpty Buffer...', 'Delete all the contents of the edit buffer') m.Append(ID_FIND, '&Find Text... \tCtrl+F', 'Search for text in the edit buffer') m.Append(ID_FINDNEXT, 'Find &Next \tCtrl+G', 'Find next instance of the search text') m.Append(ID_FINDPREVIOUS, 'Find Pre&vious \tCtrl+Shift+G', 'Find previous instance of the search text') # View m = self.viewMenu = wx.Menu() m.Append(ID_WRAP, '&Wrap Lines\tCtrl+Shift+W', 'Wrap lines at right edge', wx.ITEM_CHECK) m.Append(ID_SHOW_LINENUMBERS, '&Show Line Numbers\tCtrl+Shift+L', 'Show Line Numbers', wx.ITEM_CHECK) m.Append(ID_TOGGLE_MAXIMIZE, '&Toggle Maximize\tF11', 'Maximize/Restore Application') if hasattr(self, 'ToggleTools'): m.Append(ID_SHOWTOOLS, 'Show &Tools\tF4', 'Show the filling and other tools', wx.ITEM_CHECK) if self.shellName == ['PySlices', 'SymPySlices']: m.Append(ID_HIDEFOLDINGMARGIN, '&Hide Folding Margin', 'Hide Folding Margin', wx.ITEM_CHECK) # Options m = self.autocompMenu = wx.Menu() m.Append(ID_AUTOCOMP_SHOW, 'Show &Auto Completion\tCtrl+Shift+A', 'Show auto completion list', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_MAGIC, 'Include &Magic Attributes\tCtrl+Shift+M', 'Include attributes visible to __getattr__ and __setattr__', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_SINGLE, 'Include Single &Underscores\tCtrl+Shift+U', 'Include attibutes prefixed by a single underscore', wx.ITEM_CHECK) m.Append(ID_AUTOCOMP_DOUBLE, 'Include &Double Underscores\tCtrl+Shift+D', 'Include attibutes prefixed by a double underscore', wx.ITEM_CHECK) m = self.calltipsMenu = wx.Menu() m.Append(ID_CALLTIPS_SHOW, 'Show Call &Tips\tCtrl+Shift+T', 'Show call tips with argument signature and docstring', wx.ITEM_CHECK) m.Append(ID_CALLTIPS_INSERT, '&Insert Call Tips\tCtrl+Shift+I', '&Insert Call Tips', wx.ITEM_CHECK) m = self.optionsMenu = wx.Menu() m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, 'Auto Completion Options') m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, 'Call Tip Options') if wx.Platform == "__WXMAC__": m.Append(ID_USEAA, '&Use AntiAliasing', 'Use anti-aliased fonts', wx.ITEM_CHECK) m.AppendSeparator() self.historyMenu = wx.Menu() self.historyMenu.Append(ID_SAVEHISTORY, '&Autosave History', 'Automatically save history on close', wx.ITEM_CHECK) self.historyMenu.Append(ID_SAVEHISTORYNOW, '&Save History Now', 'Save history') self.historyMenu.Append(ID_CLEARHISTORY, '&Clear History ', 'Clear history') m.AppendMenu(-1, "&History", self.historyMenu, "History Options") self.startupMenu = wx.Menu() self.startupMenu.Append(ID_EXECSTARTUPSCRIPT, 'E&xecute Startup Script', 'Execute Startup Script', wx.ITEM_CHECK) self.startupMenu.Append(ID_EDITSTARTUPSCRIPT, '&Edit Startup Script...', 'Edit Startup Script') if self.shellName in ['PySlices', 'SymPySlices']: self.startupMenu.Append(ID_SHOWPYSLICESTUTORIAL, '&Show PySlices Tutorial', 'Show PySlices Tutorial', wx.ITEM_CHECK) m.AppendMenu(ID_STARTUP, '&Startup', self.startupMenu, 'Startup Options') self.settingsMenu = wx.Menu() if self.shellName in ['PySlices', 'SymPySlices']: self.settingsMenu.Append(ID_ENABLESHELLMODE, '&Enable Shell Mode', 'Enable Shell Mode', wx.ITEM_CHECK) if self.shellName == 'SymPySlices': self.settingsMenu.Append( ID_ENABLEAUTOSYMPY, '&Enable "Auto-Sympy" Conversions for Undefined Variables', 'Enable "Auto-Sympy" Conversions', wx.ITEM_CHECK) self.settingsMenu.Append(ID_AUTO_SAVESETTINGS, '&Auto Save Settings', 'Automatically save settings on close', wx.ITEM_CHECK) self.settingsMenu.Append(ID_SAVESETTINGS, '&Save Settings', 'Save settings now') self.settingsMenu.Append(ID_DELSETTINGSFILE, '&Revert to default', 'Revert to the default settings') m.AppendMenu(ID_SETTINGS, '&Settings', self.settingsMenu, 'Settings Options') m = self.helpMenu = wx.Menu() m.Append(ID_HELP, '&Help\tF1', 'Help!') m.AppendSeparator() m.Append(ID_ABOUT, '&About...', 'About this program') b = self.menuBar = wx.MenuBar() b.Append(self.fileMenu, '&File') b.Append(self.editMenu, '&Edit') b.Append(self.viewMenu, '&View') b.Append(self.optionsMenu, '&Options') b.Append(self.helpMenu, '&Help') self.SetMenuBar(b) self.Bind(wx.EVT_MENU, self.OnFileNew, id=ID_NEW) self.Bind(wx.EVT_MENU, self.OnFileOpen, id=ID_OPEN) self.Bind(wx.EVT_MENU, self.OnFileRevert, id=ID_REVERT) self.Bind(wx.EVT_MENU, self.OnFileClose, id=ID_CLOSE) self.Bind(wx.EVT_MENU, self.OnFileSave, id=ID_SAVE) self.Bind(wx.EVT_MENU, self.OnFileSaveAs, id=ID_SAVEAS) self.Bind(wx.EVT_MENU, self.OnFileSaveACopy, id=ID_SAVEACOPY) self.Bind(wx.EVT_MENU, self.OnFileUpdateNamespace, id=ID_NAMESPACE) self.Bind(wx.EVT_MENU, self.OnFilePrint, id=ID_PRINT) self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT) self.Bind(wx.EVT_MENU, self.OnUndo, id=ID_UNDO) self.Bind(wx.EVT_MENU, self.OnRedo, id=ID_REDO) self.Bind(wx.EVT_MENU, self.OnCut, id=ID_CUT) self.Bind(wx.EVT_MENU, self.OnCopy, id=ID_COPY) self.Bind(wx.EVT_MENU, self.OnCopyPlus, id=ID_COPY_PLUS) self.Bind(wx.EVT_MENU, self.OnPaste, id=ID_PASTE) self.Bind(wx.EVT_MENU, self.OnPastePlus, id=ID_PASTE_PLUS) self.Bind(wx.EVT_MENU, self.OnClear, id=ID_CLEAR) self.Bind(wx.EVT_MENU, self.OnSelectAll, id=ID_SELECTALL) self.Bind(wx.EVT_MENU, self.OnEmptyBuffer, id=ID_EMPTYBUFFER) self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_ABOUT) self.Bind(wx.EVT_MENU, self.OnHelp, id=ID_HELP) self.Bind(wx.EVT_MENU, self.OnAutoCompleteShow, id=ID_AUTOCOMP_SHOW) self.Bind(wx.EVT_MENU, self.OnAutoCompleteMagic, id=ID_AUTOCOMP_MAGIC) self.Bind(wx.EVT_MENU, self.OnAutoCompleteSingle, id=ID_AUTOCOMP_SINGLE) self.Bind(wx.EVT_MENU, self.OnAutoCompleteDouble, id=ID_AUTOCOMP_DOUBLE) self.Bind(wx.EVT_MENU, self.OnCallTipsShow, id=ID_CALLTIPS_SHOW) self.Bind(wx.EVT_MENU, self.OnCallTipsInsert, id=ID_CALLTIPS_INSERT) self.Bind(wx.EVT_MENU, self.OnWrap, id=ID_WRAP) self.Bind(wx.EVT_MENU, self.OnUseAA, id=ID_USEAA) self.Bind(wx.EVT_MENU, self.OnToggleMaximize, id=ID_TOGGLE_MAXIMIZE) self.Bind(wx.EVT_MENU, self.OnShowLineNumbers, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_MENU, self.OnEnableShellMode, id=ID_ENABLESHELLMODE) self.Bind(wx.EVT_MENU, self.OnEnableAutoSympy, id=ID_ENABLEAUTOSYMPY) self.Bind(wx.EVT_MENU, self.OnAutoSaveSettings, id=ID_AUTO_SAVESETTINGS) self.Bind(wx.EVT_MENU, self.OnSaveHistory, id=ID_SAVEHISTORY) self.Bind(wx.EVT_MENU, self.OnSaveHistoryNow, id=ID_SAVEHISTORYNOW) self.Bind(wx.EVT_MENU, self.OnClearHistory, id=ID_CLEARHISTORY) self.Bind(wx.EVT_MENU, self.OnSaveSettings, id=ID_SAVESETTINGS) self.Bind(wx.EVT_MENU, self.OnDelSettingsFile, id=ID_DELSETTINGSFILE) self.Bind(wx.EVT_MENU, self.OnEditStartupScript, id=ID_EDITSTARTUPSCRIPT) self.Bind(wx.EVT_MENU, self.OnExecStartupScript, id=ID_EXECSTARTUPSCRIPT) self.Bind(wx.EVT_MENU, self.OnShowPySlicesTutorial, id=ID_SHOWPYSLICESTUTORIAL) self.Bind(wx.EVT_MENU, self.OnFindText, id=ID_FIND) self.Bind(wx.EVT_MENU, self.OnFindNext, id=ID_FINDNEXT) self.Bind(wx.EVT_MENU, self.OnFindPrevious, id=ID_FINDPREVIOUS) self.Bind(wx.EVT_MENU, self.OnToggleTools, id=ID_SHOWTOOLS) self.Bind(wx.EVT_MENU, self.OnHideFoldingMargin, id=ID_HIDEFOLDINGMARGIN) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NEW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_OPEN) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_REVERT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLOSE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEAS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NAMESPACE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PRINT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_UNDO) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_REDO) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CUT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_COPY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_COPY_PLUS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PASTE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_PASTE_PLUS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLEAR) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SELECTALL) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EMPTYBUFFER) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_SHOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_MAGIC) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_SINGLE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTOCOMP_DOUBLE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CALLTIPS_SHOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CALLTIPS_INSERT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_WRAP) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_USEAA) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_ENABLESHELLMODE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_ENABLEAUTOSYMPY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_AUTO_SAVESETTINGS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVESETTINGS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_DELSETTINGSFILE) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EXECSTARTUPSCRIPT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOWPYSLICESTUTORIAL) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEHISTORY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SAVEHISTORYNOW) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_CLEARHISTORY) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EDITSTARTUPSCRIPT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FIND) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FINDNEXT) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FINDPREVIOUS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOWTOOLS) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_HIDEFOLDINGMARGIN) self.Bind(wx.EVT_ACTIVATE, self.OnActivate) self.Bind(wx.EVT_FIND, self.OnFindNext) self.Bind(wx.EVT_FIND_NEXT, self.OnFindNext) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
def __init__(self, option_data): # wx Initialization wx.Frame.__init__(self, None, title="SU2 config file editor") # Define the main sizers self.frame_sizer = wx.BoxSizer(wx.HORIZONTAL) self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.left_sizer = wx.BoxSizer(wx.VERTICAL) self.right_sizer = wx.BoxSizer(wx.VERTICAL) # Use a scrolled panel on the right side self.main_panel = wx.Panel(self) self.scroll_sizer = wx.BoxSizer(wx.VERTICAL) self.right_panel = sp.ScrolledPanel(self.main_panel, size=(500, 500)) self.right_panel.SetupScrolling() # Left side - list of option categories self.list_ctrl = wx.ListCtrl(self.main_panel, style=wx.LC_REPORT | wx.BORDER_SUNKEN, size=(300, 600)) self.list_ctrl.InsertColumn(0, 'Option Category') bigfont = wx.Font(20, wx.MODERN, wx.NORMAL, wx.BOLD) # Read the option_data and build controls self.ctrldict = {} self.optlabels = {} for j, category in enumerate(option_data): self.list_ctrl.InsertStringItem( j, category) # Add category to left size list self.optlabels[category] = wx.StaticText(self.right_panel, label=category) self.optlabels[category].SetFont(bigfont) if j > 0: self.scroll_sizer.AddSpacer(20) self.scroll_sizer.Add(self.optlabels[category], wx.EXPAND) self.ctrldict[category] = [] yctr = 0 for j, opt in enumerate(option_data[category]): if opt.option_type in [ "EnumOption", "MathProblem", "SpecialOption", "ConvectOption" ]: self.ctrldict[category].append( LabeledComboBox(self.right_panel, opt.option_name, opt.option_name, opt.option_default, opt.option_values, opt.option_type, opt.option_description)) else: self.ctrldict[category].append( LabeledTextCtrl(self.right_panel, opt.option_name, opt.option_name, opt.option_default, opt.option_type)) for control in self.ctrldict[category]: self.scroll_sizer.Add( control.GetSizer(), wx.EXPAND) # Add each control to the sizer self.lastctrl = control.GetCtrl() # Set right_panel to scroll vertically self.right_panel.SetSizer(self.scroll_sizer) # Set up menu menuBar = wx.MenuBar() m_file = wx.Menu() m_save = m_file.Append(wx.ID_SAVE, "&Save", "Save an SU2 .cfg file") m_open = m_file.Append(wx.ID_OPEN, "&Open", "Load an SU2 .cfg file") m_exit = m_file.Append(wx.ID_EXIT, "E&xit", "Close window and exit program.") menuBar.Append(m_file, "&File") self.SetMenuBar(menuBar) self.CreateStatusBar() # Specify which functions to call when stuff is changed self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_click, self.list_ctrl) self.Bind(wx.EVT_MENU, self.OnSave, m_save) self.Bind(wx.EVT_MENU, self.OnOpen, m_open) self.Bind(wx.EVT_SIZE, self.OnResize) self.right_panel.SetAutoLayout(1) # Add it all to the panel and draw self.left_sizer.SetMinSize((300, 600)) self.right_sizer.SetMinSize((300, 600)) self.list_ctrl.SetColumnWidth(0, 500) self.left_sizer.Add(self.list_ctrl, 0, wx.EXPAND) self.right_sizer.Add(self.right_panel, 0, wx.EXPAND) self.main_sizer.Add(self.left_sizer, 0, wx.EXPAND) self.main_sizer.Add(self.right_sizer, 0, wx.EXPAND) self.frame_sizer.Add(self.main_sizer, 0, wx.EXPAND) self.main_panel.SetSizer(self.main_sizer) self.SetSizer(self.frame_sizer) self.SetInitialSize()
def InitUI(self): #menus menubar = wx.MenuBar() fileMenu = wx.Menu() searchMenu = wx.Menu() carveMenu = wx.Menu() fileMenu.Append(ID_MENU_NEW, '&New') fileMenu.Append(ID_MENU_OPEN, '&Open') fileMenu.AppendSeparator() quit_menu_item = wx.MenuItem(fileMenu, APP_EXIT, '&Quit\tCtrl+C') fileMenu.AppendItem(quit_menu_item) carveMenu.Append(ID_MENU_CARVE_FILES, '&Files') carveMenu.Append(ID_MENU_CARVE_PARTITIONS, '&Partitions') searchMenu.Append(ID_MENU_SEARCH_FILES, '&Search Files') searchMenu.Append(ID_MENU_SEARCH_PARTITIONS, '&Search Partitions') menubar.Append(fileMenu, '&File') menubar.Append(searchMenu, '&Search') menubar.Append(carveMenu, '&Carve') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OverviewSetup, id=ID_MENU_NEW) self.Bind(wx.EVT_MENU, self.OverviewSetup, id=ID_MENU_OPEN) self.Bind(wx.EVT_MENU, self.OnQuit, quit_menu_item) self.Bind(wx.EVT_MENU, self.CarveFiles, id=ID_MENU_CARVE_FILES) #panels panel = wx.Panel(self) panel.SetBackgroundColour('#4f5049') grid = wx.GridBagSizer(3, 2) overview_label = wx.StaticText(panel, label="Overview") overview_label.SetForegroundColour('#FF8000') grid.Add(overview_label, pos=(0, 0), flag=wx.ALL | wx.ALIGN_CENTER, border=5) grid.AddGrowableCol(0) selection_label = wx.StaticText(panel, label="Selection") selection_label.SetForegroundColour('#FF8000') grid.Add(selection_label, pos=(0, 1), flag=wx.ALL | wx.ALIGN_CENTER, border=5) grid.AddGrowableCol(1) self.overview = ListWidthCtrl(panel, style=wx.LC_REPORT) self.overview.InsertColumn(0, 'No.', width=35) self.overview.InsertColumn(1, 'Name') grid.Add(self.overview, pos=(1, 0), flag=wx.LEFT | wx.EXPAND, border=10) self.selection = ListWidthCtrl(panel, style=wx.LC_REPORT | wx.LC_NO_HEADER) self.selection.InsertColumn(0, 'Field', width=100) self.selection.InsertColumn(1, 'Data') grid.Add(self.selection, pos=(1, 1), flag=wx.RIGHT | wx.EXPAND, border=10) grid.AddGrowableRow(1) self.details = ListWidthCtrl(panel, style=wx.LC_REPORT | wx.LC_NO_HEADER) self.details.InsertColumn(0, 'Details') grid.Add(self.details, pos=(2, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.CENTER | wx.EXPAND, border=10) grid.AddGrowableRow(2) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.GetDetails) panel.SetSizer(grid)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Gif-o-matic", pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.Size( 640,480 ), wx.DefaultSize ) self.m_main_menubar = wx.MenuBar( 0 ) self.m_file_menu = wx.Menu() self.m_open_file = wx.MenuItem( self.m_file_menu, wx.ID_ANY, u"Open video", wx.EmptyString, wx.ITEM_NORMAL ) self.m_file_menu.AppendItem( self.m_open_file ) self.m_save_gif = wx.MenuItem( self.m_file_menu, wx.ID_ANY, u"Save gif", wx.EmptyString, wx.ITEM_NORMAL ) self.m_file_menu.AppendItem( self.m_save_gif ) self.m_main_menubar.Append( self.m_file_menu, u"File" ) self.m_help_menu = wx.Menu() self.m_about = wx.MenuItem( self.m_help_menu, wx.ID_ANY, u"About", wx.EmptyString, wx.ITEM_NORMAL ) self.m_help_menu.AppendItem( self.m_about ) self.m_main_menubar.Append( self.m_help_menu, u"Help" ) self.SetMenuBar( self.m_main_menubar ) b_main_sizer = wx.BoxSizer( wx.VERTICAL ) self.m_frame_bitmap = wx.StaticBitmap( self, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_frame_bitmap.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) ) b_main_sizer.Add( self.m_frame_bitmap, 1, wx.ALL|wx.EXPAND, 5 ) self.m_frame_slider = wx.Slider( self, wx.ID_ANY, 0, 0, 0, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL ) b_main_sizer.Add( self.m_frame_slider, 0, wx.ALL|wx.EXPAND, 5 ) b_toolbar_sizer = wx.BoxSizer( wx.HORIZONTAL ) self.m_left_extreme_button = wx.Button( self, wx.ID_ANY, u"Set [", wx.DefaultPosition, wx.Size( 60,-1 ), 0 ) b_toolbar_sizer.Add( self.m_left_extreme_button, 0, wx.ALL, 5 ) self.m_right_extreme_button = wx.Button( self, wx.ID_ANY, u"Set ]", wx.DefaultPosition, wx.Size( 60,-1 ), 0 ) b_toolbar_sizer.Add( self.m_right_extreme_button, 0, wx.ALL, 5 ) b_toolbar_sizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_go_to_left_ext = wx.Button( self, wx.ID_ANY, u"Go to [", wx.DefaultPosition, wx.Size( 60,-1 ), 0 ) b_toolbar_sizer.Add( self.m_go_to_left_ext, 0, wx.ALL, 5 ) self.m_go_to_right_ext = wx.Button( self, wx.ID_ANY, u"Go to ]", wx.DefaultPosition, wx.Size( 60,-1 ), 0 ) b_toolbar_sizer.Add( self.m_go_to_right_ext, 0, wx.ALL, 5 ) b_toolbar_sizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_minus_10_button = wx.Button( self, wx.ID_ANY, u"<<", wx.DefaultPosition, wx.Size( 40,-1 ), 0 ) b_toolbar_sizer.Add( self.m_minus_10_button, 0, wx.ALL, 5 ) self.m_minus_1_button = wx.Button( self, wx.ID_ANY, u"<", wx.DefaultPosition, wx.Size( 40,-1 ), 0 ) b_toolbar_sizer.Add( self.m_minus_1_button, 0, wx.ALL, 5 ) self.m_plus_1_button = wx.Button( self, wx.ID_ANY, u">", wx.DefaultPosition, wx.Size( 40,-1 ), 0 ) b_toolbar_sizer.Add( self.m_plus_1_button, 0, wx.ALL, 5 ) self.m_plus_10_button = wx.Button( self, wx.ID_ANY, u">>", wx.DefaultPosition, wx.Size( 40,-1 ), 0 ) b_toolbar_sizer.Add( self.m_plus_10_button, 0, wx.ALL, 5 ) b_main_sizer.Add( b_toolbar_sizer, 0, wx.EXPAND, 5 ) bSizer3 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Max height (px)", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) bSizer3.Add( self.m_staticText1, 0, wx.ALL, 5 ) self.m_spin_resolution = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 60,-1 ), wx.SP_ARROW_KEYS, 0, 1080, 360 ) bSizer3.Add( self.m_spin_resolution, 0, wx.ALL, 5 ) bSizer3.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Fuzziness", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) bSizer3.Add( self.m_staticText2, 0, wx.ALL, 5 ) self.m_spin_fuzz = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 50,-1 ), wx.SP_ARROW_KEYS, 0, 100, 10 ) bSizer3.Add( self.m_spin_fuzz, 0, wx.ALL, 5 ) bSizer3.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Fps", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) bSizer3.Add( self.m_staticText3, 0, wx.ALL, 5 ) self.m_spin_fps = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 50,-1 ), wx.SP_ARROW_KEYS, 1, 120, 15 ) bSizer3.Add( self.m_spin_fps, 0, wx.ALL, 5 ) b_main_sizer.Add( bSizer3, 0, wx.EXPAND, 5 ) bSizer5 = wx.BoxSizer( wx.HORIZONTAL ) self.m_progress_bar = wx.Gauge( self, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL ) self.m_progress_bar.SetValue( 0 ) bSizer5.Add( self.m_progress_bar, 1, wx.ALL, 5 ) b_main_sizer.Add( bSizer5, 0, wx.EXPAND, 5 ) self.SetSizer( b_main_sizer ) self.Layout() b_main_sizer.Fit( self ) self.m_main_statusbar = self.CreateStatusBar( 3, wx.ST_SIZEGRIP, wx.ID_ANY ) self.Centre( wx.BOTH ) # Connect Events self.Bind( wx.EVT_MENU, self.open_file_dialog, id = self.m_open_file.GetId() ) self.Bind( wx.EVT_MENU, self.save_gif_dialog, id = self.m_save_gif.GetId() ) self.m_frame_slider.Bind( wx.EVT_SCROLL, self.scrollbar_draw ) self.m_frame_slider.Bind( wx.EVT_SCROLL_CHANGED, self.scrollbar_change ) self.m_left_extreme_button.Bind( wx.EVT_BUTTON, self.set_left_extreme ) self.m_right_extreme_button.Bind( wx.EVT_BUTTON, self.set_right_extreme ) self.m_go_to_left_ext.Bind( wx.EVT_BUTTON, self.go_to_left_extreme ) self.m_go_to_right_ext.Bind( wx.EVT_BUTTON, self.go_to_right_extreme ) self.m_minus_10_button.Bind( wx.EVT_BUTTON, self.rewind_10 ) self.m_minus_1_button.Bind( wx.EVT_BUTTON, self.rewind_1 ) self.m_plus_1_button.Bind( wx.EVT_BUTTON, self.forward_1 ) self.m_plus_10_button.Bind( wx.EVT_BUTTON, self.forward_10 )
def setup_frame(self): self.CreateStatusBar() self.Title = 'HDF5 File Import Wizard' panel = wx.Panel(self) menubar = wx.MenuBar() self.file_set = wx.Menu() self.file_set.Append(wx.ID_OPEN, 'Open CSV') self.file_set.Append(wx.ID_SAVE, 'Save CSV') self.file_set.AppendSeparator() self.iw_menu = self.file_set.Append(wx.ID_ANY, "Waters Conversion Wizard") self.file_set.AppendSeparator() self.file_set.Append(wx.ID_CLOSE, 'Close') menubar.Append(self.file_set, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.close, id=wx.ID_CLOSE) self.Bind(wx.EVT_MENU, self.import_file, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.export_file, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.on_conversion_wizard, self.iw_menu) # add box sizers hb01 = wx.BoxSizer(wx.HORIZONTAL) hb02 = wx.BoxSizer(wx.HORIZONTAL) hb04 = wx.BoxSizer(wx.HORIZONTAL) hb05 = wx.BoxSizer(wx.HORIZONTAL) # Mode which to import self.rb = wx.RadioBox(panel, wx.ID_ANY, "Mode", wx.DefaultPosition, wx.DefaultSize, ['Time', 'Scans'], 0) self.rb.SetToolTip(wx.ToolTip("How you want to parse data")) # folder path stuff self.folder_path = wx.TextCtrl(panel, wx.ID_ANY, FileDialogs.default_dir, size=(450, -1)) hb02.Add(self.folder_path, 0, wx.ALIGN_CENTRE_VERTICAL | wx.LEFT, border=5) hb02.Add(wx.Button(panel, 10, 'Browse'), 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=5) box = wx.StaticBoxSizer( wx.StaticBox(panel, wx.ID_ANY, 'Path to Data Folder'), wx.VERTICAL) box.Add(hb02) hb01.Add(self.rb, 0, wx.ALL, border=5) hb01.Add(box, 0, wx.ALL, border=5) # add my grid panel2 = wx.Panel(panel) self.my_grid = meta_import_wizard_grid.WizardGrid(panel, self) self.my_tree = meta_import_wizard_treectrl.TreeCtrlPanel(panel, self) self.tree = self.my_tree.tree hb04.Add(self.my_tree) hb04.Add(wx.StaticText(panel, wx.ID_ANY, '')) # now make comobox for various files self.desc = wx.TextCtrl(panel, wx.ID_ANY, '', size=(400, 300), style=wx.TE_MULTILINE) hb04.Add(self.desc, wx.ALL, border=10) # make buttons to add, auto, clear all hb05.Add(wx.Button(panel, 2, 'Add'), 0, wx.ALL, border=5) # hb05.Add(wx.Button(panel, 3, 'Auto'), wx.ALL | wx.ALIGN_LEFT | wx.TOP, 10) hb05.Add(wx.Button(panel, 4, 'Clear All'), 0, wx.TOP | wx.BOTTOM | wx.RIGHT, border=5) # make a box around the tree ctrl box2 = wx.StaticBoxSizer( wx.StaticBox(panel, wx.ID_ANY, 'File(s) to Convert'), wx.VERTICAL) box2.Add(hb04) box2.Add(hb05) box2.Add(self.my_grid, 1, wx.EXPAND | wx.ALL, border=5) bottom_btn_sizer = wx.BoxSizer(wx.HORIZONTAL) # bottom_btn_sizer.Add(wx.Button(panel, 7, 'Export Grid'), 0, wx.TOP | wx.BOTTOM | wx.RIGHT, border=5) bottom_btn_sizer.Add(wx.Button(panel, 8, 'Load All to HDF5'), 0, wx.TOP | wx.BOTTOM | wx.RIGHT, border=5) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(hb01, 0, wx.ALL, border=0) sizer.Add(box2, 1, wx.ALL, border=5) # sizer.Add(self.my_grid, 0, wx.EXPAND , border=5) # sizer.Add(wx.StaticText(panel, wx.ID_ANY, '')) sizer.Add(bottom_btn_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, border=0) # bind events self.Bind(wx.EVT_RADIOBOX, self.my_grid.EvtDriftType, self.rb) self.Bind(wx.EVT_BUTTON, self.get_folder_path, id=10) self.Bind(wx.EVT_BUTTON, self.add_file, id=2) self.Bind(wx.EVT_BUTTON, self.my_grid.clear_all, id=4) # self.Bind(wx.EVT_BUTTON, self.export_file, id=7) self.Bind(wx.EVT_BUTTON, self.auto, id=8) self.folder_path.Bind(wx.EVT_KEY_UP, self.on_folder_path_change) panel.SetSizerAndFit(sizer) self.fill_text_box() self.SetFocus() self.Centre()
def OnInit(self): wx.Log_SetActiveTarget(wx.LogStderr()) self.SetAssertMode(assertMode) self.Init() # InspectionMixin frame = wx.Frame(None, -1, "RunDemo: " + self.name, pos=(50, 50), size=(200, 100), style=wx.DEFAULT_FRAME_STYLE, name="run a sample") frame.CreateStatusBar() menuBar = wx.MenuBar() menu = wx.Menu() item = menu.Append(-1, "E&xit\tCtrl-Q", "Exit demo") self.Bind(wx.EVT_MENU, self.OnExitApp, item) menuBar.Append(menu, "&File") ns = {} ns['wx'] = wx ns['app'] = self ns['module'] = self.demoModule ns['frame'] = frame frame.SetMenuBar(menuBar) frame.Show(True) frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame) win = self.demoModule.runTest(frame, frame, Log()) # a window will be returned if the demo does not create # its own top-level window if win: # so set the frame to a good size for showing stuff frame.SetSize((640, 480)) win.SetFocus() self.window = win ns['win'] = win frect = frame.GetRect() else: # It was probably a dialog or something that is already # gone, so we're done. frame.Destroy() return True self.SetTopWindow(frame) self.frame = frame #wx.Log_SetActiveTarget(wx.LogStderr()) #wx.Log_SetTraceMask(wx.TraceMessages) if self.useShell: # Make a PyShell window, and position it below our test window from wx import py shell = py.shell.ShellFrame(None, locals=ns) frect.OffsetXY(0, frect.height) frect.height = 400 shell.SetRect(frect) shell.Show() # Hook the close event of the test window so that we close # the shell at the same time def CloseShell(evt): if shell: shell.Close() evt.Skip() frame.Bind(wx.EVT_CLOSE, CloseShell) return True
def __init__(self): wx.Frame.__init__(self, None, id=wx.ID_ANY, title=u"Zabbix 報警程序", pos=wx.DefaultPosition, size=wx.Size(300, 350), style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.TAB_TRAVERSAL) self.SetBackgroundColour('White') # --- Default self.data = chkfile('data.pkl') if not self.data["RedisServer"]: self.data["RedisServer"] = "127.0.0.1" self.rc = redis.StrictRedis(self.data["RedisServer"]) # --- Menu self.m_menubar = wx.MenuBar(0) self.Menu = wx.Menu() self.menuSetting = wx.MenuItem(self.Menu, 1, u"RedisServer", help="") self.Menu.AppendItem(self.menuSetting) self.menuItem1 = wx.MenuItem(self.Menu, 2, u"服務器管理", help="") self.Menu.AppendItem(self.menuItem1) self.m_menubar.Append(self.Menu, u"設定") self.SetMenuBar(self.m_menubar) # --- 系統時間 self.Label_Nowtime = wx.StaticText(self, wx.ID_ANY, time.strftime("%Y/%m/%d %H:%M:%S"), (30, 5), wx.Size(-1, -1), 0) self.Label_Nowtime.SetFont(wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)) # --- RedisServer wx.StaticText(self, 1, "Redis Server:", (15, 50), (-1, -1)).SetFont( wx.Font(14, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)) self.Label_RedisServer = wx.StaticText(self, 1, self.data["RedisServer"], (150, 50), (-1, -1)) self.Label_RedisServer.SetFont( wx.Font(14, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)) # --- Button # BtnPos = [(60, 80),(150, 80),(60, 160),(150, 160)] self.Btn1 = wx.Button(self, wx.ID_ANY, "", (60, 120), wx.Size(60, 60), 0) self.Btn2 = wx.Button(self, wx.ID_ANY, "", (150, 120), wx.Size(60, 60), 0) self.Btn3 = wx.Button(self, wx.ID_ANY, "", (60, 200), wx.Size(60, 60), 0) self.Btn4 = wx.Button(self, wx.ID_ANY, "", (150, 200), wx.Size(60, 60), 0) self.Group_Btn = [self.Btn1, self.Btn2, self.Btn3, self.Btn4] [i.Hide() for i in self.Group_Btn] [i.SetName("0") for i in self.Group_Btn] # --- StaticText self.Label_RadisStatus = wx.StaticText(self, wx.ID_ANY, u"Redis服務器無法連接", (50, 120), wx.Size(-1, -1), 0) self.Label_RadisStatus.SetFont(wx.Font(14, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)) self.Label_RadisStatus.SetForegroundColour(wx.RED) self.Label_RadisStatus.Hide() # --- 監控項目 self.Label_itemtitle = wx.StaticText(self, 1, u"監控項目", (90, 85), (-1, -1)) self.Label_itemtitle.SetFont(wx.Font(14, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)) # 啟動 self.createTimer() self.bindMenuEvent() self.chkredis(self.rc)
def __init__(self, parent, id, log): wx.Frame.__init__(self, parent, id, 'Playing with menus', size=(500, 250)) self.log = log self.CenterOnScreen() self.CreateStatusBar() self.SetStatusText("This is the statusbar") tc = wx.TextCtrl(self, -1, """ A bunch of bogus menus have been created for this frame. You can play around with them to see how they behave and then check the source for this sample to see how to implement them. """, style=wx.TE_READONLY | wx.TE_MULTILINE) # Prepare the menu bar menuBar = wx.MenuBar() # 1st menu from left menu1 = wx.Menu() menu1.Append(101, "&Mercury", "This the text in the Statusbar") menu1.Append(102, "&Venus", "") menu1.Append(103, "&Earth", "You may select Earth too") menu1.AppendSeparator() menu1.Append(104, "&Close", "Close this frame") # Add menu to the menu bar menuBar.Append(menu1, "&Planets") # 2nd menu from left menu2 = wx.Menu() menu2.Append(201, "Hydrogen") menu2.Append(202, "Helium") # a submenu in the 2nd menu submenu = wx.Menu() submenu.Append(2031, "Lanthanium") submenu.Append(2032, "Cerium") submenu.Append(2033, "Praseodymium") menu2.AppendMenu(203, "Lanthanides", submenu) # Append 2nd menu menuBar.Append(menu2, "&Elements") menu3 = wx.Menu() # Radio items menu3.Append(301, "IDLE", "a Python shell using tcl/tk as GUI", wx.ITEM_RADIO) menu3.Append(302, "PyCrust", "a Python shell using wxPython as GUI", wx.ITEM_RADIO) menu3.Append(303, "psi", "a simple Python shell using wxPython as GUI", wx.ITEM_RADIO) menu3.AppendSeparator() menu3.Append(304, "project1", "", wx.ITEM_NORMAL) menu3.Append(305, "project2", "", wx.ITEM_NORMAL) menuBar.Append(menu3, "&Shells") menu4 = wx.Menu() # Check menu items menu4.Append(401, "letters", "abcde...", wx.ITEM_CHECK) menu4.Append(402, "digits", "123...", wx.ITEM_CHECK) menu4.Append(403, "letters and digits", "abcd... + 123...", wx.ITEM_CHECK) menuBar.Append(menu4, "Chec&k") menu5 = wx.Menu() # Show how to put an icon in the menu item = wx.MenuItem(menu5, 500, "&Smile!\tCtrl+S", "This one has an icon") item.SetBitmap(images.Smiles.GetBitmap()) menu5.AppendItem(item) # Shortcuts menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!") menu5.AppendSeparator() menu5.Append(502, "Hello\tShift+H") menu5.AppendSeparator() menu5.Append(503, "remove the submenu") menu6 = wx.Menu() menu6.Append(601, "Submenu Item") menu5.AppendMenu(504, "submenu", menu6) menu5.Append(505, "remove this menu") menu5.Append(506, "this is updated") menu5.Append(507, "insert after this...") menu5.Append(508, "...and before this") menuBar.Append(menu5, "&Fun") self.SetMenuBar(menuBar) # Menu events self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight) self.Bind(wx.EVT_MENU, self.Menu101, id=101) self.Bind(wx.EVT_MENU, self.Menu102, id=102) self.Bind(wx.EVT_MENU, self.Menu103, id=103) self.Bind(wx.EVT_MENU, self.CloseWindow, id=104) self.Bind(wx.EVT_MENU, self.Menu201, id=201) self.Bind(wx.EVT_MENU, self.Menu202, id=202) self.Bind(wx.EVT_MENU, self.Menu2031, id=2031) self.Bind(wx.EVT_MENU, self.Menu2032, id=2032) self.Bind(wx.EVT_MENU, self.Menu2033, id=2033) self.Bind(wx.EVT_MENU, self.Menu301To303, id=301) self.Bind(wx.EVT_MENU, self.Menu301To303, id=302) self.Bind(wx.EVT_MENU, self.Menu301To303, id=303) self.Bind(wx.EVT_MENU, self.Menu304, id=304) self.Bind(wx.EVT_MENU, self.Menu305, id=305) # Range of menu items self.Bind(wx.EVT_MENU_RANGE, self.Menu401To403, id=401, id2=403) self.Bind(wx.EVT_MENU, self.Menu500, id=500) self.Bind(wx.EVT_MENU, self.Menu501, id=501) self.Bind(wx.EVT_MENU, self.Menu502, id=502) self.Bind(wx.EVT_MENU, self.TestRemove, id=503) self.Bind(wx.EVT_MENU, self.TestRemove2, id=505) self.Bind(wx.EVT_MENU, self.TestInsert, id=507) self.Bind(wx.EVT_MENU, self.TestInsert, id=508) wx.GetApp().Bind(wx.EVT_UPDATE_UI, self.TestUpdateUI, id=506)
def CreateMenuBar(self): self._menuBar = wx.MenuBar(wx.MB_DOCKABLE) self._fileMenu = wx.Menu() self._editMenu = wx.Menu() self._visualMenu = wx.Menu() item = wx.MenuItem(self._fileMenu, wx.ID_ANY, "&Close\tCtrl-Q", "Close demo window") self.Bind(wx.EVT_MENU, self.OnQuit, item) self._fileMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADD_PAGE, "New Page\tCtrl+N", "Add New Page") self.Bind(wx.EVT_MENU, self.OnAddPage, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_PAGE, "Delete Page\tCtrl+F4", "Delete Page") self.Bind(wx.EVT_MENU, self.OnDeletePage, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_DELETE_ALL, "Delete All Pages", "Delete All Pages") self.Bind(wx.EVT_MENU, self.OnDeleteAll, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_SET_SELECTION, "Set Selection", "Set Selection") self.Bind(wx.EVT_MENU, self.OnSetSelection, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_FWD, "Advance Selection Forward", "Advance Selection Forward") self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionFwd, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_EDIT_ADVANCE_SELECTION_BACK, "Advance Selection Backward", "Advance Selection Backward") self.Bind(wx.EVT_MENU, self.OnAdvanceSelectionBack, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_SET_ALL_TABS_SHAPE_ANGLE, "Set an inclination of tab header borders", "Set the shape of tab header") self.Bind(wx.EVT_MENU, self.OnSetAllPagesShapeAngle, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_SET_PAGE_IMAGE_INDEX, "Set image index of selected page", "Set image index") self.Bind(wx.EVT_MENU, self.OnSetPageImage, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_SHOW_IMAGES, "Show Images", "Show Images", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnShowImages, item) self._editMenu.AppendItem(item) styleMenu = wx.Menu() item = wx.MenuItem(styleMenu, MENU_USE_DEFAULT_STYLE, "Use Default Style", "Use VC71 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnDefaultStyle, item) styleMenu.AppendItem(item) item = wx.MenuItem(styleMenu, MENU_USE_VC71_STYLE, "Use VC71 Style", "Use VC71 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnVC71Style, item) styleMenu.AppendItem(item) item = wx.MenuItem(styleMenu, MENU_USE_VC8_STYLE, "Use VC8 Style", "Use VC8 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnVC8Style, item) styleMenu.AppendItem(item) item = wx.MenuItem(styleMenu, MENU_USE_FANCY_STYLE, "Use Fancy Style", "Use Fancy Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnFancyStyle, item) styleMenu.AppendItem(item) item = wx.MenuItem(styleMenu, MENU_USE_FF2_STYLE, "Use Firefox 2 Style", "Use Firefox 2 Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnFF2Style, item) styleMenu.AppendItem(item) item = wx.MenuItem(styleMenu, MENU_USE_RIBBON_STYLE, "Use Ribbon Style", "Use Ribbon Style", wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.OnRibbonStyle, item) styleMenu.AppendItem(item) self._visualMenu.AppendMenu(wx.ID_ANY, "Tabs Style", styleMenu) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_FROM, "Select fancy tab style 'from' colour", "Select fancy tab style 'from' colour") self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_TO, "Select fancy tab style 'to' colour", "Select fancy tab style 'to' colour") self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOUR_BORDER, "Select fancy tab style 'border' colour", "Select fancy tab style 'border' colour") self._visualMenu.AppendItem(item) self._editMenu.AppendSeparator() self.Bind(wx.EVT_MENU_RANGE, self.OnSelectColour, id=MENU_SELECT_GRADIENT_COLOUR_FROM, id2=MENU_SELECT_GRADIENT_COLOUR_BORDER) item = wx.MenuItem(self._editMenu, MENU_HIDE_ON_SINGLE_TAB, "Hide Page Container when only one Tab", "Hide Page Container when only one Tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.AppendItem(item) item = wx.MenuItem( self._editMenu, MENU_HIDE_TABS, "Hide Tabs", "Hide Page Container allowing only keyboard navigation", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_NO_TABS_FOCUS, "No focus on notebook tabs", "No focus on notebook tabs, only pages", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_HIDE_NAV_BUTTONS, "Hide Navigation Buttons", "Hide Navigation Buttons", wx.ITEM_CHECK) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_HIDE_X, "Hide X Button", "Hide X Button", wx.ITEM_CHECK) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_SMART_TABS, "Smart tabbing", "Smart tabbing", wx.ITEM_CHECK) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnSmartTabs, item) item.Check(False) item = wx.MenuItem(self._editMenu, MENU_USE_DROP_ARROW_BUTTON, "Use drop down button for tab navigation", "Use drop down arrow for quick tab navigation", wx.ITEM_CHECK) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnDropDownArrow, item) item.Check(False) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_TILE_HORIZONTALLY, "Tile pages horizontally", "Tile all the panels in an horizontal sizer", wx.ITEM_RADIO) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item = wx.MenuItem(self._editMenu, MENU_TILE_VERTICALLY, "Tile pages vertically", "Tile all the panels in a vertical sizer", wx.ITEM_RADIO) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item = wx.MenuItem(self._editMenu, MENU_TILE_NONE, "No tiling", "No tiling, standard FlatNotebook behaviour", wx.ITEM_RADIO) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnTile, item) item.Check(True) self._editMenu.AppendSeparator() item = wx.MenuItem( self._editMenu, wx.ID_ANY, "Use custom page", "Shows a custom page when the main notebook has no pages left", wx.ITEM_CHECK) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnCustomPanel, item) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_USE_MOUSE_MIDDLE_BTN, "Use Mouse Middle Button as 'X' button", "Use Mouse Middle Button as 'X' button", wx.ITEM_CHECK) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_DCLICK_CLOSES_TAB, "Mouse double click closes tab", "Mouse double click closes tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnDClickCloseTab, item) self._editMenu.AppendItem(item) item.Check(False) self._editMenu.AppendSeparator() item = wx.MenuItem(self._editMenu, MENU_USE_BOTTOM_TABS, "Use Bottoms Tabs", "Use Bottoms Tabs", wx.ITEM_CHECK) self._editMenu.AppendItem(item) self.Bind(wx.EVT_MENU_RANGE, self.OnStyle, id=MENU_HIDE_X, id2=MENU_USE_BOTTOM_TABS) item = wx.MenuItem(self._editMenu, MENU_ENABLE_TAB, "Enable Tab", "Enable Tab") self.Bind(wx.EVT_MENU, self.OnEnableTab, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_DISABLE_TAB, "Disable Tab", "Disable Tab") self.Bind(wx.EVT_MENU, self.OnDisableTab, item) self._editMenu.AppendItem(item) item = wx.MenuItem(self._editMenu, MENU_ENABLE_DRAG_N_DROP, "Enable Drag And Drop of Tabs", "Enable Drag And Drop of Tabs", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnEnableDrag, item) self._editMenu.AppendItem(item) item.Check(False) item = wx.MenuItem( self._editMenu, MENU_ALLOW_FOREIGN_DND, "Enable Drag And Drop of Tabs from foreign notebooks", "Enable Drag And Drop of Tabs from foreign notebooks", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnAllowForeignDnd, item) self._editMenu.AppendItem(item) item.Check(False) item = wx.MenuItem(self._visualMenu, MENU_DRAW_BORDER, "Draw Border around tab area", "Draw Border around tab area", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnStyle, item) self._visualMenu.AppendItem(item) item.Check(True) item = wx.MenuItem(self._visualMenu, MENU_DRAW_TAB_X, "Draw X button On Active Tab", "Draw X button On Active Tab", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnDrawTabX, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SET_ACTIVE_TAB_COLOUR, "Select Active Tab Colour", "Select Active Tab Colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SET_TAB_AREA_COLOUR, "Select Tab Area Colour", "Select Tab Area Colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SET_ACTIVE_TEXT_COLOUR, "Select active tab text colour", "Select active tab text colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_SELECT_NONACTIVE_TEXT_COLOUR, "Select NON-active tab text colour", "Select NON-active tab text colour") self.Bind(wx.EVT_MENU, self.OnSelectColour, item) self._visualMenu.AppendItem(item) item = wx.MenuItem(self._visualMenu, MENU_GRADIENT_BACKGROUND, "Use Gradient Colouring for tab area", "Use Gradient Colouring for tab area", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnGradientBack, item) self._visualMenu.AppendItem(item) item.Check(False) item = wx.MenuItem(self._visualMenu, MENU_COLOURFUL_TABS, "Colourful tabs", "Colourful tabs", wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnColourfulTabs, item) self._visualMenu.AppendItem(item) item.Check(False) help_menu = wx.Menu() item = wx.MenuItem(help_menu, wx.ID_ANY, "About...", "Shows The About Dialog") self.Bind(wx.EVT_MENU, self.OnAbout, item) help_menu.AppendItem(item) self._menuBar.Append(self._fileMenu, "&File") self._menuBar.Append(self._editMenu, "&Edit") self._menuBar.Append(self._visualMenu, "&Tab Appearance") self._menuBar.Append(help_menu, "&Help") self.SetMenuBar(self._menuBar)
0, wx.EXPAND | wx.ALL, border=10) sizer.Add(nuevopanel, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(HeadLow.Low(self.topanel), 0, wx.EXPAND | wx.ALL, border=10) self.topanel.SetSizer(self.sizer) self.father.SetSizer(sizer) self.father.GetSizer().Layout() self.father.Fit() app = wx.App(False) displaySize = wx.DisplaySize() frame = wx.Frame(None, wx.ID_ANY, 'ZUHÉ - UD', pos=(0, 0), size=(displaySize[0], displaySize[1])) menubar = wx.MenuBar() topPanel = scrolled.ScrolledPanel(frame) topPanel.SetupScrolling(scroll_y=True) topPanel.SetBackgroundColour('3399FF') sizertopPanel = wx.BoxSizer(wx.VERTICAL) sizertopPanel.Add(HeadLow.Head(topPanel), 0, wx.EXPAND | wx.ALL, border=10) sizertopPanel.Add(Body(topPanel), 0, wx.EXPAND | wx.ALL, border=10) sizertopPanel.Add(HeadLow.Low(topPanel), 0, wx.EXPAND | wx.ALL, border=10) topPanel.SetSizer(sizertopPanel) frame.Show() app.MainLoop()
def __init__(self, title): self.player = PitchPlayer() self.selected_tone = None wx.Frame.__init__(self, None, title=title, pos=(150, 150), size=(600, 850)) self.Bind(wx.EVT_CLOSE, self.OnClose) menuBar = wx.MenuBar() menu = wx.Menu() m_exit = menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Close window and exit program.") self.Bind(wx.EVT_MENU, self.OnClose, m_exit) menuBar.Append(menu, "&File") menu = wx.Menu() self.SetMenuBar(menuBar) self.statusbar = self.CreateStatusBar() panel = wx.Panel(self) box = wx.BoxSizer(wx.VERTICAL) m_text = wx.StaticText(panel, -1, "Sone of a pitch") m_text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)) m_text.SetSize(m_text.GetBestSize()) box.Add(m_text, 0, wx.ALL, 10) topp = wx.BoxSizer(wx.HORIZONTAL) topp.Add((10, -1)) topp.Add(wx.StaticText(panel, -1, "A4 (Hz) = ")) self.basepitch = wx.TextCtrl(panel, -1, "415", size=(175, -1)) self.basepitch.Bind(wx.EVT_TEXT, self.textChange) topp.Add(self.basepitch) box.Add((-1, 10)) box.Add(topp) topp = wx.BoxSizer(wx.HORIZONTAL) topp.Add((10, -1)) self.sound_base = wx.CheckBox(panel, label='Play A sound too') self.sound_base.Bind(wx.EVT_CHECKBOX, self.onCheckBox) topp.Add(self.sound_base) box.Add(topp) box.Add((-1, 10)) self.temperchoice = wx.RadioBox(panel, label='Temperament', choices=temperaments, majorDimension=1) self.temperchoice.Bind(wx.EVT_RADIOBOX, self.onRootChange) self.temperament = "quarter-comma meantone" box.Add(self.temperchoice) topp = wx.BoxSizer(wx.HORIZONTAL) topp.Add((10, -1)) rootp = wx.BoxSizer(wx.VERTICAL) rootp.Add(wx.StaticText(panel, -1, "Root")) self.root_notes = [] for i, pitch in enumerate(pitches): lbl = " %s " % pitch if i == 0: rb = wx.RadioButton(panel, i, label=lbl, style=wx.RB_GROUP) else: rb = wx.RadioButton(panel, i, label=lbl) rb.Bind(wx.EVT_RADIOBUTTON, self.onRootChange) rb.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)) self.root_notes.append(rb) #grid.Add( (15,-1) ) rootp.Add(rb) topp.Add(rootp) topp.Add((20, -1)) octp = wx.BoxSizer(wx.HORIZONTAL) octp.Add((10, -1)) octp.Add(wx.StaticText(panel, -1, "Octave")) self.octcorr = wx.TextCtrl(panel, -1, "4", size=(50, -1)) self.octcorr.Bind(wx.EVT_TEXT, self.textChange) octp.Add(self.octcorr) self.incrb = wx.Button(panel, wx.ID_ADD, "+", size=(25, -1)) self.incrb.Bind(wx.EVT_BUTTON, self.onOctaveChange) self.decrb = wx.Button(panel, wx.ID_DELETE, "-", size=(25, -1)) self.decrb.Bind(wx.EVT_BUTTON, self.onOctaveChange) octp.Add(self.decrb) octp.Add(self.incrb) topp.Add(octp) topp.Add((20, -1)) grid = wx.GridSizer(12, 4, 10, 10) self.pitchnames = [] self.freqrat = [] self.centlabels = [] self.hzs = [] for i, pitch in enumerate(pitches): lbl = " %s " % pitch rb = wx.CheckBox(panel, i, label=lbl, size=(100, -1)) #if i==0: # rb = wx.RadioButton(panel,i, label =lbl,style = wx.RB_GROUP) #else: # rb = wx.RadioButton(panel,i, label =lbl) rb.Bind(wx.EVT_CHECKBOX, self.onRadioGroup) rb.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD)) #grid.Add( (15,-1) ) self.pitchnames.append(rb) grid.Add(rb) rat = wx.StaticText(panel, -1, pitch) self.freqrat.append(rat) grid.Add(rat) rat = wx.StaticText(panel, -1, pitch) self.centlabels.append(rat) grid.Add(rat) rat = wx.StaticText(panel, -1, pitch) self.hzs.append(rat) grid.Add(rat) topp.Add(grid) box.Add(topp) butp = wx.BoxSizer(wx.HORIZONTAL) m_play = wx.Button(panel, wx.ID_CLOSE, "Play") m_play.Bind(wx.EVT_BUTTON, self.ClickPlay) butp.Add(m_play, 0, wx.ALL, 10) m_stop = wx.Button(panel, wx.ID_CLOSE, "Stop") m_stop.Bind(wx.EVT_BUTTON, self.StopPlay) butp.Add(m_stop, 0, wx.ALL, 10) m_close = wx.Button(panel, wx.ID_CLOSE, "Close") m_close.Bind(wx.EVT_BUTTON, self.OnClose) butp.Add(m_close, 0, wx.ALL, 10) box.Add(butp) panel.SetSizer(box) panel.Layout() self.update_from_root() self.update_freqrat()
def preview(self, widget, position=None): """Generate and instantiate preview widget. None will be returned in case of errors. The error details are written to the application log file.""" preview_filename = self._get_preview_filename() if preview_filename is None: return if wx.Platform == "__WXMAC__" and not compat.PYTHON2: # workaround for Mac OS testing: sometimes the caches need to be invalidated import importlib importlib.invalidate_caches() # make a valid name for the class (this can be invalid for some sensible reasons...) preview_classname = widget.klass.split('.')[-1].split(':')[-1] # randomize the class name to make preview work when there are multiple classes with the same name (e.g. XRC) preview_classname = '_%d_%s' % (random.randrange(10**8, 10** 9), preview_classname) widget.properties["class"].set_temp(preview_classname) frame = None try: self.generate_code(True, preview_filename, widget) # import generated preview module dynamically preview_path = os.path.dirname(preview_filename) preview_module_name = os.path.basename(preview_filename) preview_module_name = os.path.splitext(preview_module_name)[0] preview_module = plugins.import_module(preview_path, preview_module_name) if not preview_module: misc.error_message( _('Can not import the preview module from file \n"%s".\n' 'The details are written to the log file.\n' 'If you think this is a wxGlade bug, please report it.') % self.output_path) return None try: preview_class = getattr(preview_module, preview_classname) # .klass) except AttributeError: # module loade previously -> do a re-load XXX this is required for Python 3; check alternatives import importlib preview_module = importlib.reload(preview_module) preview_class = getattr(preview_module, preview_classname) if not preview_class: misc.error_message( _('No preview class "%s" found.\nThe details are written to the log file.\n' 'If you think this is a wxGlade bug, please report it.') % widget.klass) return None if issubclass(preview_class, wx.MDIChildFrame): frame = wx.MDIParentFrame(None, -1, '') frame.SetMenuBar(wx.MenuBar()) # avoid assertion error child = preview_class(frame, -1, '') child.SetTitle('<Preview> - ' + child.GetTitle()) w, h = child.GetSize() frame.SetClientSize((w + 20, h + 20)) elif not issubclass(preview_class, (wx.Frame, wx.Dialog)): # the toplevel class isn't really toplevel, add a frame... frame = wx.Frame(None, -1, widget.klass) if issubclass(preview_class, wx.MenuBar): menubar = preview_class() frame.SetMenuBar(menubar) panel = wx.Panel(frame) elif issubclass(preview_class, wx.ToolBar): toolbar = preview_class(frame, -1) frame.SetToolBar(toolbar) panel = wx.Panel(frame) frame.SetMinSize(toolbar.GetBestSize()) frame.Fit() else: panel = preview_class(frame, -1) frame.Fit() else: frame = preview_class(None, -1, '') def on_close(event): frame.Unbind(wx.EVT_CHAR_HOOK) compat.DestroyLater(frame) widget.preview_widget = None widget.properties["preview"].set_label(_('Show Preview')) frame.Bind(wx.EVT_CLOSE, on_close) frame.SetTitle(_('<Preview> - %s') % frame.GetTitle()) # raise the frame if position: frame.SetPosition(position) else: frame.CenterOnScreen() if widget.widget: # avoid Design and Preview window at the same position pos = widget.widget.GetPosition() if frame.GetPosition() == pos: frame.SetPosition((pos[0] + 200, pos[1] + 100)) frame.Show() # install handler for key down events frame.Bind(wx.EVT_CHAR_HOOK, self.on_char_hook) # remove the temporary file if not config.debugging: name = os.path.join(preview_path, preview_module_name + ".py") if os.path.isfile(name): os.unlink(name) except Exception as inst: if config.debugging or config.testing: raise widget.preview_widget = None widget.properties["preview"].set_label(_('Show Preview')) bugdialog.Show(_("Generate Preview"), inst) return frame
def __init__(self): if DEBUG: print("CremerGroupAppFrame.__init__()") ### init frame wPos = [0, 25] wg = wx.Display(0).GetGeometry() wSz = (int(wg[2] * 0.333), int(wg[3] * 0.5)) wx.Frame.__init__( self, None, -1, "CremerGroupApp v.%s" % (__version__), pos=tuple(wPos), size=tuple(wSz), style=wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX), ) self.SetBackgroundColour('#333333') iconPath = path.join(FPATH, "icon.png") if path.isfile(iconPath): self.SetIcon(wx.Icon(iconPath)) # set app icon ##### [begin] setting up attributes ----- self.wPos = wPos # window position self.wSz = wSz # window size self.fonts = getWXFonts(initFontSz=8, numFonts=3) pi = self.setPanelInfo() self.pi = pi # pnael information self.gbs = {} # for GridBagSizer self.panel = {} # panels self.timer = {} # timers self.chosenAppIdx = 0 self.appNames = [] # names of apps self.appDesc = [] # description string for each app for p in sorted(glob(path.join(FPATH, "*"))): if path.isdir(p) and path.isfile(path.join(p, "__init__.py")): dirName = path.basename(p) self.appNames.append(dirName) # store app name # it should be as same as its containing folder name ### get description of the file, ### which should be located at top of the file. appFilePath = path.join(p, "%s.py" % (dirName)) fh = open(appFilePath, "r") lines = fh.readlines() fh.close() isInitCommentStarted = False desc = "" for line in lines: if line[:3] in ["\"\"\"", "'''"]: # multiline comment if not isInitCommentStarted: # comment starting isInitCommentStarted = True line = line[3:] else: # comment ended break if isInitCommentStarted: desc += line # store description self.appDesc.append(desc) ##### [end] setting up attributes ----- ### create panels for pk in pi.keys(): self.panel[pk] = SPanel.ScrolledPanel( self, name="%s_panel" % (pk), pos=pi[pk]["pos"], size=pi[pk]["sz"], style=pi[pk]["style"], ) self.panel[pk].SetBackgroundColour(pi[pk]["bgCol"]) ##### [begin] set up top panel interface ----- tpSz = pi["tp"]["sz"] self.gbs["tp"] = wx.GridBagSizer(0, 0) row = 0 col = 0 sTxt = setupStaticText(self.panel["tp"], label="App: ", font=self.fonts[1], fgColor="#cccccc", bgColor="#333333") add2gbs(self.gbs["tp"], sTxt, (row, col), (1, 1)) col += 1 cho = wx.Choice(self.panel["tp"], -1, name="app_cho", size=(200, -1), choices=self.appNames) cho.Bind(wx.EVT_CHOICE, self.onChoice) cho.SetSelection(0) self.chosenAppIdx = 0 add2gbs(self.gbs["tp"], cho, (row, col), (1, 1)) col += 1 btn = wx.Button(self.panel["tp"], -1, label="What's this app?", size=(150, -1), name="desc_btn") btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown) add2gbs(self.gbs["tp"], btn, (row, col), (1, 1)) col += 1 btn = wx.Button(self.panel["tp"], -1, label="Run App", size=(100, -1), name="runApp_btn") btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown) add2gbs(self.gbs["tp"], btn, (row, col), (1, 1)) self.panel["tp"].SetSizer(self.gbs["tp"]) self.gbs["tp"].Layout() self.panel["tp"].SetupScrolling() ##### [end] set up top panel interface ----- ##### [begin] set up bottom panel interface ----- bpSz = pi["bp"]["sz"] self.gbs["bp"] = wx.GridBagSizer(0, 0) row = 0 col = 0 self.desc_txt = wx.TextCtrl(self.panel["bp"], value="", size=(bpSz[0] - 4, bpSz[1] - tpSz[1]), style=wx.TE_READONLY | wx.TE_MULTILINE) self.desc_txt.SetForegroundColour("#cccccc") self.desc_txt.SetFont(self.fonts[2]) add2gbs(self.gbs["bp"], self.desc_txt, (row, col), (1, 1)) self.panel["bp"].SetSizer(self.gbs["bp"]) self.gbs["bp"].Layout() self.panel["bp"].SetupScrolling() ##### [end] set up bottom panel interface ----- ### set up menu menuBar = wx.MenuBar() pyABCMenu = wx.Menu() quitItem = pyABCMenu.Append(wx.Window.NewControlId(), item="Quit\tCTRL+Q") menuBar.Append(pyABCMenu, "&CremerGroupApp") self.Bind(wx.EVT_MENU, self.onClose, quitItem) self.SetMenuBar(menuBar) ### keyboard binding exitId = wx.NewIdRef(count=1) self.Bind(wx.EVT_MENU, self.onClose, id=exitId) accel_tbl = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('Q'), exitId), ]) self.SetAcceleratorTable(accel_tbl) ### set up status-bar self.statusbar = self.CreateStatusBar(1) self.sbBgCol = self.statusbar.GetBackgroundColour() self.timer["sb"] = None updateFrameSize(self, wSz) self.Bind(wx.EVT_CLOSE, self.onClose)
def InitUI(self): # build a menu menubar = wx.MenuBar() fileMenu = wx.Menu() fitem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit Application') menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnQuit, fitem) # 1st: build a panel panel = wx.Panel(self) # 2nd: build a vertical box vbox = wx.BoxSizer(wx.VERTICAL) # 3rd: build a horizontal box inside the vertical one hbox1 = wx.BoxSizer(wx.HORIZONTAL) # set a label label1 = wx.StaticText(panel, label='Set Domain') # set a scanner right to the static label hbox1.Add(label1, flag=wx.RIGHT, border=10) urlField = wx.TextCtrl(panel, value='Enter your url') self.Bind(wx.EVT_TEXT, self.OnTypeText, id=urlField.GetId()) hbox1.Add(urlField, proportion=5) vbox.Add(hbox1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=10) vbox.Add((-1, 10)) # 4th: build another horizontal box inside the vertical one hbox2 = wx.BoxSizer(wx.HORIZONTAL) label2 = wx.StaticText(panel, label='Result') hbox2.Add(label2) vbox.Add(hbox2, flag=wx.LEFT | wx.TOP, border=10) vbox.Add((-1, 10)) # 5th: add multiple lines hbox3 = wx.BoxSizer(wx.HORIZONTAL) scanner2 = wx.TextCtrl(panel, style=wx.TE_MULTILINE) hbox3.Add(scanner2, proportion=5, flag=wx.EXPAND) vbox.Add(hbox3, proportion=5, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) vbox.Add((-1, 10)) # 6th: Buttons Container buttonsContainer = wx.BoxSizer(wx.HORIZONTAL) parseButton = wx.Button(panel, label='Parse', size=(70, 30)) self.Bind(wx.EVT_BUTTON, self.OnParse, id=parseButton.GetId()) buttonsContainer.Add(parseButton) quitButton = wx.Button(panel, label='EXIT', size=(70, 30)) self.Bind(wx.EVT_BUTTON, self.OnQuit, id=quitButton.GetId()) buttonsContainer.Add(quitButton, flag=wx.LEFT | wx.BOTTOM, border=5) vbox.Add(buttonsContainer, flag=wx.ALIGN_RIGHT | wx.RIGHT, border=10) # set the size of the panel according to the vbox panel.SetSizer(vbox) # set size of the panel self.SetSize((600, 600)) # center and show the window self.Center() self.Show(True)
def __init__(self, parent, ID, title): import traceback traceback.print_stack() self.app=wx.GetApp() self.options=self.app.options wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.CAPTION|wx.SYSTEM_MENU) self.panel=wx.Panel(self) self.CreateStatusBar() self.SetStatusText("Program initialised") self.SetBackgroundColour(wx.Colour(192,192,192)) # build menu self.menu1 = wx.Menu() self.menu1.Append(ID_LOG, 'Show Output &Log', 'Redirect log statements to a window',wx.ITEM_CHECK) self.menu1.Append(ID_ABOUT, "&About", "More information about this program") self.menu1.AppendSeparator() self.menu1.Append(ID_EXIT, "E&xit", "Terminate the program") menu2 = wx.Menu() menu2.Append(ID_QMDEXTENSIONS, 'Allow Metadata Extensions', 'Allow Metadata Extensions', wx.ITEM_CHECK) menu2.Append(ID_UCVARS, 'Force &Uppercase', 'Force all identifiers to upper-case', wx.ITEM_CHECK) menu2.Append(ID_FORCEFIBFLOAT, 'Force &Float', 'Force FIBs to be treated as floats', wx.ITEM_CHECK) menu2.Append(ID_FORCEDTD, 'Force DTD Location', 'Overrule the DTD location found in the XML file') menu2.Append(ID_FORCELANG, 'Default Language', 'Provide a default language setting for converted items') menu2.Append(ID_NOCOMMENT, 'Suppress Comments', 'Suppress output of diagnostic comments in converted items', wx.ITEM_CHECK) menu2.Append(ID_XPYSLET, 'Experimental Conversion', 'Convert files using the new pyslet modules (Experimental)', wx.ITEM_CHECK) # Set the options menu2.Check(ID_QMDEXTENSIONS, self.options.qmdExtensions) menu2.Check(ID_UCVARS, self.options.ucVars) menu2.Check(ID_FORCEFIBFLOAT, self.options.forceFloat) menu2.Check(ID_NOCOMMENT, self.options.noComment) menu2.Check(ID_XPYSLET, self.options.x) menuBar = wx.MenuBar() menuBar.Append(self.menu1, "&File"); menuBar.Append(menu2, "&Options"); self.SetMenuBar(menuBar) # events for menu items wx.EVT_MENU(self, ID_ABOUT, self.OnAbout) wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit) wx.EVT_MENU(self, ID_LOG, self.OnToggleRedirect) wx.EVT_MENU(self, ID_QMDEXTENSIONS, self.OnQMDExtensions) wx.EVT_MENU(self, ID_UCVARS, self.OnUCVars) wx.EVT_MENU(self, ID_FORCEFIBFLOAT, self.OnForceFIBFloat) wx.EVT_MENU(self, ID_FORCEDTD, self.OnForceDTD) wx.EVT_MENU(self, ID_FORCELANG, self.OnForceLANG) wx.EVT_MENU(self, ID_NOCOMMENT, self.OnSuppressComments) wx.EVT_MENU(self, ID_XPYSLET, self.OnXPyslet) # close event for main window self.Bind(wx.EVT_CLOSE, self.TimeToQuit) # Group FileBrowser and DirectoryBrowser # Only one is to be made active box1_title = wx.StaticBox( self.panel, 107, "Convert..." ) self.grp1_ctrls = [] radio1 = wx.RadioButton(self.panel, 103, "", style = wx.RB_SINGLE ) ffb1 = filebrowse.FileBrowseButton(self.panel, 104, size = (450, -1), labelText = "Single QTIv1.2 File : ", buttonText = "Browse..", startDirectory = os.getcwd(), fileMask = wildcard, fileMode = wx.OPEN, changeCallback = self.ffb1Callback) radio1.SetValue(1) ffb1.Enable(True) radio2 = wx.RadioButton(self.panel, 105, "", style = wx.RB_SINGLE ) dbb1 = filebrowse.DirBrowseButton(self.panel, 106, size = (450, -1), labelText = "Full Directory : ", buttonText = "Browse..", startDirectory = os.getcwd(), changeCallback = self.dbb1Callback) radio2.SetValue(0) dbb1.Enable(False) self.grp1_ctrls.append((radio1, ffb1)) self.grp1_ctrls.append((radio2, dbb1)) box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL ) grid1 = wx.FlexGridSizer( 0, 2, 0, 0 ) for radio, browseButton in self.grp1_ctrls: grid1.Add( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) grid1.Add( browseButton, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) box1.Add( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) # == Save files to... box2_title = wx.StaticBox( self.panel, 109, "Save files to..." ) self.grp2_ctrls = [] dbb2 = filebrowse.DirBrowseButton(self.panel, 108, size = (475, -1), labelText = "Select Directory : ", buttonText = "Browse..", startDirectory = os.getcwd(), changeCallback = self.dbb2Callback) dbb2.SetValue(self.options.cpPath,0) self.grp2_ctrls.append(dbb2) box2 = wx.StaticBoxSizer( box2_title, wx.VERTICAL ) box2.Add( dbb2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) # == define Convert and Cancel (close) buttons button1 = wx.Button(self.panel, 1003, "Convert..") self.Bind(wx.EVT_BUTTON, self.ConvertMe, button1) button2 = wx.Button(self.panel, 1004, "Close") self.Bind(wx.EVT_BUTTON, self.TimeToQuit, button2) # Now add everything to the border # First define a button row buttonBorder = wx.BoxSizer(wx.HORIZONTAL) buttonBorder.Add(button1, 0, wx.ALL, 5) buttonBorder.Add(button2, 0, wx.ALL, 5) # Add it all border = wx.BoxSizer(wx.VERTICAL) border.Add(box1, 0, wx.ALL, 5) border.Add(box2, 0, wx.ALL, 5) border.Add(buttonBorder, 0, wx.ALL, 5) self.SetSizer(border) self.SetAutoLayout(True) # Setup event handling and initial state for controls: for radio, browseButton in self.grp1_ctrls: self.Bind(wx.EVT_RADIOBUTTON, self.OnGroup1Select, radio ) # radio.SetValue(0) # browseButton.Enable(False) self.app.SetMainFrame(self)
def __init__(self, parent, ID, title): "constructor" wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(675, 480)) # Create the menu menu = wx.Menu() menu.Append(ID_ABOUT, (localText.getText("TXT_KEY_PITBOSS_ABOUT", ())), (localText.getText("TXT_KEY_PITBOSS_ABOUT_TEXT", ()))) menu.AppendSeparator() menu.Append(ID_SAVE, (localText.getText("TXT_KEY_PITBOSS_SAVE", ())), (localText.getText("TXT_KEY_PITBOSS_SAVE_TEXT", ()))) menu.Append(ID_EXIT, (localText.getText("TXT_KEY_PITBOSS_EXIT", ())), (localText.getText("TXT_KEY_PITBOSS_EXIT_TEXT", ()))) menuBar = wx.MenuBar() strFile = localText.getText("TXT_KEY_PITBOSS_FILE", ()) strFile = localText.stripHTML(strFile) menuBar.Append(menu, strFile) self.SetMenuBar(menuBar) # Create our arrays of information and controls self.nameArray = [] self.pingArray = [] self.scoreArray = [] self.kickArray = [] pageSizer = wx.BoxSizer(wx.VERTICAL) # Add the game name and date self.gameTurn = PB.getGameturn() self.title = wx.StaticText( self, -1, PB.getGamename() + " - " + PB.getGamedate(False)) font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL) self.title.SetFont(font) self.title.SetSize(self.title.GetBestSize()) pageSizer.Add(self.title, 0, wx.ALL, 5) # Add the turn timer if we have one if (PB.getTurnTimer()): timerSizer = wx.BoxSizer(wx.HORIZONTAL) # Add a button to allow turn timer modification timerChangeButton = wx.Button( self, -1, localText.getText("TXT_KEY_MP_OPTION_TURN_TIMER", ())) self.Bind(wx.EVT_BUTTON, self.OnChangeTimer, timerChangeButton) timerSizer.Add(timerChangeButton, 0, wx.ALL, 5) self.timerDisplay = wx.StaticText(self, -1, "") font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL) self.timerDisplay.SetFont(font) self.timerDisplay.SetSize(self.timerDisplay.GetBestSize()) timerSizer.Add(self.timerDisplay, 0, wx.ALL, 5) pageSizer.Add(timerSizer, 0, wx.ALL, 5) infoSizer = wx.BoxSizer(wx.HORIZONTAL) leftSizer = wx.BoxSizer(wx.VERTICAL) playerPanel = wx.lib.scrolledpanel.ScrolledPanel( self, -1, size=(370, 280), style=wx.DOUBLE_BORDER) playerSizer = wx.BoxSizer(wx.VERTICAL) # Create a row for each player in the game rowNum = 0 for rowNum in range(gc.getMAX_CIV_PLAYERS()): if (gc.getPlayer(rowNum).isEverAlive()): # Create the border box border = wx.StaticBox(playerPanel, -1, (localText.getText( "TXT_KEY_PITBOSS_PLAYER", (rowNum + 1, ))), (0, (rowNum * 30))) # Create the layout mgr rowSizer = wx.StaticBoxSizer(border, wx.HORIZONTAL) # Player name itemSizer = wx.BoxSizer(wx.VERTICAL) lbl = wx.StaticText( playerPanel, -1, (localText.getText("TXT_KEY_PITBOSS_WHO", ()))) txtValue = wx.StaticText(playerPanel, rowNum, "", size=wx.Size(100, 13)) itemSizer.Add(lbl) itemSizer.Add(txtValue) rowSizer.Add(itemSizer, 0, wx.ALL, 5) self.nameArray.append(txtValue) # Ping times itemSizer = wx.BoxSizer(wx.VERTICAL) lbl = wx.StaticText( playerPanel, -1, (localText.getText("TXT_KEY_PITBOSS_PING", ()))) txtValue = wx.StaticText(playerPanel, rowNum, "", size=wx.Size(70, 13)) itemSizer.Add(lbl) itemSizer.Add(txtValue) rowSizer.Add(itemSizer, 0, wx.ALL, 5) self.pingArray.append(txtValue) # Scores itemSizer = wx.BoxSizer(wx.VERTICAL) lbl = wx.StaticText( playerPanel, -1, (localText.getText("TXT_KEY_PITBOSS_SCORE", ()))) txtValue = wx.StaticText(playerPanel, rowNum, "", size=wx.Size(30, 13)) itemSizer.Add(lbl) itemSizer.Add(txtValue) rowSizer.Add(itemSizer, 0, wx.ALL, 5) self.scoreArray.append(txtValue) # Kick buttons kickButton = wx.Button( playerPanel, rowNum, (localText.getText("TXT_KEY_PITBOSS_KICK", ()))) rowSizer.Add(kickButton, 0, wx.ALL, 5) kickButton.Disable() self.Bind(wx.EVT_BUTTON, self.OnKick, kickButton) self.kickArray.append(kickButton) playerSizer.Add(rowSizer, 0, wx.ALL, 5) playerPanel.SetSizer(playerSizer) playerPanel.SetAutoLayout(1) playerPanel.SetupScrolling() leftSizer.Add(playerPanel, 0, wx.ALL, 5) # Add a button row buttonSizer = wx.BoxSizer(wx.HORIZONTAL) # Add the save game button saveButton = wx.Button( self, -1, (localText.getText("TXT_KEY_PITBOSS_SAVE_GAME", ()))) self.Bind(wx.EVT_BUTTON, self.OnSave, saveButton) buttonSizer.Add(saveButton, 0, wx.ALL, 5) # Add the exit game button exitButton = wx.Button( self, -1, (localText.getText("TXT_KEY_MAIN_MENU_EXIT_GAME", ()))) self.Bind(wx.EVT_BUTTON, self.OnExit, exitButton) buttonSizer.Add(exitButton, 0, wx.ALL, 5) leftSizer.Add(buttonSizer, 0, wx.ALL, 5) # Add the left area to the info area infoSizer.Add(leftSizer, 0, wx.ALL, 5) # Now create the message area messageSizer = wx.BoxSizer(wx.VERTICAL) # Create the MotD Panel motdBorder = wx.StaticBox( self, -1, localText.getText("TXT_KEY_PITBOSS_MOTD_TITLE", ())) motdSizer = wx.StaticBoxSizer(motdBorder, wx.VERTICAL) # Check box whether to use MotD or not self.motdCheckBox = wx.CheckBox( self, -1, localText.getText("TXT_KEY_PITBOSS_MOTD_TOGGLE", ())) self.motdCheckBox.SetValue(len(pbSettings.get('MotD', '')) > 0) motdSizer.Add(self.motdCheckBox, 0, wx.TOP, 5) # Add edit box displaying current MotD self.motdDisplayBox = wx.TextCtrl(self, -1, "", size=(225, 50), style=wx.TE_MULTILINE | wx.TE_READONLY) self.motdDisplayBox.SetHelpText( localText.getText("TXT_KEY_PITBOSS_MOTD_HELP", ())) self.motdDisplayBox.SetValue(pbSettings.get('MotD', '')) motdSizer.Add(self.motdDisplayBox, 0, wx.ALL, 5) # Add a button to allow motd modification motdChangeButton = wx.Button( self, -1, localText.getText("TXT_KEY_PITBOSS_MOTD_CHANGE", ())) motdChangeButton.SetHelpText( localText.getText("TXT_KEY_PITBOSS_MOTD_CHANGE_HELP", ())) self.Bind(wx.EVT_BUTTON, self.OnChangeMotD, motdChangeButton) motdSizer.Add(motdChangeButton, 0, wx.ALL, 5) # Add the motd area to the message area messageSizer.Add(motdSizer, 0, wx.ALL, 5) # Create the dialog panel dialogBorder = wx.StaticBox( self, -1, localText.getText("TXT_KEY_PITBOSS_CHAT_TITLE", ())) dialogSizer = wx.StaticBoxSizer(dialogBorder, wx.VERTICAL) # Chat log self.chatLog = wx.TextCtrl(self, -1, "", size=(225, 100), style=wx.TE_MULTILINE | wx.TE_READONLY) self.chatLog.SetHelpText( localText.getText("TXT_KEY_PITBOSS_CHAT_LOG_HELP", ())) dialogSizer.Add(self.chatLog, 0, wx.ALL, 5) # Chat edit self.chatEdit = wx.TextCtrl(self, -1, "", size=(225, -1), style=wx.TE_PROCESS_ENTER) self.chatEdit.SetHelpText( localText.getText("TXT_KEY_PITBOSS_CHAT_EDIT_HELP", ())) dialogSizer.Add(self.chatEdit, 0, wx.ALL, 5) self.Bind(wx.EVT_TEXT_ENTER, self.OnSendChat, self.chatEdit) # Add the dialog area to the message area messageSizer.Add(dialogSizer, 0, wx.ALL, 5) # Add the message area to our info area infoSizer.Add(messageSizer, 0, wx.ALL, 5) # Add the info area to the page pageSizer.Add(infoSizer, 0, wx.ALL, 5) self.SetSizer(pageSizer) # Register the event handlers wx.EVT_MENU(self, ID_ABOUT, self.OnAbout) wx.EVT_MENU(self, ID_SAVE, self.OnSave) wx.EVT_MENU(self, ID_EXIT, self.OnExit) # Other handlers self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) #Webserver self.webserver = Webserver.ThreadedHTTPServer( (pbSettings['webserver']['host'], pbSettings['webserver']['port']), Webserver.HTTPRequestHandler) self.t = Thread(target=self.webserver.serve_forever) self.t.setDaemon(True) self.t.start() #Periodical game data upload if (pbSettings['webfrontend']['sendPeriodicalData'] != 0): self.webupload = Webserver.PerpetualTimer( pbSettings['webfrontend'], self.webserver) self.t2 = Thread(target=self.webupload.start) self.t2.setDaemon(True) self.t2.start()
def initui(self): """ Initialize the position of objects in the UI """ # define the panel panel = wx.Panel(self) # create menubar for About information menubar = wx.MenuBar() helpm = wx.Menu() abti = wx.MenuItem(helpm, wx.ID_ABOUT, '&About', 'Program Information') self.Bind(wx.EVT_MENU, self.AboutDialog, abti) helpm.Append(abti) menubar.Append(helpm, '&Help') self.SetMenuBar(menubar) # define layer size begin_depth = 20 layer_diff = 40 first_blk = 20 sec_blk = 250 third_blk = 525 # title # position: (from top to bottom, from left to right) wx.StaticText(panel, label=u''.join([ u'Time-of-change value data to data ', u'at constant time intervals' ]), pos=(first_blk, begin_depth)) # Inputs to the data file path layer_depth = begin_depth+layer_diff text = wx.StaticText( panel, label=u'Data file path:', pos=(first_blk, layer_depth+2) ) # require additional object for textbox # with default path self.dfpath = wx.TextCtrl( panel, value=u'../dat/time_of_change.csv', pos=(sec_blk, layer_depth), size=(250, 20) ) # load worksheet name choices for files with xls/ xlsx extension # for self.sheetname ComboBox self.dfpath.Bind(wx.EVT_TEXT, self.ChangeForXlsFile) button = wx.Button( panel, label=u'Browse...', pos=(third_blk, layer_depth) ) button.Bind(wx.EVT_BUTTON, self.OnOpen) layer_depth += layer_diff # ask for existence of header as a checkbox text = wx.StaticText( panel, label=u'Existence of a header row:', pos=(first_blk, layer_depth+2) ) self.header = wx.CheckBox(panel, pos=(sec_blk, layer_depth)) self.header.SetValue(True) # for the positioning of the header numeric function wx.StaticText( panel, label=u''.join([ 'Number of rows to be skipped\nabove the header row:' ]), pos=(third_blk-150, layer_depth), size=(150, 30) ) self.header_no = wx.SpinCtrl( panel, value='0', min=0, max=100000, # max: approx. 1 month pos=(third_blk+20, layer_depth), size=(50, 20) ) # add the dynamic information of the checkbox self.header.Bind(wx.EVT_CHECKBOX, self.HeaderInput) layer_depth += layer_diff # option to select sheet, if any, and choose if all sheets # should be loaded wx.StaticText(panel, label=u''.join([ u'Choose a worksheet to load\n', u'for xls/xlsx input file:' ]), pos=(first_blk, layer_depth-5)) self.sheetname = wx.ComboBox( panel, pos=(sec_blk, layer_depth), size=(100, 30) ) self.sheetname.Enable(False) wx.StaticText(panel, label=u''.join([ u'Load all worksheets with the\n', u'same config for xls/xlsx input file:' ]), pos=(third_blk-150, layer_depth-5)) self.loadallsheets = wx.CheckBox(panel, pos=(third_blk+55, layer_depth)) self.loadallsheets.SetValue(False) if 'xls' not in get_ext(self.dfpath.GetValue()): self.loadallsheets.Enable(False) # check if anything needs to be changed after checking/unchecking the box self.loadallsheets.Bind(wx.EVT_CHECKBOX, self.LoadAllSheets) layer_depth += layer_diff # Inputs to the directory to save the plots text = wx.StaticText( panel, label=u'Path to save file:', pos=(first_blk, layer_depth+2) ) # require additional object for textbox # with default path self.newdfpath = wx.TextCtrl( panel, value=u'./example.csv', pos=(sec_blk, layer_depth), size=(250, 20) ) self.newdfpath.Bind(wx.EVT_TEXT, self.ChangeForXlsFileOutput) button = wx.Button( panel, label=u'Browse...', pos=(third_blk, layer_depth) ) button.Bind(wx.EVT_BUTTON, self.SaveOpen) layer_depth += layer_diff # Separator of output file # can be any string, but provide the choices wx.StaticText( panel, label=u''.join([ u'Separator of the output file', u'\n(valid for csv file only):' ]), pos=(first_blk, layer_depth+2) ) # do not use unicode here self.output_sep = wx.ComboBox( panel, value=',', choices=[';', ','], pos=(sec_blk, layer_depth), size=(50, 20) ) layer_depth += layer_diff # Inputs to the format time string text = wx.StaticText(panel, label=u'\n'.join([ u'Format of time string', u'in the output file', u'(invalid for xls/xlsx file output):' ]), pos=(first_blk, layer_depth+2)) # # require additional object for textbox self.outputtimestring = wx.TextCtrl( panel, value=u'%Y/%m/%d %H:%M:%S', pos=(sec_blk, layer_depth), size=(250, 20) ) self.outputtimestring.Enable(get_ext(self.dfpath.GetValue()) == 'csv') # a button for instructions button = wx.Button( panel, label=u'Instructions to enter the format of the time string', pos=(sec_blk, layer_depth+20) ) button.Bind(wx.EVT_BUTTON, self.TimeInstruct) layer_depth += (layer_diff+20) # other output format wx.StaticText(panel, label=u'\n'.join([ u'or output the time as values of ', ]), pos=(first_blk, layer_depth+2)) self.numtimeoutput = wx.ComboBox(panel, value='None', choices=[ 'None', 'seconds', 'minutes', 'hours', 'days' ], pos=(sec_blk, layer_depth), size=(70, 20)) self.numtimeoutput.SetEditable(False) self.numtimeoutput.Bind(wx.EVT_COMBOBOX, self.ChangeOptionForNum) wx.StaticText(panel, label=u'\n'.join([ u'from the user-defined start time', ]), pos=(sec_blk+80, layer_depth+2)) layer_depth += (layer_diff) # Inputs to the format time string text = wx.StaticText(panel, label=u'\n'.join([ u'Format of time string in the first', u'column of the input file:' ]), pos=(first_blk, layer_depth+2)) # require additional object for textbox self.timestring = wx.TextCtrl( panel, value=u'%m/%d/%y %I:%M:%S %p CST', pos=(sec_blk, layer_depth), size=(250, 20) ) # Computer to auto-detect the format instead self.autotimeinputformat = wx.CheckBox( panel, pos=(sec_blk+70*4, layer_depth+2) ) self.autotimeinputformat.SetValue(True) wx.StaticText( panel, label=u'Auto-detecting format\nof input time string', pos=(sec_blk+70*4, layer_depth+20) ) self.autotimeinputformat.Bind( wx.EVT_CHECKBOX, self.GreyOutInputTimeString ) self.timestring.Enable(False) # disable the option # a button for instructions text = wx.StaticText(panel, label=u''.join([ u'Same instructions as the format in output file' ]), pos=(sec_blk, layer_depth+20)) layer_depth += (layer_diff+20) # add start time input text = wx.StaticText(panel, label=u''.join([ u'Start time in the new data file:' u'\n(inaccurate for too much extension)' ]), pos=(first_blk, layer_depth+2)) # create spin control for the date and time self.start_yr = wx.SpinCtrl( panel, value='2017', min=1, max=4000, pos=(sec_blk, layer_depth), size=(55, 20) ) text = wx.StaticText(panel, label=u''.join([ u'Year' ]), pos=(sec_blk, layer_depth+20)) # reset the last day of the month if needed self.start_yr.Bind(wx.EVT_COMBOBOX, self.ChangeStartDayLimit) self.start_mon = wx.ComboBox( panel, pos=(sec_blk+70, layer_depth), choices=[str(ind) for ind in range(1, 13)], size=(50, 20) ) self.start_mon.SetValue('1') # reset the last day of the month if needed self.start_mon.Bind(wx.EVT_COMBOBOX, self.ChangeStartDayLimit) self.start_mon.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Month' ]), pos=(sec_blk+70, layer_depth+20)) self.start_day = wx.ComboBox( panel, pos=(sec_blk+70*2, layer_depth), choices=[str(ind) for ind in range(1, 32)], size=(50, 20) ) self.start_day.SetValue('1') self.start_day.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Day' ]), pos=(sec_blk+70*2, layer_depth+20)) self.start_hr = wx.ComboBox( panel, pos=(sec_blk+70*3, layer_depth), choices=['%02i' % ind for ind in range(24)], size=(50, 20) ) self.start_hr.SetValue('00') self.start_hr.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Hour' ]), pos=(sec_blk+70*3, layer_depth+20)) self.start_min = wx.ComboBox( panel, pos=(sec_blk+70*4, layer_depth), choices=['%02i' % ind for ind in range(60)], size=(50, 20) ) self.start_min.SetValue('00') self.start_min.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Minutes' ]), pos=(sec_blk+70*4, layer_depth+20)) self.use_starttime = wx.CheckBox(panel, pos=(sec_blk+70*5, layer_depth+2)) self.use_starttime.SetValue(True) wx.StaticText( panel, label=u'Use file\nstarting time', pos=(sec_blk+70*5, layer_depth+20) ) layer_depth += (layer_diff+20) # add ending time input text = wx.StaticText(panel, label=u''.join([ u'Ending time in the new data file:', u'\n(inaccurate for too much extension)' ]), pos=(first_blk, layer_depth+2)) # create spin control for the date and time self.end_yr = wx.SpinCtrl( panel, value='2017', min=1, max=4000, pos=(sec_blk, layer_depth), size=(55, 20) ) text = wx.StaticText(panel, label=u''.join([ u'Year' ]), pos=(sec_blk, layer_depth+20)) # reset the last day of the month if needed self.end_yr.Bind(wx.EVT_COMBOBOX, self.ChangeEndDayLimit) self.end_mon = wx.ComboBox( panel, pos=(sec_blk+70, layer_depth), choices=[str(ind) for ind in range(1, 13)], size=(50, 20) ) self.end_mon.SetValue('12') # reset the last day of the month if needed self.end_mon.Bind(wx.EVT_COMBOBOX, self.ChangeEndDayLimit) self.end_mon.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Month' ]), pos=(sec_blk+70, layer_depth+20)) self.end_day = wx.ComboBox( panel, pos=(sec_blk+70*2, layer_depth), choices=[str(ind) for ind in range(1, 32)], size=(50, 20) ) self.end_day.SetValue('31') self.end_day.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Day' ]), pos=(sec_blk+70*2, layer_depth+20)) self.end_hr = wx.ComboBox( panel, pos=(sec_blk+70*3, layer_depth), choices=['%02i' % ind for ind in range(24)], size=(50, 20) ) self.end_hr.SetValue('23') self.end_hr.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Hour' ]), pos=(sec_blk+70*3, layer_depth+20)) self.end_min = wx.ComboBox( panel, pos=(sec_blk+70*4, layer_depth), choices=['%02i' % ind for ind in range(60)], size=(50, 20) ) self.end_min.SetValue('59') self.end_min.SetEditable(False) text = wx.StaticText(panel, label=u''.join([ u'Minutes' ]), pos=(sec_blk+70*4, layer_depth+20)) self.no_endtime = wx.CheckBox(panel, pos=(sec_blk+70*5, layer_depth+2)) self.no_endtime.SetValue(True) wx.StaticText( panel, label=u'Autogen\nending time', pos=(sec_blk+70*5, layer_depth+20) ) layer_depth += (layer_diff+20) # add fixed interval input text = wx.StaticText( panel, label=u'New time interval:', pos=(first_blk, layer_depth+2) ) self.time_int = wx.SpinCtrl( panel, value='10', min=1, max=31*24*60, # max: approx. 1 month pos=(sec_blk, layer_depth), size=(50, 20) ) text = wx.StaticText( panel, label=u'minutes', pos=(sec_blk+50+10, layer_depth+2) ) layer_depth += layer_diff # Relationship between time series data points wx.StaticText( panel, label=u'Assumption between data points:', pos=(first_blk, layer_depth+2) ) self.func_choice = wx.ComboBox( panel, value=u'Step Function', choices=[ u'Step Function', u'Continuous variable (inter- and extrapolation)' ], pos=(sec_blk, layer_depth), size=(225, 20) ) self.func_choice.SetSelection(0) self.func_choice.SetEditable(False) layer_depth += layer_diff # Assumptions on extrapolation wx.StaticText( panel, label=u''.join([ u'Assumptions for data points\n', u'earlier than the existing data:' ]), pos=(first_blk, layer_depth+2) ) self.early_pts = wx.ComboBox( panel, value=u'Use the minimum value in the trend', choices=[ u'Use the minimum value in the trend', u'Use the first value in the trend', u'Use blanks' ], pos=(sec_blk, layer_depth), size=(225, 20) ) self.early_pts.SetSelection(2) self.early_pts.SetEditable(False) layer_depth += layer_diff # buttons at the bottom button_ok = wx.Button( panel, label=u'Preprocess', pos=(third_blk+50, layer_depth) ) button_ok.Bind(wx.EVT_BUTTON, self.Analyzer) layer_depth += layer_diff
def createItems(self): """create all items""" #menu self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() qms = self.fileMenu.Append(wx.ID_SAVE, '&Save Image') self.Bind(wx.EVT_MENU, self.OnSave, qms) qec = self.fileMenu.Append(wx.ID_ANY, '&Export Coordinates') self.Bind(wx.EVT_MENU, self.OnExport, qec) qme = self.fileMenu.Append(wx.ID_EXIT, '&Quit') self.Bind(wx.EVT_MENU, self.OnQuit, qme) self.menubar.Append(self.fileMenu, '&File') self.SetMenuBar(self.menubar) #image options self.zoomTxt = wx.StaticText(self, 200, "Zoom Factor") self.slider = wx.Slider(self, 300, value=14, minValue=1, maxValue=20, style=wx.SL_HORIZONTAL,size=(500,-1)) self.combo = wx.ComboBox(self, 500, "Satellite",choices=map_types, style=wx.CB_READONLY,size=(180,-1)) wx.EVT_SLIDER(self,300,self.OnEvent) wx.EVT_COMBOBOX(self,500,self.OnEvent) #list self.list = CheckListCtrl(self,size=(675,500)) self.list.InsertColumn(0, 'Label') self.list.InsertColumn(1, 'File Name') self.list.InsertColumn(2, 'Latitude') self.list.InsertColumn(3, 'Longitude') self.list.InsertColumn(4, 'PDOP') self.list.SetColumnWidth(0, 50) self.list.SetColumnWidth(1, 150) self.list.SetColumnWidth(2, 200) self.list.SetColumnWidth(3, 200) self.list.SetColumnWidth(4, 50) self.list.OnCheckItem = self.OnCheckItem wx.EVT_CHECKBOX(self.list,600,self.OnEvent) #create list entries letters = string.ascii_uppercase i = 0 num_labels = 0 for entry in self.files: lat = self.files[i].header["Latitude"] long = self.files[i].header["Longitude"] name = os.path.basename(self.files[i].filename) pdop = self.files[i].header["PDOP"] if -180<=lat<=180: try: label = letters[num_labels] num_labels += 1 except: label = letters[0] num_labels = 1 else: label = "-" self.label.append(label) self.list.InsertStringItem(i,label) if not label == "-": self.list.CheckItem(i, True) self.list.SetStringItem(i,1,name) self.list.SetStringItem(i,2,str(lat)) self.list.SetStringItem(i,3,str(long)) self.list.SetStringItem(i,4,"%.1f"%pdop) i+=1
def __init__(self, parent = None, id = -1, title = "Anagopos"): wx.Frame.__init__( self, parent, id, title, size = (1200, 768), style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE ) # Hack! Add the extra path so the application knows where to find the # GraphViz binaries when run with a "double click" (in which case the # path set in .profile isn't used). osenviron['PATH'] = osenviron['PATH'] + ":" \ + MACPORTS_PATH + ":" \ + FINK_PATH + ":" \ + PKGSRC_PATH + ":" \ + BINARY_DISTRO_PATH self.load_state() self.drawing = ReductionGraphCanvas(self) self.drawing.ready = False # Create the radio buttons to select between lambda calculus and TRS. self.radio_lambda = wx.RadioButton(self, -1, 'Lambda Calculus', style = wx.RB_GROUP) self.radio_trs = wx.RadioButton(self, -1, 'TRS') self.Bind(wx.EVT_RADIOBUTTON, self.SetRadioVal, id = self.radio_lambda.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.SetRadioVal, id = self.radio_trs.GetId()) self.active_rule_file_text = wx.StaticText(self, -1, 'Rule set: Beta Reduction') radio_box = wx.BoxSizer(wx.HORIZONTAL) radio_box.Add(self.radio_lambda, 0, wx.ALIGN_LEFT, 10) radio_box.Add(self.radio_trs, 0, wx.ALIGN_LEFT | wx.LEFT, 10) self.radio_lambda.SetValue(True) # Lambda is by default active self.radio_trs.SetToolTip(wx.ToolTip("Select 'File > Load Rule Set' to activate TRS mode.")) width = 200 spinner_width = 60 button_size = (width, -1) step_size = (width - spinner_width, -1) # Buttons self.term_input = wx.TextCtrl(self, 0, style = wx.TE_MULTILINE, size = (width, 100)) draw_button = wx.Button(self, 0, "Draw Graph", size = button_size) self.random_button = wx.Button(self, 0, "Generate Random Term", size = button_size) forward_button = wx.Button(self, 0, "Forward", size = step_size) back_button = wx.Button(self, 0, "Back", size = step_size) redraw_button = wx.Button(self, 0, "Redraw Graph", size = button_size) optimize_button = wx.Button(self, 0, "Optimize Graph", size = button_size) optimize_button.SetToolTip(wx.ToolTip("Recomputes graph with optimized node positions.")) algo_label = wx.StaticText(self, -1, 'Select Drawing Algorithm: ', (5, 5)) self.algo_combo = wx.ComboBox(self, -1, size = (width, -1), choices = [k for (k,v) in algorithms.iteritems()], style = wx.CB_READONLY) term_label = wx.StaticText(self, -1, 'Clicked Term: ') term_text = wx.TextCtrl(self, -1, size = (width, 150), style = wx.TE_MULTILINE | wx.TE_READONLY) def node_click_callback(node): term_text.SetValue("" + str(node)[5:]) self.drawing.node_clicked = node_click_callback start_checkbox = wx.CheckBox(self, -1, 'Show start') newest_checkbox = wx.CheckBox(self, -1, 'Show newest') # Spinners (for choosing step size) self.forward_spinner = wx.SpinCtrl(self, -1, "1", min = 1, max = 100, initial = 1, size = (spinner_width, -1)) forward_box = wx.BoxSizer(wx.HORIZONTAL) forward_box.Add(forward_button, 0, wx.ALIGN_LEFT, 10) forward_box.Add(self.forward_spinner, 0, wx.ALIGN_RIGHT, 10) self.back_spinner = wx.SpinCtrl(self, -1, "1", min = 1, max = 100, initial = 1, size = (spinner_width, -1)) back_box = wx.BoxSizer(wx.HORIZONTAL) back_box.Add(back_button, 0, wx.ALIGN_LEFT, 10) back_box.Add(self.back_spinner, 0, wx.ALIGN_RIGHT, 10) # Button/spinner actions draw_button.Bind(wx.EVT_BUTTON, self.DrawGraph) self.random_button.Bind(wx.EVT_BUTTON, self.Generate) forward_button.Bind(wx.EVT_BUTTON, self.drawing.Forward) back_button.Bind(wx.EVT_BUTTON, self.drawing.Back) redraw_button.Bind(wx.EVT_BUTTON, self.drawing.Redraw) optimize_button.Bind(wx.EVT_BUTTON, self.drawing.Optimize) self.algo_combo.Bind(wx.EVT_COMBOBOX, self.NewAlgoSelected) self.forward_spinner.Bind(wx.EVT_SPINCTRL, self.forward_spin) self.back_spinner.Bind(wx.EVT_SPINCTRL, self.back_spin) start_checkbox.Bind(wx.EVT_CHECKBOX, self.drawing.ToggleShowStart) newest_checkbox.Bind(wx.EVT_CHECKBOX, self.drawing.ToggleShowNewest) # Layout the control panel bts = wx.BoxSizer(wx.VERTICAL) bts.Add(radio_box, 0, wx.ALIGN_LEFT | wx.ALL, 10) bts.Add(self.active_rule_file_text, 0, wx.ALIGN_LEFT | wx.LEFT, 10) bts.Add(self.term_input, 0, wx.ALIGN_CENTER | wx.ALL, 10) bts.Add(self.random_button, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(draw_button, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(forward_box, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(back_box, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(redraw_button, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(optimize_button, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(algo_label, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 3) bts.Add(self.algo_combo, 0, wx.ALIGN_CENTER | wx.LEFT | wx.BOTTOM, 10) bts.Add(start_checkbox, 0, wx.ALIGN_LEFT | wx.LEFT, 10) bts.Add(newest_checkbox, 0, wx.ALIGN_LEFT | wx.LEFT | wx.BOTTOM, 10) bts.Add(term_label, 0, wx.ALIGN_CENTER | wx.ALL, 3) bts.Add(term_text, 0, wx.ALIGN_CENTER | wx.ALL, 3) # Layout the whole window frame box = wx.BoxSizer(wx.HORIZONTAL) box.Add(bts, 0, wx.ALIGN_TOP, 15) box.Add(self.drawing, 1, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) self.Layout() self.CreateStatusBar() def status_bar_callback(grapharea): s = "Number of nodes: " + str(len(grapharea.graph.nodes)) + "." if hasattr(grapharea, 'nomoregraphs') and grapharea.nomoregraphs: s += " No more graphs." self.SetStatusText(s) self.drawing.output_graph_status = status_bar_callback # Menus filemenu = wx.Menu() color_scheme_menu = wx.Menu() # Menu actions menuitem = filemenu.Append(-1, "&Save Image\tCtrl+S", "Take a screenshot") self.Bind(wx.EVT_MENU, self.OnScreenshot, menuitem) menuitem = filemenu.Append(-1, "&Open Rule Set\tCtrl+O", "Load a TRS rule set") self.Bind(wx.EVT_MENU, self.OnLoadRuleSet, menuitem) filemenu.AppendSeparator() self.color_scheme_black = color_scheme_menu.AppendRadioItem(-1, "Black Funk\tCtrl+1") self.Bind(wx.EVT_MENU, self.OnColorSchemeChange, self.color_scheme_black) self.color_scheme_white = color_scheme_menu.AppendRadioItem(-1, "White Snow\tCtrl+2") self.Bind(wx.EVT_MENU, self.OnColorSchemeChange, self.color_scheme_white) self.color_scheme_grey = color_scheme_menu.AppendRadioItem(-1, "Grey Dawn\tCtrl+3") self.Bind(wx.EVT_MENU, self.OnColorSchemeChange, self.color_scheme_grey) filemenu.AppendMenu(-1, "Color Schemes", color_scheme_menu) menuitem = filemenu.Append(-1, "&About", "About") self.Bind(wx.EVT_MENU, self.OnAbout, menuitem) filemenu.AppendSeparator() menuitem = filemenu.Append(-1, "E&xit", "Terminate the program") self.Bind(wx.EVT_MENU, self.OnExit, menuitem) # Menubar, containg the menu(s) created above menubar = wx.MenuBar() menubar.Append(filemenu, "&File") self.SetMenuBar(menubar) self.lambda_contents = self.trs_contents = "" self.rule_set = None # Used for the TRS self.last_used_rule_set = None self.last_used_rule_name = ""