我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用wx.CENTER。
def __init__(self,parent): wx.Panel.__init__(self, parent) self.panelvisual = self.GetParent().GetParent().GetParent() self.vbox = wx.BoxSizer(wx.VERTICAL) self.hbox_btn = wx.BoxSizer(wx.HORIZONTAL) self.chkbox_enable = CheckBoxNew(self, -1, 'Enable XYZ Axes') self.chkbox_enable.SetToolTipNew("Enable Widget") if self.panelvisual.widget.GetEnabled() == 0: self.chkbox_enable.SetValue(False) else: self.chkbox_enable.SetValue(True) self.Bind(wx.EVT_CHECKBOX, self.OnChkbox, self.chkbox_enable) self.hbox_btn.Add(self.chkbox_enable, 1, flag=wx.CENTER) self.vbox.Add(self.hbox_btn, 1, flag=wx.CENTER, border=2) self.SetSizer(self.vbox) self.Fit() self.Show()
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "Background Reset Tutorial") # Add a panel so it looks the correct on all platforms self.panel = wx.Panel(self, wx.ID_ANY) self.txt = wx.TextCtrl(self.panel) self.txt.SetBackgroundColour("Yellow") blueBtn = wx.Button(self.panel, label="Change Background Color") blueBtn.Bind(wx.EVT_BUTTON, self.onChangeBackground) resetBtn = wx.Button(self.panel, label="Reset") resetBtn.Bind(wx.EVT_BUTTON, self.onReset) topSizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(blueBtn, 0, wx.ALL|wx.CENTER, 5) btnSizer.Add(resetBtn, 0, wx.ALL|wx.CENTER, 5) topSizer.Add(self.txt, 0, wx.ALL, 5) topSizer.Add(btnSizer, 0, wx.CENTER) self.panel.SetSizer(topSizer)
def __init__(self): """Constructor""" wx.Frame.__init__(self, None, title="Center the Button") panel = wx.Panel(self) h_sizer = wx.BoxSizer(wx.HORIZONTAL) main_sizer = wx.BoxSizer(wx.VERTICAL) btn = wx.Button(panel, label="Centered") h_sizer.Add(btn, 0, wx.CENTER) main_sizer.Add((0,0), 1, wx.EXPAND) main_sizer.Add(h_sizer, 0, wx.CENTER) main_sizer.Add((0,0), 1, wx.EXPAND) panel.SetSizer(main_sizer) self.Show()
def __init__(self): """Constructor""" wx.Frame.__init__(self, None, title="Center the Button") panel = wx.Panel(self) h_sizer = wx.BoxSizer(wx.HORIZONTAL) main_sizer = wx.BoxSizer(wx.VERTICAL) btn = wx.Button(panel, label="Centered") h_sizer.Add(btn, 0, wx.CENTER) main_sizer.AddStretchSpacer(prop=1) main_sizer.Add(h_sizer, 0, wx.CENTER) main_sizer.AddStretchSpacer(prop=1) panel.SetSizer(main_sizer) self.Show()
def layout(self): """ Layout the widgets on the panel """ self.mainSizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) img = wx.EmptyImage(self.photoMaxSize,self.photoMaxSize) self.imageCtrl = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(img)) self.mainSizer.Add(self.imageCtrl, 0, wx.ALL|wx.CENTER, 5) self.imageLabel = wx.StaticText(self, label="") self.mainSizer.Add(self.imageLabel, 0, wx.ALL|wx.CENTER, 5) btnData = [("Previous", btnSizer, self.onPrevious), ("Slide Show", btnSizer, self.onSlideShow), ("Next", btnSizer, self.onNext)] for data in btnData: label, sizer, handler = data self.btnBuilder(label, sizer, handler) self.mainSizer.Add(btnSizer, 0, wx.CENTER) self.SetSizer(self.mainSizer)
def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) self.number_of_buttons = 0 self.frame = parent self.mainSizer = wx.BoxSizer(wx.VERTICAL) controlSizer = wx.BoxSizer(wx.HORIZONTAL) self.widgetSizer = wx.BoxSizer(wx.VERTICAL) self.addButton = wx.Button(self, label="Add") self.addButton.Bind(wx.EVT_BUTTON, self.onAddWidget) controlSizer.Add(self.addButton, 0, wx.CENTER|wx.ALL, 5) self.removeButton = wx.Button(self, label="Remove") self.removeButton.Bind(wx.EVT_BUTTON, self.onRemoveWidget) controlSizer.Add(self.removeButton, 0, wx.CENTER|wx.ALL, 5) self.mainSizer.Add(controlSizer, 0, wx.CENTER) self.mainSizer.Add(self.widgetSizer, 0, wx.CENTER|wx.ALL, 10) self.SetSizer(self.mainSizer)
def InitUI(self): sb = wx.StaticText(self, label='Stop! Open or Create new project first!') ic = wx.ArtProvider.GetBitmap( wx.ART_TIP, size=(48,48) ) icn= wx.StaticBitmap(self,-1,ic,name='Stop') lbl_mt = wx.StaticText(self, label="") vbox = wx.BoxSizer(wx.VERTICAL) self.SetSizer(vbox) vbox.Add(lbl_mt,flag=wx.CENTER, border=2) vbox.Add(sb,flag=wx.CENTER, border=2) vbox.Add(icn,flag=wx.CENTER, border=0) hbox2 = wx.BoxSizer(wx.HORIZONTAL) OButton = wx.Button(self, label='Open') NButton = wx.Button(self, label='New') hbox2.Add(OButton, flag=wx.CENTER, border=2) hbox2.Add(NButton, flag=wx.LEFT, border=5) vbox.Add(hbox2,flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=2) OButton.Bind(wx.EVT_BUTTON,self.OpenBtn) NButton.Bind(wx.EVT_BUTTON,self.NewBtn) self.Show() self.SetFocus() self.SetWindowStyle( wx.STAY_ON_TOP )
def beforeStart(self): instructionDialog = wx.MessageDialog(self, self.instructions, 'Instructions', style=wx.OK | wx.CENTER) instructionDialog.ShowModal() instructionDialog.Destroy()
def sayThankYou(self): thankYou = 'This session is complete. Thank you for participating!!' thanksDialog = wx.MessageDialog(self, thankYou, 'Thank You!', style=wx.OK | wx.CENTER) thanksDialog.ShowModal() thanksDialog.Destroy()
def __init__(self, parent): wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) self.panelphase = self.GetParent().GetParent().GetParent() self.font = self.GetParent().font self.file = None vbox = wx.BoxSizer(wx.VERTICAL) title = wx.StaticText(self, label="Convert HDF5 to Numpy array.") vbox.Add(title ,0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.input_filename = TextPanelObject(self, "Input HDF5 File: ", "",150,"HDF files (*.hdf)|*.hdf|HDF5 files (*.h5)|*.h5|All files (*.*)|*.*") vbox.Add(self.input_filename, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) hbox = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1,"HDF Key Path:" , style =wx.ALIGN_RIGHT, size=(150,-1) ) label.SetFont(self.font) hbox.Add( label, 0, wx.CENTER ) def OnEdit(event): self.objectpath.ChangeValue(event.GetString()) self.objectpath = TextCtrlNew(self, -1) self.objectpath.SetFont(self.font) self.objectpath.SetValue("") self.objectpath.SetToolTipNew("Comma separated key names.") self.objectpath.Bind(wx.EVT_TEXT_ENTER, OnEdit) hbox.Add( self.objectpath, 1, wx.CENTER |wx.EXPAND ) self.button = ButtonNew(self, -1, "Browse") self.button.SetFont(self.font) self.button.SetToolTipNew("Browse for HDF5 key path.") self.button.Bind(wx.EVT_BUTTON, self.OnBrowse) hbox.Add( self.button, 0, wx.LEFT|wx.CENTER) vbox.Add(hbox, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.output_filename = TextPanelObject(self, "Output File: ", "output.npy",150,'*.npy') vbox.Add(self.output_filename, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.SetAutoLayout(True) self.SetSizer( vbox )
def __init__(self, parent, name, objectpath, textwidth, file_extension): def assign(input): self.objectpath.ChangeValue(input) def OnBrowse(self): if IsNotWX4(): dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '', file_extension, wx.OPEN) else: dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '', file_extension, wx.FD_OPEN) if dlg.ShowModal() == wx.ID_OK: assign(dlg.GetPath()) dlg.Destroy() def OnEdit(event): self.objectpath.ChangeValue(event.GetString()) fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > textwidth: labelw = textw else: labelw = textwidth wx.BoxSizer.__init__(self, wx.HORIZONTAL) self.label = StaticTextNew(parent, -1, name, style =wx.ALIGN_RIGHT, size=(labelw,-1) ) self.label.SetFont(self.font) self.Add( self.label, 0, wx.CENTER ) self.objectpath = TextCtrlNew(parent, -1) self.objectpath.SetFont(self.font) self.objectpath.SetValue(objectpath) self.objectpath.SetToolTipNew("Browse for file or type "+os.linesep+"path and name") self.objectpath.Bind(wx.EVT_TEXT_ENTER, OnEdit) self.Add( self.objectpath, 1, wx.CENTER |wx.EXPAND ) self.button = ButtonNew(parent, -1, "Browse") self.button.SetFont(self.font) self.button.SetToolTipNew("Browse for file or type "+os.linesep+"path and name") self.button.Bind(wx.EVT_BUTTON, OnBrowse) self.Add( self.button, 0, wx.LEFT|wx.CENTER)
def onInstall(): requiredVer = "Windows 10 Version 1703" # Translators: Dialog text shown when attempting to install the add-on on an unsupported version of Windows (minSupportedVersion is the minimum version required for this add-on). if sys.getwindowsversion().build < 15063 and gui.messageBox(_("You are using an older version of Windows. This add-on requires {minSupportedVersion} or later. Are you sure you wish to install this add-on anyway?").format(minSupportedVersion = requiredVer), # Translators: title of the dialog shown when attempting to install the add-on on an old version of Windows. _("Old Windows version"), wx.YES | wx.NO | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.NO: raise RuntimeError("Old Windows version detected")
def getUpdateResponse(message, caption, updateURL): if gui.messageBox(message, caption, wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.YES: W10UpdateDownloader([updateURL]).start()
def create_callable(self, name, action): def callable(event): # check if this is for whole project or file/directory if 'item' in name.lower(): # for one single item - file/directory if not self.datafile: return full_cmd = action.format(path=self.datafile.source) else: # for whole project - root file/directory full_cmd = action.format(path=self.model.suite.source) # RideLogMessage(name + " clicked: " + fullCmd).publish() if full_cmd.lower().startswith('http'): wx.LaunchDefaultBrowser(full_cmd) else: try: subprocess.Popen(full_cmd) except OSError as error: s = "This is the error we got trying to execute {executor_name} executable file:\n" \ "\"{error}\"\n\n" \ "Probably this file in not in your PATH. Try to reinstall {executor_name}.\n" \ "Do you want to open download page?".format(error=error.strerror, executor_name=self.MENU_NAME) dlg = wx.MessageDialog(parent=self.frame, caption="Hmm, something went wrong...", message=s, style=wx.YES_NO | wx.CENTER | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: wx.LaunchDefaultBrowser(self.SVN_INSTALLATION_URL) dlg.Destroy() return callable
def __init__(self): """Constructor""" wx.Frame.__init__(self, None, title="Center the Button") panel = wx.Panel(self) main_sizer = wx.BoxSizer(wx.VERTICAL) btn = wx.Button(panel, label="Centered") main_sizer.AddStretchSpacer() main_sizer.Add(btn, 0, wx.CENTER) main_sizer.AddStretchSpacer() panel.SetSizer(main_sizer) self.Show()
def __init__(self, parent): wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) self.panelphase = self.GetParent().GetParent().GetParent() self.font = self.GetParent().font self.file = None vbox = wx.BoxSizer(wx.VERTICAL) title = wx.StaticText(self, label="Fill blank voxels lines in raw data.") vbox.Add(title ,0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.input_filename = TextPanelObject(self, "Input File: ", "",150,"Numpy files (*.npy)|*.npy|All files (*.*)|*.*") vbox.Add(self.input_filename, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) hbox = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1,"ROI:" , style =wx.ALIGN_RIGHT, size=(150,-1) ) label.SetFont(self.font) hbox.Add( label, 0, wx.CENTER ) def OnEdit(event): self.objectpath.ChangeValue(event.GetString()) self.objectpath = TextCtrlNew(self, -1) self.objectpath.SetFont(self.font) self.objectpath.SetValue("") self.objectpath.SetToolTipNew("Region of Interest") self.objectpath.Bind(wx.EVT_TEXT_ENTER, OnEdit) hbox.Add( self.objectpath, 1, wx.CENTER |wx.EXPAND ) self.button = ButtonNew(self, -1, "Browse") self.button.SetFont(self.font) self.button.SetToolTipNew("Browse for ROI.") self.button.Bind(wx.EVT_BUTTON, self.OnBrowse) hbox.Add( self.button, 0, wx.LEFT|wx.CENTER) vbox.Add(hbox, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.output_filename = TextPanelObject(self, "Output File: ", "output.npy",150,'*.npy') vbox.Add(self.output_filename, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) vbox.Add((0,10)) title2 = wx.StaticText(self, label="Filter kernel dimensions: ") vbox.Add(title2 ,0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.kdims=[{} for i in range(3)] self.kdims[0] = SpinnerObject(self,"x",MAX_INT_16,1,1,3,20,60) self.kdims[1] = SpinnerObject(self,"y",MAX_INT_16,1,1,3,20,60) self.kdims[2] = SpinnerObject(self,"z",MAX_INT_16,1,1,1,20,60) hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox1.Add(self.kdims[0], 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, border=10) hbox1.Add(self.kdims[1], 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, border=10) hbox1.Add(self.kdims[2], 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, border=10) vbox.Add(hbox1, 0, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=2) self.SetAutoLayout(True) self.SetSizer( vbox )
def __init__(self, parent, name, smax, smin, sinc, sinit, stextwidth, swidth): if abs(sinc) < 1.0: self.precision = "%."+str(str(sinc)[::-1].find('.'))+"f" else: self.precision = "%d" def OnSpin(pos): self.value.ChangeValue(self.precision%(sinc * pos + self.remainder)) def OnEdit(event): text = event.GetString() point = self.value.GetInsertionPoint() if (IsNumber(self.value.GetValue()) == False): self.value.SetBackgroundColour( "Pink" ) self.value.SetForegroundColour( "Black" ) else: self.value.SetBackgroundColour(wx.NullColour) self.value.SetForegroundColour(wx.NullColour) self.value.ChangeValue(text) self.value.SetInsertionPoint(point) if ( text == '' or text == '.'): self.spin.SetValue(smin/sinc); try: self.spin.SetValue(int(float(text)/sinc)) except: pass event.Skip() fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > stextwidth: labelw = textw else: labelw = stextwidth wx.BoxSizer.__init__(self, wx.HORIZONTAL) self.label = StaticTextNew(parent, -1, name, style=wx.ALIGN_RIGHT, size=(labelw,-1) ) self.label.SetFont(self.font) self.Add( self.label, 0, wx.CENTER ) self.value = TextCtrlNew(parent, value=str(sinit),size=(swidth, -1), style=wx.TE_PROCESS_ENTER) self.value.SetWindowStyle(wx.TE_RIGHT) self.value.SetFont(self.font) self.value.Bind(wx.EVT_TEXT, OnEdit) self.Add( self.value, 0, wx.CENTER ) bw,bh = dc.GetTextExtent("0") spinw = int(1.5*bh) self.spin = SpinButtonNew(parent, size=(spinw,-1), spinfunc=OnSpin) self.spin.SetRange(int(smin/sinc), int(smax/sinc)) self.spin.SetValue(int(sinit/sinc)) self.remainder = smin%sinc self.Add( self.spin, 0, wx.CENTER ) self.IsEnabled = True self.Layout() self.Show()
def __init__(self, parent, info): wx.Dialog.__init__(self, parent, title="About Bonsu", size=(460,300)) self.SetSizeHints(450,300,-1,-1) self.parent = parent self.info = info self.vboxborder = wx.BoxSizer(wx.VERTICAL) self.vbox = wx.BoxSizer(wx.VERTICAL) self.icon = wx.Image(os.path.join(os.path.dirname(os.path.dirname(__file__)),'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO) if IsNotWX4(): self.bitmap = wx.BitmapFromImage(self.icon) else: self.bitmap = wx.Bitmap(self.icon) self.staticbmp = wx.StaticBitmap(self, -1, self.bitmap) self.vbox.Add(self.staticbmp, 0, flag=wx.CENTER, border=5) namestr = info.GetName()+" "+info.GetVersion() self.namefont = wx.Font((parent.font.GetPointSize()+8),parent.font.GetFamily(),wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.name = wx.StaticText(self, label=namestr) self.name.SetFont(self.namefont) self.vbox.Add((-1, 5)) self.vbox.Add(self.name, 0, flag=wx.CENTER, border=5) self.vbox.Add((-1, 5)) self.description = wx.StaticText(self, label=info.GetDescription(), style=wx.ALIGN_CENTRE_HORIZONTAL) self.description.Wrap(400) self.vbox.Add(self.description, 0, flag=wx.CENTER, border=5) self.vbox.Add((-1, 5)) self.copyright = wx.StaticText(self, label=info.GetCopyright()) self.vbox.Add(self.copyright, 0, flag=wx.CENTER, border=5) self.vbox.Add((-1, 5)) if IsNotWX4(): self.web = wx.StaticText(self, label=info.GetWebSite()[0]) else: self.web = wx.StaticText(self, label=info.GetWebSiteURL()) self.vbox.Add(self.web, 0, flag=wx.CENTER, border=5) self.vbox.Add((-1, 10)) self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.credits =wx.Button(self, label="More") self.Bind(wx.EVT_BUTTON, self.OnCredits, self.credits) self.hbox.Add(self.credits) self.hbox.Add((10, -1)) self.license =wx.Button(self, label="License") self.Bind(wx.EVT_BUTTON, self.OnLicense, self.license) self.hbox.Add(self.license) self.hbox.Add((10, -1)) self.close =wx.Button(self, label="Close") self.Bind(wx.EVT_BUTTON, self.OnClose, self.close) self.hbox.Add(self.close) self.vbox.Add(self.hbox, 0, flag=wx.CENTER, border=5) self.vbox.Add((-1, 10)) self.vboxborder.Add(self.vbox, 1, flag=wx.CENTER|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=20) self.SetSizer( self.vboxborder ) self.SetAutoLayout(True) self.Fit() self.Layout() self.Show()
def __init__(self, parent=None): super(WebPanel, self).__init__(parent=parent) self.current_url = HOMEURL sizer = wx.BoxSizer(orient=wx.VERTICAL) btn_sizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.web_view = webview.WebView.New(parent=self) self.Bind(event=webview.EVT_WEBVIEW_LOADED, handler=self.webview_loaded, source=self.web_view) self.Bind(event=webview.EVT_WEBVIEW_NEWWINDOW, handler=self.open_new_window, source=self.web_view) btn_home = wx.Button(parent=self, label=u"??", style=wx.BU_EXACTFIT) self.Bind(event=wx.EVT_BUTTON, handler=self.click_home_button, source=btn_home) btn_sizer.Add(item=btn_home, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) btn_back_page = wx.Button(parent=self, label=u"<--", style=wx.BU_EXACTFIT) self.Bind(event=wx.EVT_BUTTON, handler=self.click_preview_page_button, source=btn_back_page) self.Bind(event=wx.EVT_UPDATE_UI, handler=self.check_can_goback, source=btn_back_page) btn_sizer.Add(item=btn_back_page, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) btn_next_page = wx.Button(parent=self, label=u"-->", style=wx.BU_EXACTFIT) self.Bind(event=wx.EVT_BUTTON, handler=self.click_next_page_button, source=btn_next_page) self.Bind(event=wx.EVT_UPDATE_UI, handler=self.check_can_goforward, source=btn_next_page) btn_sizer.Add(item=btn_next_page, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) btn_stop = wx.Button(parent=self, label=u"??", style=wx.BU_EXACTFIT) self.Bind(event=wx.EVT_BUTTON, handler=self.click_stop_button, source=btn_stop) btn_sizer.Add(item=btn_stop, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) btn_refresh = wx.Button(parent=self, label=u"??", style=wx.BU_EXACTFIT) self.Bind(event=wx.EVT_BUTTON, handler=self.click_refresh_page_button, source=btn_refresh) btn_sizer.Add(btn_refresh, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) url_bar_title = wx.StaticText(parent=self, label=u"??:") btn_sizer.Add(url_bar_title, proportion=CAN_NOT_CHANGE, flag=wx.CENTER | wx.ALL, border=2) self.location = wx.ComboBox(parent=self, value=wx.EmptyString, style=wx.CB_DROPDOWN | wx.TE_PROCESS_ENTER) self.location.Bind(event=wx.EVT_TEXT_ENTER, handler=self.enter_location) self.Bind(event=wx.EVT_COMBOBOX, handler=self.select_location, source=self.location) btn_sizer.Add(item=self.location, proportion=CAN_CHANGE, flag=wx.EXPAND | wx.ALL, border=2) sizer.Add(item=btn_sizer, proportion=CAN_NOT_CHANGE, flag=wx.EXPAND) sizer.Add(item=self.web_view, proportion=CAN_CHANGE, flag=wx.EXPAND) self.SetSizer(sizer=sizer) self.web_view.LoadURL(url=self.current_url)
def _init_ctrls(self, prnt): wx.Dialog.__init__( self, id=ID_DISCOVERYDIALOG, name='DiscoveryDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE, title=_('Service Discovery')) self.staticText1 = wx.StaticText( id=ID_DISCOVERYDIALOGSTATICTEXT1, label=_('Services available:'), name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) # Set up list control self.ServicesList = AutoWidthListCtrl( id=ID_DISCOVERYDIALOGSERVICESLIST, name='ServicesList', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.LC_REPORT | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING | wx.LC_SINGLE_SEL) self.ServicesList.InsertColumn(0, _('NAME')) self.ServicesList.InsertColumn(1, _('TYPE')) self.ServicesList.InsertColumn(2, _('IP')) self.ServicesList.InsertColumn(3, _('PORT')) self.ServicesList.SetColumnWidth(0, 150) self.ServicesList.SetColumnWidth(1, 150) self.ServicesList.SetColumnWidth(2, 150) self.ServicesList.SetColumnWidth(3, 150) self.ServicesList.SetInitialSize(wx.Size(-1, 300)) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, id=ID_DISCOVERYDIALOGSERVICESLIST) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, id=ID_DISCOVERYDIALOGSERVICESLIST) listmix.ColumnSorterMixin.__init__(self, 4) self.RefreshButton = wx.Button( id=ID_DISCOVERYDIALOGREFRESHBUTTON, label=_('Refresh'), name='RefreshButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnRefreshButton, id=ID_DISCOVERYDIALOGREFRESHBUTTON) self.LocalButton = wx.Button( id=ID_DISCOVERYDIALOGLOCALBUTTON, label=_('Local'), name='LocalButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnLocalButton, id=ID_DISCOVERYDIALOGLOCALBUTTON) self.IpButton = wx.Button( id=ID_DISCOVERYDIALOGIPBUTTON, label=_('Add IP'), name='IpButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnIpButton, id=ID_DISCOVERYDIALOGIPBUTTON) self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTER) self._init_sizers() self.Fit()
def __init__(self, parent, info): title = _("About") + " " + info.Name wx.Dialog.__init__(self, parent, title=title) self.info = info if parent and parent.GetIcon(): self.SetIcon(parent.GetIcon()) image = None if self.info.Icon: bitmap = wx.BitmapFromIcon(self.info.Icon) image = wx.StaticBitmap(self, bitmap=bitmap) name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version)) description = wx.StaticText(self, label=info.Description) description.Wrap(400) copyright = wx.StaticText(self, label=info.Copyright) url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1]) font = name.GetClassDefaultAttributes().font font.SetWeight(wx.FONTWEIGHT_BOLD) font.SetPointSize(18) name.SetFont(font) credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits")) license = wx.Button(self, label=_("&License")) close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close")) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5) btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5) btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5) sizer = wx.BoxSizer(wx.VERTICAL) if image: sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5) sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15) sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5) container = wx.BoxSizer(wx.VERTICAL) container.Add(sizer, flag=wx.ALL, border=10) self.SetSizer(container) self.Layout() self.Fit() self.Centre() self.Show(True) self.SetEscapeId(close.GetId()) credits.Bind(wx.EVT_BUTTON, self.on_credits) license.Bind(wx.EVT_BUTTON, self.on_license) close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())
def create_main_panel(self): self.panel = wx.Panel(self) self.set_text = wx.StaticText(self.panel, -1, label="Showing : All (%d examples)" % self.m) self.set_text.SetBackgroundColour(wx.WHITE) font = wx.Font(20, wx.MODERN, wx.NORMAL, wx.BOLD) self.set_text.SetFont(font) self.hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.hbox1.Add(self.set_text, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.draw_fig(True) self.canvas = FigCanvas(self.panel, -1, self.fig) # Bind the 'click' event for clicking on one of the axes self.canvas.mpl_connect('button_press_event', self.on_click) self.navigation_control = NavigationControlBox(self.panel, self, -1, "navigation control") #self.label_key_box = LabelKeyBox(self.panel,-1) self.data_set_control = DataSetControlBox(self.panel,self,-1) self.build_button = wx.Button(self.panel, -1, label="Build") self.build_button.Bind(wx.EVT_BUTTON, self.on_build) self.reset_button = wx.Button(self.panel, -1, label="Reset") self.reset_button.Bind(wx.EVT_BUTTON, self.on_reset) self.exit_button = wx.Button(self.panel, -1, label="Exit") self.exit_button.Bind(wx.EVT_BUTTON, self.on_exit) self.vbox1 = wx.BoxSizer(wx.VERTICAL) self.vbox1.Add(self.build_button, 0, flag=wx.CENTER | wx.BOTTOM) self.vbox1.Add(self.reset_button, 0, flag=wx.CENTER | wx.BOTTOM) self.vbox1.Add(self.exit_button, 0, flag=wx.CENTER | wx.BOTTOM) self.hbox2 = wx.BoxSizer(wx.HORIZONTAL) #self.hbox2.Add(self.label_key_box, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.data_set_control, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.navigation_control, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.vbox1, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.vbox2 = wx.BoxSizer(wx.VERTICAL) self.vbox2.Add(self.hbox1, 0, flag=wx.CENTER | wx.TOP) self.vbox2.Add(self.canvas, 1, flag=wx.CENTER | wx.CENTER | wx.GROW) self.vbox2.Add(self.hbox2, 0, flag=wx.LEFT | wx.TOP) self.panel.SetSizer(self.vbox2) self.vbox2.Fit(self)