def __init__(self, parent, title, homeDir, fileName=None): """ Standard constructor. 'parent', 'id' and 'title' are all passed to the standard wx.Frame constructor. 'fileName' is the name and path of a saved file to load into this frame, if any. """ wx.Dialog.__init__(self, parent, title='title', size=(500, 600)) self.statToolName = wx.StaticText(self, -1, "Name of New Tool", size=(100,-1), pos=(50,50)) self.textToolName = wx.TextCtrl(self, -1, "", size=(300,-1), pos=(50,75)) self.newToolIconButton = filebrowse.DirBrowseButton(parent=self, id=-1,pos=wx.Point(50,100), size=(400,50), labelText="Select icon\nfor new tool") self.newToolIconButton.SetValue(homeDir + r"\Utils\Icons\Default") self.newToolLocButton = filebrowse.DirBrowseButton(parent=self, id=-1,pos=wx.Point(50,150), size=(400,50), labelText="Select location\nof original script") self.statToolClass = wx.StaticText(self, -1, "What class(es) are used with the tool?", size=(350,-1), pos=(50,200)) self.textToolClass = wx.TextCtrl(self, -1, "", size=(350,-1), pos=(50,225)) self.statToolInput = wx.StaticText(self, -1, "What inputs does this class recognize?", size=(350,-1), pos=(50,250)) self.textToolInput = wx.TextCtrl(self, -1, "", size=(350,-1), pos=(50,275)) addToolButton = wx.Button(self, -1, "Create", pos=(300,325)) addToolButton.SetBackgroundColour('RED') addToolButton.SetForegroundColour('WHITE') self.Bind(wx.EVT_BUTTON, self.doCreate, addToolButton)
def add_dir_browse_field(parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL, label='Select a directory:', button='Browse', tooltip='Type directory name or browse to select', title='', history='', start_directory='.', dialog_class=wx.DirDialog, new_directory=False, name='dirBrowseButton', value='', editable=True, call_back=None, **kwargs): dbb = filebrowse.DirBrowseButton(parent, id, pos=pos, size=size, style=style, labelText=label, buttonText=button, toolTip=tooltip, dialogTitle=title, startDirectory=start_directory, changeCallback=call_back, dialogClass=dialog_class, newDirectory=new_directory, name=name, ) if value: dbb.SetValue(value, 0) dbb.textControl.SetEditable(editable) return dbb
def BuildInterface( self ): self.main_sizer = wx.BoxSizer( wx.VERTICAL ) # Save As filed save_as_sizer = wx.BoxSizer( wx.HORIZONTAL ) st = wx.StaticText( self, -1, 'Save as:', style=wx.ALIGN_RIGHT ) save_as_sizer.Add( st, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 8 ) self.save_as = wx.TextCtrl( self, -1, size=(350,-1) ) save_as_sizer.Add( self.save_as, 0, wx.RIGHT, 72 ) self.main_sizer.Add( save_as_sizer, 0, wx.TOP | wx.ALIGN_RIGHT, 86 ) # Tags field tags_sizer = wx.BoxSizer( wx.HORIZONTAL ) st = wx.StaticText( self, -1, 'Tags:', style=wx.ALIGN_RIGHT ) tags_sizer.Add( st, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 8 ) self.tags = wx.TextCtrl( self, -1, size=(350,-1) ) tags_sizer.Add( self.tags, 0, wx.RIGHT, 72 ) self.main_sizer.Add( tags_sizer, 0, wx.TOP | wx.ALIGN_RIGHT, 15 ) # Where field where_sizer = wx.BoxSizer( wx.HORIZONTAL ) self.where = filebrowse.DirBrowseButton( self, -1, size=(400,-1), labelText= "Where: " )#, changeCallback=self.__SelectDirectory ) initial_directory = self.config.Read( 'were_fild_init_dir' ) if len( initial_directory ) != 0: self.where.SetValue( initial_directory ) where_sizer.Add( self.where, 0 ) where_sizer.Add( ( 70, 20 ), 0 )#just add empty space self.main_sizer.Add( where_sizer, 0, wx.TOP | wx.ALIGN_RIGHT, 15 ) self.BuildFormatsPanel( ) #confirm_btns_sizer = self.CreateButtonSizer( wx.OK | wx.CANCEL ) #self.main_sizer.Add( confirm_btns_sizer,0, wx.ALIGN_RIGHT| wx.RIGHT | wx.LEFT | wx.BOTTOM, 20 ) self.CreateOkCancelBtns( ) self.SetSizer( self.main_sizer ) self.Layout( )
def __init__(self, parent, ID, log): wx.Panel.__init__(self, parent, ID) self.log = log self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), changeCallback=self.fbbCallback) self.fbbh = filebrowse.FileBrowseButtonWithHistory( self, -1, size=(450, -1), changeCallback=self.fbbhCallback) self.dbb = filebrowse.DirBrowseButton(self, -1, size=(450, -1), changeCallback=self.dbbCallback) self.fbbh.callCallback = False self.fbbh.SetHistory( ['You', 'can', 'put', 'some', 'filenames', 'here'], 4) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.fbb, 0, wx.ALL, 5) sizer.Add(self.fbbh, 0, wx.ALL, 5) sizer.Add(self.dbb, 0, wx.ALL, 5) box = wx.BoxSizer() box.Add(sizer, 0, wx.ALL, 20) self.SetSizer(box)
def __init__(self, parent, log): wx.Panel.__init__(self, parent) self.log = log self.dbb = filebrowse.DirBrowseButton(self, -1, size=(450, -1), buttonText=u'瀏覽', labelText=u'圖片根目錄:', changeCallback=self.dbbCallback) b = wx.Button(self, 40, u'RUN', (500, 28), style=wx.NO_BORDER) b.SetToolTipString("Run OCR\n") self.Bind(wx.EVT_BUTTON, self.OnClick, b) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.dbb, 0, wx.ALL, 5) box = wx.BoxSizer() box.Add(sizer, 0, wx.ALL, 20) b.SetInitialSize() self.SetSizer(box) x1 = wx.CheckBox(self, 1, u"日期", (35, 100), (150, 20)) x2 = wx.CheckBox(self, 2, u"時間", (35, 120), (150, 20)) x3 = wx.CheckBox(self, 3, u"車牌", (35, 140), (150, 20)) x4 = wx.CheckBox(self, 4, u"速限", (35, 160), (150, 20)) x5 = wx.CheckBox(self, 5, u"速度", (35, 180), (150, 20)) self.Bind(wx.EVT_CHECKBOX, self.OnClick2, x1) self.Bind(wx.EVT_CHECKBOX, self.OnClick2, x2) self.Bind(wx.EVT_CHECKBOX, self.OnClick2, x3) self.Bind(wx.EVT_CHECKBOX, self.OnClick2, x4) self.Bind(wx.EVT_CHECKBOX, self.OnClick2, x5)
def __init__(self, parent, log): wx.Panel.__init__(self, parent) self.log = log self.dbb = filebrowse.DirBrowseButton(self, -1, size=(450, -1), buttonText=u'瀏覽', labelText=u'圖片檔案位置:', changeCallback=self.dbbCallback) self.dbb1 = filebrowse.FileBrowseButton( self, -1, size=(450, -1), buttonText=u'瀏覽', labelText=u'DBF檔案位置:', changeCallback=self.dbbCallback) b = wx.Button(self, 40, u'RUN', (500, 28), style=wx.NO_BORDER) self.Bind(wx.EVT_BUTTON, self.OnClick, b) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.dbb, 0, wx.ALL, 5) sizer.Add(self.dbb1, 0, wx.ALL, 5) box = wx.BoxSizer() box.Add(sizer, 0, wx.ALL, 20) b.SetInitialSize() self.SetSizer(box)
def __init__(self, parent, *args, title=None, subTitle='', **kw): wx.Panel.__init__(self, parent, id=-1) WorkspaceHelper.__init__(self) self.info = wx.InfoBar(self) # self.parent = parent self.title = title vBox = wx.BoxSizer(wx.VERTICAL) vBoxFooter = wx.BoxSizer(wx.VERTICAL) ###################################3333333333 self.headerPanel = HeaderPanel(self, title=title, subTitle=subTitle, imageName='import_wiz.png') startDirectory = self.getWorkpacePath() self.dbb = filebrowse.DirBrowseButton(self, -1, size=(450, -1), changeCallback=self.dbbCallback, startDirectory=startDirectory, dialogTitle=startDirectory, labelText="Workspace: ") self.dbb.SetValue(startDirectory) self.buttons = CreateButtonPanel(self) #################################################################### vBoxFooter.Add(self.buttons, 0, wx.EXPAND, 0) vBox.Add(self.headerPanel, 0, wx.EXPAND, 0) vBox.Add(self.info, 0, wx.EXPAND) vBox.Add(self.dbb, 1, wx.EXPAND, 0) vBox.Add(vBoxFooter, 0, wx.EXPAND | wx.ALL, 5) self.SetSizer(vBox) self.SetAutoLayout(True)
def __init__(self, parent, log=None): self.log = log wx.Panel.__init__(self, parent, -1) self.newPath = Workspace().path vBox = wx.BoxSizer(wx.VERTICAL) hBox1 = wx.BoxSizer(wx.HORIZONTAL) hBox2 = wx.BoxSizer(wx.HORIZONTAL) hBox3 = wx.BoxSizer(wx.HORIZONTAL) hBox4 = wx.BoxSizer(wx.HORIZONTAL) page = ''' <html> <body> <h4>Select a workspace</h4> Opal stores your books in a folder called workspace. \n Choose a workspace folder to use for this session. </body> </html> ''' ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, size=(550, 100)) if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo: ctrl.SetStandardFonts() ctrl.SetPage(page) self.info = wx.InfoBar(self) # TODO self.dbb = filebrowse.DirBrowseButton( self, -1, size=(450, -1), changeCallback=self.dbbCallback, startDirectory=Workspace().path ) print '----otherWorkspace------', Workspace().path if Workspace().path: self.dbb.textControl.SetValue(Workspace().path) okButton = wx.Button(self, -1, "OK") cancelButton = wx.Button(self, -1, "Cancel") self.Bind(wx.EVT_BUTTON, self.okBtnClicked, okButton) self.Bind(wx.EVT_BUTTON, self.cancelBtnClicked, cancelButton) hBox2.Add(ctrl, 0, wx.ALL | wx.EXPAND, 5) vBox.Add(self.info, 0, wx.EXPAND) hBox4.Add(self.dbb, 0, wx.ALL | wx.EXPAND, 5) hBox3.Add(okButton, 0, wx.ALL | wx.RIGHT, 5) hBox3.Add(cancelButton, 0, wx.ALL | wx.RIGHT, 5) vBox.Add(hBox2, 0, wx.EXPAND) vBox.Add(hBox1, 0, wx.EXPAND) vBox.Add(hBox4, 0, wx.EXPAND) vBox.Add(hBox3, 0, wx.ALL | wx.RIGHT, 5) self.SetSizer(vBox) vBox.Fit(self)
def __init__(self, parent, fps, frames, loop, outdir): """ConfigDlg的构造函数""" wx.Dialog.__init__(self, parent, -1, "设置录像参数", size=(400, 270)) sizer = wx.BoxSizer() # 创建布局管理器 grid = wx.GridBagSizer(10, 10) subgrid = wx.GridBagSizer(10, 10) # 帧率 text = wx.StaticText(self, -1, "帧率:") grid.Add(text, (0, 0), flag=wx.ALIGN_RIGHT | wx.TOP, border=3) self.fps = wx.SpinCtrl(self, -1, size=(80, -1)) self.fps.SetValue(fps) grid.Add(self.fps, (0, 1), flag=wx.LEFT, border=8) # 最大帧数 text = wx.StaticText(self, -1, "最大帧数") grid.Add(text, (1, 0), flag=wx.ALIGN_RIGHT | wx.TOP, border=3) self.frames = wx.SpinCtrl(self, -1, size=(80, -1)) self.frames.SetValue(frames) grid.Add(self.frames, (1, 1), flag=wx.LEFT, border=8) # 循环次数 text = wx.StaticText(self, -1, "循环次数") grid.Add(text, (2, 0), flag=wx.ALIGN_RIGHT | wx.TOP, border=3) self.loop = wx.SpinCtrl(self, -1, size=(80, -1)) self.loop.SetValue(loop) grid.Add(self.loop, (2, 1), flag=wx.LEFT, border=8) # 输出路径 text = wx.StaticText(self, -1, "输出目录") grid.Add(text, (3, 0), flag=wx.TOP, border=8) self.outdir = filebrowse.DirBrowseButton(self, -1, labelText="", startDirectory=outdir, buttonText="浏览", toolTip="请选择输出路径") self.outdir.SetValue(outdir) grid.Add(self.outdir, (3, 1), flag=wx.EXPAND, border=0) okBtn = wx.Button(self, wx.ID_OK, "确定") subgrid.Add(okBtn, (0, 0), flag=wx.ALIGN_RIGHT) canelBtn = wx.Button(self, wx.ID_CANCEL, "取消") subgrid.Add(canelBtn, (0, 1)) grid.Add(subgrid, (4, 0), (1, 2), flag=wx.ALIGN_CENTER | wx.TOP, border=10) # 界面总成 grid.AddGrowableCol(1) sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 20) self.SetSizer(sizer) self.Layout() self.CenterOnScreen()
def _checkArg(self, name): """Create an option in WX :param str name: the name of command to parse """ sizer = wx.BoxSizer(wx.HORIZONTAL) # check what is the module if name == 'modis_convert.py' or name == 'modis_parse.py' or \ name == 'modis_quality.py': ltext = 'File HDF [%s]' % STREQUIRED self.htext = 'Select HDF file' self.typecont = 'file' elif name == 'modis_download.py' or \ name == 'modis_download_from_list.py': ltext = 'Destination Folder [%s]' % STREQUIRED self.htext = 'Select directory where save MODIS files' self.typecont = 'dir' elif name == 'modis_mosaic.py': ltext = 'File containig HDF list [%s]' % STREQUIRED self.htext = 'Select file containig a list of MODIS file' self.typecont = 'file' elif name == 'modis_multiparse.py': ltext = 'List of HDF file [%s]' % STREQUIRED self.htext = 'List of MODIS files' self.typecont = 'mfile' else: ltext = 'Test' self.htext = 'Test' label = wx.StaticText(self, -1, ltext) label.SetHelpText(self.htext) sizer.Add(item=label, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) if self.typecont == 'dir': self.arg_ctrl = filebrowse.DirBrowseButton( self, id=wx.ID_ANY, labelText='', dialogTitle=self.htext, buttonText='Browse', startDirectory=os.getcwd(), changeCallback=self.onText, size=TEXTCTRL_SIZE) elif self.typecont in ['file', 'mfile']: self.arg_ctrl = filebrowse.FileBrowseButton( self, id=wx.ID_ANY, fileMask='*', labelText='', dialogTitle=self.htext, buttonText='Browse', startDirectory=os.getcwd(), fileMode=wx.OPEN, changeCallback=self.onText, size=TEXTCTRL_SIZE) sizer.Add(item=self.arg_ctrl, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) return sizer
def create_control(self, settings): c = filebrowse.DirBrowseButton( self.container, -1, size=(self.default_width, -1), labelText="", changeCallback=self.on_directory_changed) return c
def __init__(self): wx.Dialog.__init__(self, None, -1, title="Output results", size=(450, 250)) self.startDirectory = os.getcwd() # make sizers sizerMainFrame = wx.BoxSizer(wx.VERTICAL) self.FlBrwsBtnsSizer = wx.BoxSizer(wx.VERTICAL) sizerBtns = wx.BoxSizer(wx.HORIZONTAL) # make buttons self.FlBrwsBtn = filebrowse.DirBrowseButton( self, id=wx.NewId(), labelText="Output path", size=(400, -1), buttonText="Browse...", startDirectory=self.startDirectory) btnOK = wx.Button(self, wx.ID_OK, label="&OK") btnCancel = wx.Button(self, wx.ID_CANCEL, label="&Cancel") # self.Bind(wx.EVT_BUTTON, self.OnOK, btnOK) # set sizers of list file browse buttons self.FlBrwsBtnsSizer.Add(wx.Size(1, 20)) self.FlBrwsBtnsSizer.Add(self.FlBrwsBtn, flag=wx.ALL | wx.ALIGN_LEFT | wx.EXPAND, border=5) # set sizers of OK and Cancel buttons sizerBtns.Add(wx.Size(1, 20)) sizerBtns.Add(btnCancel, flag=wx.ALL, border=5) sizerBtns.Add(btnOK, flag=wx.ALL, border=5) # set sizerMainFrame sizerMainFrame.Add(self.FlBrwsBtnsSizer) sizerMainFrame.Add(sizerBtns) self.SetSizer(sizerMainFrame) self.Fit() self.Layout() if self.ShowModal() == wx.ID_OK: print "OK" self.status = True self.Destroy() else: print "Cancel" self.status = False self.Destroy()
def box_os_access(self, panel): box = wx.StaticBox(panel, -1, 'Operating system access') sizerBox = wx.StaticBoxSizer(box, wx.VERTICAL) sizerOs = wx.GridBagSizer() self.gridCount = 0 self.tmpPath = wx.TextCtrl(panel, -1, size=SIZE) self.tmpPath.SetToolTip( wx.ToolTip('Remote absolute path of temporary files directory')) self.set_label(sizerOs, panel, 'tmp-path', self.tmpPath) self.osCmd = wx.TextCtrl(panel, -1, size=SIZE) self.osCmd.SetToolTip( wx.ToolTip('Execute an operating system command')) self.set_label(sizerOs, panel, 'os-cmd', self.osCmd) self.msfPath = fbrows.DirBrowseButton(panel, -1) self.msfPath.SetLabel('msf-path') self.msfPath.SetToolTip( wx.ToolTip('Local path where Metasploit Framework is installed')) self.osShell = wx.CheckBox(panel, -1, 'os-shell') self.osShell.SetToolTip( wx.ToolTip('Prompt for an interactive operating system shell')) sizerOs.Add(self.osShell, (self.gridCount, 2)) self.gridCount += 1 self.osPwn = wx.CheckBox(panel, -1, 'os-pwn') self.osPwn.SetToolTip( wx.ToolTip('Prompt for an out-of-band shell, meterpreter or VNC')) sizerOs.Add(self.osPwn, (self.gridCount, 2)) self.gridCount += 1 self.osSmb = wx.CheckBox(panel, -1, 'os-smbrelay') self.osSmb.SetToolTip( wx.ToolTip( 'One click prompt for an OOB shell, meterpreter or VNC')) sizerOs.Add(self.osSmb, (self.gridCount, 2)) self.gridCount += 1 self.osBof = wx.CheckBox(panel, -1, 'os-bof') self.osBof.SetToolTip( wx.ToolTip('Stored procedure buffer overflow exploitation')) sizerOs.Add(self.osBof, (self.gridCount, 2)) self.gridCount += 1 self.privEsc = wx.CheckBox(panel, -1, 'priv-esc') self.privEsc.SetToolTip( wx.ToolTip('Database process\' user privilege escalation')) sizerOs.Add(self.privEsc, (self.gridCount, 2)) sizerBox.Add(self.msfPath, 0, wx.EXPAND) sizerBox.Add(sizerOs, 1, wx.EXPAND) return sizerBox
def __init__(self, parent, title): super(MainFrame, self).__init__(parent, title=title, size=(500, 400)) # Set up the menu functionality menubar = wx.MenuBar() filemenu = wx.Menu() menubar.Append(filemenu,"&File") self.SetMenuBar(menubar) # The box sizer that all widgets will fit in vbox = wx.BoxSizer(wx.VERTICAL) # Set up the playlist selection self.selected_playlists = [] itunes = iTunes() self.playlists = [p.name for p in itunes.playlists() if p.is_music_playlist()] self.plbox = wx.CheckListBox(self, 3, choices=self.playlists) self.Bind(wx.EVT_CHECKLISTBOX, self.set_playlists, id=3) # The directory browser dirbrowse = filebrowse.DirBrowseButton(self, labelText='Destination', startDirectory='/Volumes', toolTip='Choose where to sync', changeCallback=self.set_destination, id=2) dirbrowse.SetValue('Choose where to sync') dirbrowse.Disable() # The choice of what to do self.choice = wx.Choice(self, choices=MainFrame.options, id=1) self.Bind(wx.EVT_CHOICE, self.set_choice, id=1) # Our sync button self.sync_button = wx.Button(self, 4, 'Sync') self.Bind(wx.EVT_BUTTON, self.on_sync, id=4) vbox.AddMany([ (dirbrowse, 0, wx.EXPAND|wx.ALL, 5), (self.choice, 0, wx.EXPAND|wx.ALL, 5), #(dirbrowse, 0, wx.EXPAND|wx.ALL, 5), # Set the proportion to 1 because we want the listbox to resize VERTICAL and HORIZONTAL (self.plbox, 1, wx.EXPAND|wx.ALL, 5), (self.sync_button, 0, wx.ALIGN_BOTTOM|wx.ALIGN_RIGHT|wx.ALL, 5) ]) # We're placing a boxsizer inside of a boxsizer so that we can get # a nice 20 pixel border (padding) around all elements. mainbox = wx.BoxSizer(wx.VERTICAL) mainbox.Add(vbox, 1, wx.EXPAND|wx.ALL, 20) # We have a default where all items are checked indexes = [idx for (idx,p) in enumerate(self.playlists)] self.plbox.SetChecked(indexes) self.SetSizer(mainbox) self.Show()
def __init__(self, parent, id, configParser, configStringTextNodeVar, _size): """ """ # Call superclass constructors ConfigControl.__init__(self, parent, configParser, configStringTextNodeVar) wx.BoxSizer.__init__(self, wx.HORIZONTAL) # Controls if self.configVar.setting.choose == 'file': file = self.configVar.getVal() #path = file[:file.rfind(os.path.sep)] #file = file[file.rfind(os.path.sep):] self.ctrl = filebrowse.FileBrowseButton( self.parent, -1, size=_size, labelText='', buttonText='Browse', toolTip=self.configVar.setting.description, startDirectory=file, initialValue=file, changeCallback=self.callback) self.ctrl.textControl.Bind(wx.EVT_KILL_FOCUS, self.callback) elif self.configVar.setting.choose == 'path': self.ctrl = filebrowse.DirBrowseButton( self.parent, -1, size=_size, labelText='', toolTip=self.configVar.setting.description, startDirectory=os.path.join(os.getcwd(), self.configVar.getVal()), changeCallback=self.callback) self.ctrl.textControl.Bind(wx.EVT_KILL_FOCUS, self.callback) self.ctrl.SetValue( os.path.join(os.getcwd(), self.configVar.getVal()), 0) else: self.ctrl = wx.TextCtrl(self.parent, id, self.configVar.getVal(), size=_size) self.ctrl.Bind(wx.EVT_KILL_FOCUS, self.callback) textLabel = wx.StaticText(self.parent, -1, self.configVar.setting.displayName) # Tooltip textLabel.SetToolTip(wx.ToolTip(self.configVar.setting.description)) self.ctrl.SetToolTip(wx.ToolTip(self.configVar.setting.description)) # Add controll to the sizer self.Add(textLabel, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTRE_VERTICAL) self.Add(self.ctrl, 1, wx.EXPAND | wx.ALL, 5) # Binding self.ctrl.Bind(wx.EVT_KEY_DOWN, self.onOK)
def makePanel(self, parent, name): """ """ tp = wx.Panel(parent, -1, style=wx.TAB_TRAVERSAL) self.virtualw = wx.ScrolledWindow(tp) sz1 = wx.BoxSizer(wx.VERTICAL) titleFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD) items = [] for option in options.getOptionsNames(name): option_name = option option_value = str(options.GetOption(option_name)) option_description = options.getOptionDescription(option_name) items.append( wx.StaticText(self.virtualw, -1, '\nSet value of the variable: %s' % option_name)) items[-1].SetFont(titleFont) items.append(wx.StaticText(self.virtualw, -1, option_description)) if "FOLDER" in option_name.upper(): items.append( filebrowse.DirBrowseButton(self.virtualw, -1, size=(400, -1), changeCallback=partial( self.__saveValue, option_name), startDirectory=".")) items.append((wx.StaticLine(self.virtualw), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)) else: #for boolean first choice is always True, second choice always False items.append(wx.TextCtrl(self.virtualw, -1, value=option_value)) items[-1].Bind(wx.EVT_TEXT, partial(self.__saveValue, option_name)) items.append((wx.StaticLine(self.virtualw), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)) sz1.AddMany(items) self.virtualw.SetSizer(sz1) sz1.Fit(self.virtualw) self.virtualw.SetScrollRate(20, 20) TreeBookPanelSizer = wx.BoxSizer() TreeBookPanelSizer.Add(self.virtualw, 1, wx.GROW | wx.EXPAND, 0) tp.SetSizer(TreeBookPanelSizer) return tp
def __init__(self, parent, title='define title'): WizardPageSimple.__init__(self, parent) self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) titleText = wx.StaticText(self, -1, title) fs = self.GetFont().GetPointSize() bf = wx.Font(fs + 4, wx.SWISS, wx.NORMAL, wx.BOLD) nf = wx.Font(fs + 2, wx.SWISS, wx.NORMAL, wx.NORMAL) titleText.SetFont(bf) self.sizer.Add(titleText, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.ALL, 5) #################################################################### self.panel = wx.Panel(self, -1) vbox1 = wx.BoxSizer(wx.VERTICAL) hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox3 = wx.BoxSizer(wx.HORIZONTAL) connectionNameLabel = wx.StaticText(self.panel, -1, "Connection name : ") self.connectionNameTextCtrl = wx.TextCtrl(self.panel, size=(300, -1)) dbFileNameLabel = wx.StaticText(self.panel, -1, "Database File name : ") self.dbFileNameTextCtrl = wx.TextCtrl(self.panel, size=(300, -1)) self.connectionNameTextCtrl.Bind(wx.EVT_TEXT, self.onConnectionName) hbox1.Add(connectionNameLabel) hbox1.Add(self.connectionNameTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, 1) hbox3.Add(dbFileNameLabel) hbox3.Add(self.dbFileNameTextCtrl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, 1) import wx.lib.filebrowsebutton as filebrowse self.dbb = filebrowse.DirBrowseButton(self.panel, -1, size=(450, -1), changeCallback=self.dbbCallback, startDirectory=wx.GetHomeDir()) self.dbb.SetValue(wx.GetHomeDir(), self.dbbCallback) # self.markFile = brows.FileBrowseButton(self.panel, labelText="File path :", fileMode=wx.FD_OPEN, size=(400, 30), toolTip='Type database filename or click browse to choose file') # self.markFile.Bind(wx.EVT_TEXT, self.onMarkFile) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox2.Add(self.dbb) vbox1.Add(hbox1) vbox1.Add(hbox2) vbox1.Add(hbox3) self.panel.SetSizer(vbox1) self.sizer.Add(self.panel, 0, wx.ALL, 5)
def __init__(self, panel, parent): wx.BoxSizer.__init__(self, wx.HORIZONTAL) self.parent = parent self.config = get_param_config() self.initDir = self.config.getComputeDir() self.saveTitle = wx.StaticText(panel, label="Choose folder to save files", size=fbbTitleSize) self.Add(self.saveTitle, flag=wx.ALIGN_CENTER_VERTICAL) self.savePath = fbb.DirBrowseButton(panel, labelText="", size=fbbSize, startDirectory=self.initDir) self.Add(self.savePath)
def __init__(self, name, pref_item, size, parent=None): ''' The constructor. Parameters ---------- name : String The name of the field. It is used as the field label. pref_item : :class:`~psysmon.core.preferences.PrefItem` The key of the base option edited by this field. size : tuple (width, height) The size of the field. parent : The parent wxPyton window of this field. ''' Field.__init__(self, parent=parent, name=name, pref_item=pref_item, size=size) # Create the field label. self.labelElement = StaticText(parent=self, ID=wx.ID_ANY, label=self.label, style=wx.ALIGN_RIGHT) # Create the field text control. if pref_item.tool_tip is None: pref_item.tool_tip = 'Type filename or click browse to choose file.' self.controlElement = filebrowse.DirBrowseButton( self, wx.ID_ANY, labelText='', changeCallback=self.onValueChange, startDirectory=pref_item.start_directory, toolTip=pref_item.tool_tip) # Add the gui elements to the field. self.addLabel(self.labelElement) self.addControl(self.controlElement) # Set the value of the control element. self.setControlElementValue()
def __init__(self, parent, fps, loop, outdir): """ ConfigDlg的构造函数 """ wx.Dialog.__init__(self, parent, -1, "设置", size=(450, 200)) # 创建布局管理器 sizer = wx.BoxSizer() grid = wx.GridBagSizer(10, 10) # 帧率 text = wx.StaticText(self, -1, "帧率") grid.Add(text, (0, 0), flag=wx.TOP | wx.ALIGN_RIGHT, border=5) self.fps = wx.SpinCtrl(self, -1) self.fps.SetValue(fps) grid.Add(self.fps, (0, 1), flag=wx.EXPAND | wx.LEFT, border=10) # 是否循环 self.loop = wx.CheckBox(self, -1, "是否循环") self.loop.SetValue(loop) grid.Add(self.loop, (0, 2), flag=wx.EXPAND) # 输出路径 text = wx.StaticText(self, -1, "输出目录") grid.Add(text, (1, 0), flag=wx.TOP, border=10) self.outdir = filebrowse.DirBrowseButton(self, -1, labelText="", buttonText="浏览", toolTip="请选择输出路径") self.outdir.SetValue(outdir) grid.Add(self.outdir, (1, 1), (1, 2), flag=wx.EXPAND) # 按钮,直接使用内置的ID,可以省略事件处理函数,使用wxPython内置的事件处理 subgrid = wx.GridBagSizer(10, 10) okBtn = wx.Button(self, wx.ID_OK, "确定") subgrid.Add(okBtn, (0, 0), flag=wx.ALIGN_RIGHT) canelBtn = wx.Button(self, wx.ID_CANCEL, "取消") subgrid.Add(canelBtn, (0, 1)) grid.Add(subgrid, (2, 0), (1, 3), flag=wx.ALIGN_CENTER) # 界面总成 grid.AddGrowableCol(2) sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 20) self.SetSizer(sizer) self.Layout() self.CenterOnScreen()
def __init__(self, parent, ID, log): wx.Panel.__init__(self, parent, ID) self.log = log self.fbb = filebrowse.FileBrowseButton(self, -1, (20, 20), (450, -1), changeCallback=self.fbbCallback) self.fbbh = filebrowse.FileBrowseButtonWithHistory( self, -1, (20, 50), (450, -1), changeCallback=self.fbbhCallback) self.dbb = filebrowse.DirBrowseButton(self, -1, (20, 80), (450, -1), changeCallback=self.dbbCallback) self.fbbh.SetHistory( ['You', 'can', 'put', 'some', 'filenames', 'here'])
def makePanel(self, parent, name): # Make a new panel tp = wx.Panel(parent, -1, style = wx.TAB_TRAVERSAL) # The panel contains a window, allowing us to scroll self.virtualw = wx.ScrolledWindow(tp) sz1 = wx.BoxSizer(wx.VERTICAL) titleFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD) items = [] # Put all of the options on the page for option in options.getOptionsNames(name): option_name = option option_value= str(options.GetOption(option_name)) option_description = options.getOptionDescription(option_name) # Display option name and description items.append ( wx.StaticText(self.virtualw, -1, '\nSet value of the variable: %s' % option_name)) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self.virtualw, -1, option_description) ) # If the option is regarding a folder, make a Browse button if "FOLDER" in option_name.upper(): items.append ( filebrowse.DirBrowseButton(self.virtualw, -1, size=(400, -1), changeCallback = partial(self.__saveValue, option_name), startDirectory="." )) items.append ( (wx.StaticLine(self.virtualw), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) # Add a text field for the user to change the option else: #for boolean first choice is always True, second choice always False items.append ( wx.TextCtrl (self.virtualw, -1, value=option_value)) items[-1].Bind (wx.EVT_TEXT, partial (self.__saveValue, option_name) ) items.append ( (wx.StaticLine(self.virtualw), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) # Put all of them in a boxsizer sz1.AddMany (items) self.virtualw.SetSizer(sz1) sz1.Fit(self.virtualw) # fit to window self.virtualw.SetScrollRate(20,20) TreeBookPanelSizer = wx.BoxSizer() TreeBookPanelSizer.Add(self.virtualw, 1, wx.GROW | wx.EXPAND, 0) tp.SetSizer(TreeBookPanelSizer) return tp
def addControls(self, parent): parent.SetSizerType("vertical") self.folderCtrl = filebrowse.DirBrowseButton( parent, -1, # Translators: label of an edit control labelText=_("Select a folder:"), # Translators: label of a button buttonText=("Browse..."), toolTip="", ) wx.StaticText(parent, -1, _("Reading List")) self.categoryCombo = wx.ComboBox( parent, -1, choices=[cat.name for cat in Category.get_all()] ) self.categoryCombo.SetSizerProps(expand=True) # Translators: label of a check box self.addToFTSCheckbox = wx.CheckBox( parent, -1, _("Add to full-text search index") ) self.addToFTSCheckbox.SetValue(True)
def __init__(self, parent, log): wx.Panel.__init__(self, parent) self.log = log self.dbb = filebrowse.DirBrowseButton(self, -1, size=(450, -1), buttonText=u'瀏覽', labelText=u'建檔根目錄:', changeCallback=self.dbbCallback) b = wx.Button(self, 40, u'開始建立xlsx檔', (355, 70), style=wx.NO_BORDER) b.SetToolTipString( "This button has a style flag of wx.NO_BORDER.\n" "On some platforms that will give it a flattened look.") self.Bind(wx.EVT_BUTTON, self.OnClick, b) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.dbb, 0, wx.ALL, 5) box = wx.BoxSizer() box.Add(sizer, 0, wx.ALL, 20) b.SetInitialSize() self.SetSizer(box)
def InitUI(self): panel = wx.Panel(self) sizer = wx.GridBagSizer(4, 4) text_setting = wx.StaticText(panel, label='Settings') sizer.Add(text_setting, pos=(0, 0), flag=wx.TOP | wx.LEFT | wx.BOTTOM, border=10) line = wx.StaticLine(panel) sizer.Add(line, pos=(1, 0), span=(1, 4), flag=wx.EXPAND | wx.BOTTOM, border=10) self.btn_downfolder = filebrowse.DirBrowseButton( panel, labelText='Download Folder', startDirectory=GLOBAL_SETTING.dpath, changeCallback=self.DbbCallback) sizer.Add(self.btn_downfolder, pos=(2, 0), span=(2, 4), flag=wx.EXPAND, border=10) line = wx.StaticLine(panel) sizer.Add(line, pos=(3, 0), span=(1, 4), flag=wx.EXPAND | wx.BOTTOM | wx.TOP, border=10) btn_ok = wx.Button(panel, label='Ok') sizer.Add(btn_ok, pos=(4, 2)) btn_cancel = wx.Button(panel, label='Cancel') sizer.Add(btn_cancel, pos=(4, 3)) sizer.AddGrowableCol(1) panel.SetSizer(sizer) btn_ok.Bind(wx.EVT_BUTTON, self.OnOkClicked) btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancelClicked) self.btn_downfolder.SetValue(GLOBAL_SETTING.dpath)
def RunWizard(self): Wizard = wiz.Wizard(self.parent, -1, "RToolDS Setup Wizard", GFX.getGFX_WizardBitmap(), style=wx.DEFAULT_DIALOG_STYLE | wx.SYSTEM_MENU | wx.CLOSE_BOX) Page1 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 1/7") Page2 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 2/7") Page3 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 3/7") Page4 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 4/7") Page5 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 5/7") Page6 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 6/7") Page7 = TitledPage(Wizard, _("RToolDS Setup - Page") + " 7/7") # dialogTitle = _("Select Device Directory") + " : ", labelText = _("Device") + " : ") Page1.sizer.Add( wx.StaticText(Page1, -1, "Welcome to RToolDS Initial Configuration\n")) Page1.sizer.Add( wx.StaticText(Page1, -1, _("Please Select Your ROM Directory :"))) if sys.platform == "linux2" or sys.platform == "darwin": self.ROM_Path = filebrowse.DirBrowseButton( Page1, -1, labelText="", dialogTitle=_("Select ROMs Directory") + " : ", newDirectory=True, startDirectory=os.path.expanduser("~/")) self.ROM_Path.SetValue(os.path.expanduser("~/")) else: self.ROM_Path = filebrowse.DirBrowseButton( Page1, -1, labelText="", dialogTitle=_("Select ROMs Directory") + " : ", newDirectory=True) Page1.sizer.Add(self.ROM_Path, 0, wx.EXPAND | wx.TOP, 10) self.SubDirs = wx.RadioBox(Page1, -1, _('Search Sub-Directories?'), choices=[_('No'), _('Yes')]) self.SubDirs.SetStringSelection(_("Yes")) Page1.sizer.Add(self.SubDirs) Page1.sizer.Add( wx.StaticText( Page1, -1, "\n" + _("RToolDS accepts Uncompressed, Zip, 7-Zip and RAR archived ROM files." ))) Page2.sizer.Add( wx.StaticText( Page2, -1, _("Select a Default Save Game Database Directory :"))) self.Save_Path = filebrowse.DirBrowseButton( Page2, -1, labelText="", newDirectory=True, dialogTitle=_("Select Save Game Database Directory") + " : ", startDirectory=os.path.join(os.getcwd(), "cache", "saves")) # if sys.platform != "linux2": self.Save_Path.SetValue(os.path.join(os.getcwd(), "cache", "saves")) Page2.sizer.Add(self.Save_Path, 0, wx.EXPAND | wx.TOP, 10) Page2.sizer.Add( wx.StaticText( Page2, -1, "\n" + _("Note: Do not select a previous linker device save directory" ))) Page2.sizer.Add( wx.StaticText( Page2, -1, _("when choosing a location! Previous linker device saves will" ))) Page2.sizer.Add( wx.StaticText( Page2, -1, _("need to be imported within RToolDS before use, and any current" ))) Page2.sizer.Add( wx.StaticText( Page2, -1, _("saves within the chosen directory will not be automatically detected." ))) Page3.sizer.Add( wx.StaticText(Page3, -1, _("Select a Default Image Directory :"))) # Page3.sizer.Add ( wx.StaticText ( Page3, -1, _( "(It is Safe to Keep the Default)" ) ) ) self.Image_Path = filebrowse.DirBrowseButton( Page3, -1, labelText="", newDirectory=True, dialogTitle=_("Select Images Directory") + " : ", startDirectory=os.path.join(os.getcwd(), "cache", "img")) # if sys.platform != "linux2": self.Image_Path.SetValue(os.path.join(os.getcwd(), "cache", "img")) Page3.sizer.Add(self.Image_Path, 0, wx.EXPAND | wx.TOP, 10) Page3.sizer.Add( wx.StaticText(Page3, -1, "\n" + _("Select a Default NFO Directory :"))) self.NFO_Path = filebrowse.DirBrowseButton( Page3, -1, labelText="", newDirectory=True, dialogTitle=_("Select NFO Directory") + " : ", startDirectory=os.path.join(os.getcwd(), "cache", "nfo")) # if sys.platform != "linux2": self.NFO_Path.SetValue(os.path.join(os.getcwd(), "cache", "nfo")) Page3.sizer.Add(self.NFO_Path, 0, wx.EXPAND | wx.TOP, 10) Page3.sizer.Add( wx.StaticText( Page3, -1, "\n" + _("Note: Keeping the default directories is recommended."))) Page3.sizer.Add( wx.StaticText( Page3, -1, _("Directories will contain ROM images and NFO files,"))) Page3.sizer.Add( wx.StaticText( Page3, -1, _("downloaded during the update process, which are associated") )) Page3.sizer.Add( wx.StaticText(Page3, -1, _("with your ROM collection."))) self.Use_Trimmed = wx.RadioBox(Page4, -1, _('Enable ROM Trimming by default?'), choices=[_('No'), _('Yes')]) self.Use_Trimmed.SetStringSelection(_("Yes")) Page4.sizer.Add(self.Use_Trimmed) Page4.sizer.Add( wx.StaticText( Page4, -1, "\n" + _("Enabling this option saves memory, as all ROM files are"))) Page4.sizer.Add( wx.StaticText(Page4, -1, _("compressed before being copied to the device."))) self.DLGFX = wx.RadioBox( Page5, -1, _('Update Image and NFO Database upon initial start-up?'), choices=[_('No'), _('Yes')]) self.DLGFX.SetStringSelection(_("No")) Page5.sizer.Add(self.DLGFX) Page5.sizer.Add( wx.StaticText( Page5, -1, "\n" + _("Warning: This process will take a long time and requires"))) Page5.sizer.Add( wx.StaticText( Page5, -1, _("an Internet connection! This process includes updating Images and" ))) Page5.sizer.Add( wx.StaticText(Page5, -1, _("NFO files associated with your ROM collection."))) self.Find_Unknown = wx.RadioBox( Page6, -1, _('Enable Unknown/Homebrew ROM File Detection?'), choices=[_('No'), _('Yes')]) self.Find_Unknown.SetStringSelection(_("Yes")) Page6.sizer.Add(self.Find_Unknown) Page6.sizer.Add( wx.StaticText( Page6, -1, "\n" + _("Enabling this option allows RToolDS to detect ROMs which are not" ))) Page6.sizer.Add( wx.StaticText( Page6, -1, _("categorised in our database. This option is recommended and is required" ))) Page6.sizer.Add( wx.StaticText( Page6, -1, _("to detect newly released ROMs and uncategorised homebrew files." ))) Page7.sizer.Add( wx.StaticText(Page7, -1, _("Select Your Linker Device Drive :"))) self.Device_Path = filebrowse.DirBrowseButton( Page7, -1, labelText="", dialogTitle=_("Select Device Directory") + " : ", newDirectory=True) Page7.sizer.Add(self.Device_Path, 0, wx.EXPAND | wx.TOP, 10) Page7.sizer.Add( wx.StaticText(Page7, -1, "\n" + _("Select Your Linker Device Type :"))) self.Default_Device = wx.Choice(Page7, -1, choices=[]) for Device in Config.Config["Devices"]: if Device[2] != "": self.Default_Device.Append(Device[2]) Page7.sizer.Add(self.Default_Device, 0, wx.EXPAND | wx.TOP | wx.LEFT, 10) Page7.sizer.Add( wx.StaticText( Page7, -1, "\n" + _("Note: You can leave these options blank and select them at a" ))) Page7.sizer.Add( wx.StaticText( Page7, -1, _("later time from the options menu. Completing these selections enables" ))) Page7.sizer.Add( wx.StaticText( Page7, -1, _("enhanced RToolDS integration with your linker device."))) Wizard.FitToPage(Page1) wiz.WizardPageSimple_Chain(Page1, Page2) wiz.WizardPageSimple_Chain(Page2, Page3) wiz.WizardPageSimple_Chain(Page3, Page4) wiz.WizardPageSimple_Chain(Page4, Page5) wiz.WizardPageSimple_Chain(Page5, Page6) wiz.WizardPageSimple_Chain(Page6, Page7) Wizard.GetPageAreaSizer().Add(Page1) Wizard.Fit() Wizard.Layout() self.Wizard = Wizard self.Page1 = Page1 self.Page2 = Page2 self.Page3 = Page3 self.Page4 = Page4 self.Page5 = Page5 self.Page6 = Page6 self.Page7 = Page7 Wizard.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnWizPageChanging) Result = Wizard.RunWizard(Page1) del (Wizard) return Result
def __init__(self, parent, user_config, customuser_config): self.temp_userconfig = user_config self.temp_customuserconfig = customuser_config wx.ScrolledWindow.__init__(self, parent) sz1 = wx.BoxSizer(wx.VERTICAL) titleFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD) items = [] items.append ( wx.StaticText(self, -1, '\nSelect the DAM Folder.') ) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self, -1, 'The folder should contain the raw data as output of the DAM monitor.\nFiles should be arranged in a hierarchy of folders of type: \\yyyy\\mm\\dd\\\n') ) items.append ( filebrowse.DirBrowseButton(self, -1, size=(400, -1), changeCallback = partial(self.dbbCallback, 'DAMinput'), startDirectory=self.temp_userconfig['DAMinput'] )) items[-1].SetValue(self.temp_userconfig['DAMinput']) items.append ( (wx.StaticLine(self), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) items.append ( wx.StaticText(self, -1, '\nSelect the Output Folder.') ) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self, -1, 'The folder where the .DAL and .DAD files are going to be saved.') ) items.append ( filebrowse.DirBrowseButton(self, -1, size=(400, -1), changeCallback = partial(self.dbbCallback, 'DAMoutput'), startDirectory=self.temp_userconfig['DAMoutput'] ) ) items[-1].SetValue(self.temp_userconfig['DAMoutput']) items.append ( (wx.StaticLine(self), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) items.append ( wx.StaticText(self, -1, '\nSelect the extension of the input files.') ) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self, -1, 'What is the extension of the file containing the raw data? Default is ".txt".\nLeave blank for none.' )) items.append ( wx.TextCtrl (self, -1, size=(100,-1), name='Select your extension' ) ) items[-1].Bind( wx.EVT_TEXT, partial(self.dbbCallback, 'DAMextension') ) items[-1].SetValue(self.temp_userconfig['DAMextension']) items.append ( (wx.StaticLine(self), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) # Group of radio controls: items.append ( wx.StaticText(self, -1, '\nSelect RAW Data structure.') ) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self, -1, 'Select the version of the input type file.\n') ) grid1 = wx.FlexGridSizer( 0, 1, 0, 0 ) self.DAM_version_radio = [] self.DAM_version_radio.append( wx.RadioButton( self, -1, 'Trikinetics - Channel Files', name = 'Channel', style = wx.RB_GROUP ) ) self.DAM_version_radio.append( wx.RadioButton( self, -1, 'Trikinetics - Monitor Files', name = 'Monitor' ) ) self.DAM_version_radio.append( wx.RadioButton( self, -1, 'pySolo Video - Distance', name = 'pvg_distance' ) ) self.DAM_version_radio.append( wx.RadioButton( self, -1, 'pySolo Video - Virtual Beam Split', name = 'pvg_beam' ) ) self.DAM_version_radio.append( wx.RadioButton( self, -1, 'pySolo Video - Raw Data', name = 'pvg_raw' ) ) #not active yet self.DAM_version_radio[-1].Enable(False) for radio in self.DAM_version_radio: grid1.Add( radio, 0, wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) radio.Bind(wx.EVT_RADIOBUTTON, partial(self.OnGroupSelect, 'DAMtype', bool=False )) ck = ['Channel', 'Monitor', 'pvg_distance', 'pvg_beam'].index(self.temp_userconfig['DAMtype']) self.DAM_version_radio[ck].SetValue(True) items.append (grid1) items.append ( (wx.StaticLine(self), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) # Group of radio controls: items.append ( wx.StaticText(self, -1, '\nAutomatically check for updates on start.') ) items[-1].SetFont(titleFont) items.append ( wx.StaticText(self, -1, 'Do this only if your computer is always connected to the Internet.\n') ) grid1 = wx.FlexGridSizer( 0, 1, 0, 0 ) self.checkUpdate_radio = [] self.checkUpdate_radio.append( wx.RadioButton( self, -1, 'Yes', name = 'checkUpdate', style = wx.RB_GROUP ) ) self.checkUpdate_radio.append( wx.RadioButton( self, -1, 'No', name = 'no_checkUpdate' ) ) for radio in self.checkUpdate_radio: grid1.Add( radio, 0, wx.ALIGN_LEFT|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) radio.Bind(wx.EVT_RADIOBUTTON, partial(self.OnGroupSelect, 'checkUpdate', bool=True )) ck = not self.temp_userconfig['checkUpdate'] self.checkUpdate_radio[ck].SetValue(True) items.append (grid1) items.append ( (wx.StaticLine(self), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )) sz1.AddMany (items) self.SetSizer(sz1) sz1.Fit(self)
def createImageExport(self): """ Creates similar parts of every export dialog """ self.imagePanel = wx.Panel(self, -1, size = (640, 480)) self.imageSizer = wx.GridBagSizer(5, 5) if self.imageMode == 1: self.imageSourcebox = wx.StaticBox(self.imagePanel, -1, "Target for Images") else: self.imageSourcebox = wx.StaticBox(self.imagePanel, -1, "Target for Datasets") self.imageSourceboxsizer = wx.StaticBoxSizer(self.imageSourcebox, wx.VERTICAL) self.imageSourceboxsizer.SetMinSize((600, 100)) initialDir = self.conf.getConfigItem("ExportDirectory", "Paths") if not initialDir: initialDir = "." if self.imageMode == 1: self.browsedir = filebrowse.DirBrowseButton(self.imagePanel, -1, labelText = "Image Directory: ", changeCallback = self.updateListOfImages, startDirectory = initialDir) else: self.browsedir = filebrowse.DirBrowseButton(self.imagePanel, -1, labelText = "Dataset Directory: ", changeCallback = self.updateListOfImages, startDirectory = initialDir) self.sourcesizer = wx.BoxSizer(wx.VERTICAL) self.imageSourceboxsizer.Add(self.browsedir, 0, wx.EXPAND) if self.c > 1: ptr = self.dataUnit.getImageName() + "_C%d" else: ptr = self.dataUnit.getName() if self.t > 1: ptr += "_T%d" if self.imageMode == 1 and self.z > 1: ptr += "_Z%d" self.patternEdit = wx.TextCtrl(self.imagePanel, -1, ptr, size = (300,-1), style = wx.TE_PROCESS_ENTER) self.patternEdit.Bind(wx.EVT_TEXT_ENTER, self.updateListOfImages) self.patternEdit.Bind(wx.EVT_TEXT, self.updateListOfImages) self.patternLbl = wx.StaticText(self.imagePanel, -1, "Filename Pattern: ") self.patternBox = wx.BoxSizer(wx.HORIZONTAL) self.patternBox.Add(self.patternLbl, 1) self.patternBox.Add(self.patternEdit, 0) self.sourcesizer.Add(self.patternBox) if self.imageMode == 1: self.outputFormat = UIElements.getImageFormatMenu(self.imagePanel) self.outputFormat.menu.SetSelection(0) self.outputFormat.menu.Bind(wx.EVT_CHOICE, self.updateListOfImages) self.sourcesizer.Add(self.outputFormat) elif self.imageMode == 2: sizer = wx.BoxSizer(wx.HORIZONTAL) lbl = wx.StaticText(self.imagePanel, -1, "VTK Dataset Format") sizer.Add(lbl) formats = ["XML Image Data", "VTK Image Data"] self.vtkmenu = wx.Choice(self.imagePanel, -1, choices = formats) self.vtkmenu.SetSelection(0) sizer.Add(self.vtkmenu) self.vtkmenu.Bind(wx.EVT_CHOICE, self.updateListOfImages) self.sourcesizer.Add(sizer) self.sourceListbox = wx.ListBox(self.imagePanel, -1, size = (600, 100), style = wx.LB_ALWAYS_SB | wx.LB_EXTENDED) if self.imageMode == 1: self.listlbl = wx.StaticText(self.imagePanel, -1, "List of Images:") else: self.listlbl = wx.StaticText(self.imagePanel, -1, "List of Datasets:") self.sourcesizer.Add(self.listlbl) self.sourcesizer.Add(self.sourceListbox) self.imageSourceboxsizer.Add(self.sourcesizer, 1, wx.EXPAND) self.imageInfoBox = wx.StaticBox(self.imagePanel, -1, "Dataset Information") self.imageInfoSizer = wx.StaticBoxSizer(self.imageInfoBox, wx.VERTICAL) self.infosizer = wx.GridBagSizer(5, 5) self.imageAmountLbl = wx.StaticText(self.imagePanel, -1, "%d" % self.imageAmnt) if self.imageMode == 1: self.nlbl = wx.StaticText(self.imagePanel, -1, "Number of Images:") self.dimlbl = wx.StaticText(self.imagePanel, -1, "Image Dimensions:") else: self.nlbl = wx.StaticText(self.imagePanel, -1, "Number of Datasets:") self.dimlbl = wx.StaticText(self.imagePanel, -1, "Dataset Dimensions:") if self.imageMode == 1: self.dimensionLbl = wx.StaticText(self.imagePanel, -1, "%d x %d" % (self.x, self.y)) self.depthlbl = wx.StaticText(self.imagePanel, -1, "Depth of Stack:") self.depthLbl = wx.StaticText(self.imagePanel, -1, "%d" % self.z) else: self.dimensionLbl = wx.StaticText(self.imagePanel, -1, "%d x %d x %d" %(self.x, self.y, self.z)) self.tpLbl = wx.StaticText(self.imagePanel, -1, "Number of Timepoints:") self.timepointLbl = wx.StaticText(self.imagePanel, -1, "%d" % self.t) self.cLbl = wx.StaticText(self.imagePanel, -1, "Number of Channels:") self.channelLbl = wx.StaticText(self.imagePanel, -1, "%d" % self.c) yloc = 0 self.infosizer.Add(self.nlbl, (yloc, 0)) self.infosizer.Add(self.imageAmountLbl, (yloc, 1), flag = wx.EXPAND | wx.ALL) yloc += 1 self.infosizer.Add(self.dimlbl, (yloc, 0)) self.infosizer.Add(self.dimensionLbl, (yloc, 1), flag = wx.EXPAND | wx.ALL) yloc += 1 if self.imageMode == 1: self.infosizer.Add(self.depthlbl, (yloc, 0)) self.infosizer.Add(self.depthLbl, (yloc, 1), flag = wx.EXPAND | wx.ALL) yloc += 1 self.infosizer.Add(self.tpLbl, (yloc, 0)) self.infosizer.Add(self.timepointLbl, (yloc, 1), flag = wx.EXPAND | wx.ALL) yloc += 1 self.infosizer.Add(self.cLbl, (yloc, 0)) self.infosizer.Add(self.channelLbl, (yloc, 1), flag = wx.EXPAND | wx.ALL) self.imageInfoSizer.Add(self.infosizer) self.imageSizer.Add(self.imageInfoSizer, (0, 0), flag = wx.EXPAND | wx.ALL, border = 5) self.imageSizer.Add(self.imageSourceboxsizer, (1, 0), flag = wx.EXPAND | wx.ALL, border = 5) self.imagePanel.SetSizer(self.imageSizer) self.imagePanel.SetAutoLayout(1) self.imageSizer.Fit(self.imagePanel)
def __init__(self, *args, **kwargs): wx.Dialog.__init__(self, *args, **kwargs) #local copy self.parent = args[0] ###list des item selectionnes self._selectedItem = {} ### recuperation des lib a partir du dico D du tree (library) lst = filter(lambda s: not self.parent.tree.IsChildRoot(s), self.parent.tree.GetDomainList( DOMAIN_PATH)) if self.parent else [] exportPathsList = self.parent.exportPathsList if self.parent else [] ### if lst is empty, perhaps DOMAIN_PATH is false if self.parent and lst == []: self.CheckDomainPath() ### Dico pour correspondance entre nom et path pour les exported path self._d = {} for path in exportPathsList: name = os.path.basename(path) if not self.parent.tree.IsChildRoot(name): lst.append(name) self._d[name] = os.path.abspath(path) ### construction du dico pour populate aves les paths local et exportes D = {} for v in lst: ### path is on the domain dir by default path = os.path.join(DOMAIN_PATH, v) ### else we find the path in the exportPathsList if not os.path.exists(path): for s in filter(lambda p: v in p, self.parent.exportPathsList): if os.path.isdir(s): path = s ### update the exported path list else: path = None i = self.parent.exportPathsList.index(s) del self.parent.exportPathsList[i] if path: D[path] = v ### Panels panel = wx.Panel(self, wx.ID_ANY) leftPanel = wx.Panel(panel, wx.ID_ANY) rightPanel = wx.Panel(panel, wx.ID_ANY) ### check list of libraries self._cb = CheckListCtrl(rightPanel) ### Populate Check List dynamicaly wx.CallAfter(self._cb.Populate, D) ### Box Sizer vbox = wx.BoxSizer(wx.VERTICAL) vbox2 = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox1 = wx.BoxSizer(wx.HORIZONTAL) ### Buttons self._dbb = filebrowse.DirBrowseButton(rightPanel, wx.ID_ANY, startDirectory=HOME_PATH, labelText=_("New"), changeCallback=self.OnChange) self._btn_Add = wx.Button(rightPanel, id=wx.ID_ADD) self._btn_Add.Enable(False) new = wx.Button(leftPanel, id=wx.ID_NEW, size=(100, -1)) sel = wx.Button(leftPanel, id=wx.ID_SELECTALL, size=(100, -1)) des = wx.Button(leftPanel, wx.ID_ANY, _('Deselect All'), size=(100, -1)) apply = wx.Button(leftPanel, id=wx.ID_OK, size=(100, -1)) ### Set Sizer hbox1.Add(self._dbb, 1, wx.EXPAND) hbox1.Add(self._btn_Add, 0, wx.RIGHT | wx.CENTER, 3) vbox2.Add(new, 0, wx.TOP, 2) vbox2.Add(sel, 0, wx.TOP, 2) vbox2.Add(des, 0, wx.TOP, 2) #vbox2.Add((-1, 300)) vbox2.Add(apply, 0, wx.TOP, 2) vbox.Add(self._cb, 1, wx.EXPAND | wx.TOP, 3) vbox.Add((-1, 10)) vbox.Add(hbox1, 0.5, wx.EXPAND) vbox.Add((-1, 10)) hbox.Add(rightPanel, 1, wx.EXPAND, 5) hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT) hbox.Add((3, -1)) ### SetSizer leftPanel.SetSizer(vbox2) rightPanel.SetSizer(vbox) panel.SetSizer(hbox) ##Binding Events self.Bind(wx.EVT_BUTTON, self.OnNew, id=new.GetId()) self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId()) self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId()) self.Bind(wx.EVT_BUTTON, self.OnAdd, self._btn_Add) self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, self._cb) self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.Centre() self.Layout() ### just for windows e = wx.SizeEvent(self.GetSize()) self.ProcessEvent(e)
def __init__(self, parent, ID, title): 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) # 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) 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) # 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)