我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Button()。
def InitUI(self): #draw the pannel wx.StaticText(self, label='Select elements to download to local storage', pos=(30, 5)) self.cb_conf = wx.CheckBox(self, label='Config',pos = (80,30)) self.cb_logs = wx.CheckBox(self, label='Logs',pos = (80,55)) self.cb_cron = wx.CheckBox(self, label='Crontab',pos = (80,80)) self.cb_pics = wx.CheckBox(self, label='Photos',pos = (80,105)) self.cb_graph = wx.CheckBox(self, label='Graphs',pos = (80,130)) #right side self.cb_all = wx.CheckBox(self, label='Back up\nWhole Pigrow Folder',pos = (270,75)) #progress bar wx.StaticText(self, label='saving to; '+ localfiles_info_pnl.local_path, pos=(15, 155)) self.current_file_txt = wx.StaticText(self, label='--', pos=(30, 190)) self.current_dest_txt = wx.StaticText(self, label='--', pos=(30, 215)) #buttons self.start_download_btn = wx.Button(self, label='Download files', pos=(40, 240), size=(175, 50)) self.start_download_btn.Bind(wx.EVT_BUTTON, self.start_download_click) self.close_btn = wx.Button(self, label='Close', pos=(415, 240), size=(175, 50)) self.close_btn.Bind(wx.EVT_BUTTON, self.OnClose) ## universal controls pnl = wx.Panel(self)
def tkinterApp(): import tkinter as tk from tkinter import ttk win = tk.Tk() win.title("Python GUI") aLabel = ttk.Label(win, text="A Label") aLabel.grid(column=0, row=0) ttk.Label(win, text="Enter a name:").grid(column=0, row=0) name = tk.StringVar() nameEntered = ttk.Entry(win, width=12, textvariable=name) nameEntered.grid(column=0, row=1) nameEntered.focus() def buttonCallback(): action.configure(text='Hello ' + name.get()) action = ttk.Button(win, text="Print", command=buttonCallback) action.grid(column=2, row=1) win.mainloop() #==================================================================
def addFileWidgets(self): boxSizerH = wx.BoxSizer(wx.HORIZONTAL) boxSizerH.Add(wx.Button(self.panel, label='Browse to File...')) boxSizerH.Add(wx.TextCtrl( self.panel, size=(174, -1), value= "Z:\\" )) boxSizerH1 = wx.BoxSizer(wx.HORIZONTAL) boxSizerH1.Add(wx.Button(self.panel, label='Copy File To: ')) boxSizerH1.Add(wx.TextCtrl( self.panel, size=(174, -1), value= "Z:\\Backup" )) boxSizerV = wx.BoxSizer(wx.VERTICAL) boxSizerV.Add(boxSizerH) boxSizerV.Add(boxSizerH1) self.statBoxSizerMgrV.Add( boxSizerV, 1, wx.ALL ) #====================================================================
def __init__(self, parent): wx.Panel.__init__(self, parent) menu = wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menu.AppendSeparator() menu.Append(wx.ID_EXIT, "Exit", " Exit the GUI") menuBar = wx.MenuBar() menuBar.Append(menu, "File") parent.SetMenuBar(menuBar) self.textWidget = wx.TextCtrl(self, size=(280, 80), style=wx.TE_MULTILINE) button = wx.Button(self, label="Create OpenGL 3D Cube", pos=(60, 100)) self.Bind(wx.EVT_BUTTON, self.buttonCallback, button) parent.CreateStatusBar()
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) box = wx.BoxSizer(wx.VERTICAL) box.Add((20, 30)) keys = buttonDefs.keys() for k in keys: text = buttonDefs[k][1] btn = wx.Button(self, k, text) box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15) self.Bind(wx.EVT_BUTTON, self.OnButton, btn) # put a GLCanvas on the wx.Panel c = CubeCanvas(self) c.SetMinSize((200, 200)) box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15) c = ConeCanvas(self) c.SetMinSize((200, 200)) box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15) self.SetAutoLayout(True) self.SetSizer(box)
def createWidgets(self): # Main window resizer object sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(topPanel(self, self.SIM), 1, wx.ALL|wx.EXPAND, 5) sizer.Add(bottomPanel(self, self.SIM), 1, wx.ALL|wx.EXPAND, 5) #buttons = wx.BoxSizer(wx.HORIZONTAL) #buttons.Add(wx.Button(self, ID_BUTTON_CHANGE_PIN, "Okay"), 1, wx.ALIGN_LEFT | wx.ALL, 20) #buttons.Add(wx.Button(self, wxID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20) #sizer.Add(buttons, 1, wx.ALL) self.SetSizer(sizer) self.SetAutoLayout(1) sizer.Fit(self) self.Layout() wx.EVT_CLOSE(self, self.closeWindow)
def __init__(self, parent,nbresult,lf,rt): wx.Panel.__init__(self, parent, -1) panel = wx.Panel(self, -1) self.nbResult = nbresult self.lf = lf self.rt = rt hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.UrlTxtCtrl = wx.TextCtrl(self, -1, "http://news.china.com.cn", style = wx.TE_PROCESS_ENTER) btnStart = wx.Button(self, -1, "?", (20,20)) #¼ #Onstart = frame.OnStart self.Bind(wx.EVT_BUTTON, self.OnStart, btnStart) hbox1.Add(self.UrlTxtCtrl, 1, wx.EXPAND) hbox1.Add(btnStart,0, wx.EXPAND) self.SetSizer(hbox1)
def __init__(self, parent,start): wx.Panel.__init__(self, parent, -1) self.start = start panel = wx.Panel(self, -1) hbox2 = wx.BoxSizer(wx.HORIZONTAL) self.NumTxtCtrl = wx.TextCtrl(self, -1, " ?v0.1.4", style = wx.TE_PROCESS_ENTER|wx.TE_READONLY) self.severule = wx.Button(self, -1, "" ,(20,20)) self.btnClear = wx.Button(self, -1, "?" ,(20,20)) self.btnParseURL = wx.Button(self, -1, "URL" ,(20,20)) self.btnParseContent = wx.Button(self, -1, "?" ,(20,20)) #sizer hbox2.Add(self.NumTxtCtrl,1, wx.EXPAND) hbox2.Add(self.severule,0, wx.EXPAND) hbox2.Add(self.btnClear,0, wx.EXPAND) hbox2.Add(self.btnParseURL,0, wx.EXPAND) hbox2.Add(self.btnParseContent,0, wx.EXPAND) self.SetSizer(hbox2) ##?¼ self.Bind(wx.EVT_BUTTON, self.start.OnRemoveCache, self.btnClear) self.Bind(wx.EVT_BUTTON, self.start.OnSeveResult, self.severule) self.Bind(wx.EVT_BUTTON, self.start.OnStart, self.btnParseURL) self.Bind(wx.EVT_BUTTON, self.start.OnStart, self.btnParseContent)
def __init__(self, parent, id, title, message, download_url, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, name='dialog'): wx.Dialog.__init__(self, parent, id, title, pos, size, style, name) label = wx.StaticText(self, label=message) button = wx.Button(self, id=wx.ID_OK, label="Close") button.SetDefault() line = wx.StaticLine(self, wx.ID_ANY, size=(20, -1), style=wx.LI_HORIZONTAL) download_ctrl = hl.HyperLinkCtrl(self, wx.ID_ANY, download_url, URL=download_url) sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.StdDialogButtonSizer() button_sizer.AddButton(button) button_sizer.Realize() sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5) sizer.Add(download_ctrl, 0, wx.ALL, 10) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) sizer.Add(button_sizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
def initMediaPath(self): mediaPathControlBox = widgets.ControlBox(self, label='Media Path', orient=wx.HORIZONTAL) self.mediaPathTextCtrl = wx.TextCtrl(parent=self, style=wx.TE_PROCESS_ENTER) self.mediaPathTextCtrl.SetValue(self.pg.defaultMusicDir) mediaPathControlBox.Add(self.mediaPathTextCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_TEXT_ENTER, self.setMediaPath, self.mediaPathTextCtrl) self.offlineControls += [self.mediaPathTextCtrl] self.mediaBrowseButton = wx.Button(self, label='Browse') mediaPathControlBox.Add(self.mediaBrowseButton, proportion=0, flag=wx.TOP | wx.RIGHT | wx.BOTTOM, border=10) self.Bind(wx.EVT_BUTTON, self.mediaBrowse, self.mediaBrowseButton) self.offlineControls += [self.mediaBrowseButton] self.sizer.Add(mediaPathControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10)
def initStandardToolbarControls(self): # button to start and stop the page self.runButton = wx.Button(self.toolbar, label='Start') self.toolbar.AddControl(self.runButton, label='Run') self.Bind(wx.EVT_BUTTON, self.toggleRunning, self.runButton) # toolbar button to pause without stopping data acquisition self.pauseButton = wx.Button(self.toolbar, label='Pause') self.pauseButton.Disable() self.toolbar.AddControl(self.pauseButton, label='Pause') self.Bind(wx.EVT_BUTTON, self.togglePause, self.pauseButton) # toolbar button to start and stop EEG recording self.recordButton = wx.Button(self.toolbar, label='Start Recording') self.recordButton.Disable() self.toolbar.AddControl(self.recordButton, label='Record EEG') self.Bind(wx.EVT_BUTTON, self.toggleRecord, self.recordButton) # toolbar button to save an image of the current plot self.captureButton = wx.Button(self.toolbar, label='Capture Image') self.toolbar.AddControl(self.captureButton, label='Capture Image') self.Bind(wx.EVT_BUTTON, self.captureImage, self.captureButton) # init toolbar controls in base class StandardPage.initStandardToolbarControls(self)
def initStandardToolbarControls(self): # button to start training process self.trainButton = wx.Button(self.toolbar, label='Train') self.toolbar.AddControl(self.trainButton, label='Train') self.Bind(wx.EVT_BUTTON, self.toggleTrain, self.trainButton) # button to re-train classifier self.retrainButton = wx.Button(self.toolbar, label='Retrain') self.retrainButton.Disable() self.toolbar.AddControl(self.retrainButton, label='Retrain') self.Bind(wx.EVT_BUTTON, self.retrain, self.retrainButton) # button to start and stop the interface self.testButton = wx.Button(self.toolbar, label='Test') self.testButton.Disable() self.toolbar.AddControl(self.testButton, label='Test') self.Bind(wx.EVT_BUTTON, self.toggleTest, self.testButton) # init toolbar controls in base class StandardPage.initStandardToolbarControls(self)
def __init__(self, *args, **kwds): # begin wxGlade: Dialog_snapshot.__init__ kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER wx.Dialog.__init__(self, *args, **kwds) self.label_1 = wx.StaticText(self, wx.ID_ANY, "Nombre:") self.nombre_snap = wx.TextCtrl(self, wx.ID_ANY, "") self.label_2 = wx.StaticText(self, wx.ID_ANY, u"Descripci\u00f3n:") self.descripcion_snap = wx.TextCtrl(self, wx.ID_ANY, "") self.checkbox_memory = wx.CheckBox(self, wx.ID_ANY, "memory") self.checkbox_quiesce = wx.CheckBox(self, wx.ID_ANY, "quiesce") self.snap_ok = wx.Button(self, wx.ID_OK, "OK") self.snap_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") self.__set_properties() self.__do_layout() # end wxGlade
def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) note1 = wx.StaticText(self, -1, "The FloatCanvas Demo needs") note2 = wx.StaticText(self, -1, "a separate frame") b = wx.Button(self, -1, "Open Demo Frame Now") b.Bind(wx.EVT_BUTTON, self.OnButton) S = wx.BoxSizer(wx.VERTICAL) S.Add((10, 10), 1) S.Add(note1, 0, wx.ALIGN_CENTER) S.Add(note2, 0, wx.ALIGN_CENTER | wx.BOTTOM, 5) S.Add(b, 0, wx.ALIGN_CENTER | wx.ALL, 5) S.Add((10, 10), 1) self.SetSizer(S) self.Layout()
def __init__(self, *args, **kwds): # begin wxGlade: LogicalVolumeDialog.__init__ wx.Dialog.__init__(self, *args, **kwds) self.panel_1 = wx.Panel(self, wx.ID_ANY) self.panel_4 = wx.Panel(self, wx.ID_ANY) self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Select Logical Volume: "), style=wx.ALIGN_CENTER_HORIZONTAL) self.panel_7 = wx.Panel(self, wx.ID_ANY) self.combo_logical_volumes = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN) self.panel_8 = wx.Panel(self, wx.ID_ANY) self.panel_3 = wx.Panel(self, wx.ID_ANY) self.panel_5 = wx.Panel(self, wx.ID_ANY) self.button_select = wx.Button(self, wx.ID_OK, _("Select")) self.panel_9 = wx.Panel(self, wx.ID_ANY) self.button_cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel")) self.panel_6 = wx.Panel(self, wx.ID_ANY) self.panel_2 = wx.Panel(self, wx.ID_ANY) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.button_select_click, id=wx.ID_OK) self.Bind(wx.EVT_BUTTON, self.button_cancel_click, id=wx.ID_CANCEL) # end wxGlade self.PopulateVolumes()
def __init__( self, parent ): win_height = parent.GetSize()[1] height_of_pannels_above = 230 space_left = win_height - height_of_pannels_above wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (0, height_of_pannels_above), size = wx.Size(285, space_left), style = wx.TAB_TRAVERSAL ) # Start drawing the UI elements wx.StaticText(self, label='Pigrow Config', pos=(25, 10)) self.update_config_btn = wx.Button(self, label='read config from pigrow', pos=(15, 60), size=(175, 30)) self.update_config_btn.Bind(wx.EVT_BUTTON, self.update_config_click) self.name_box_btn = wx.Button(self, label='change box name', pos=(15, 95), size=(175, 30)) self.name_box_btn.Bind(wx.EVT_BUTTON, self.name_box_click) self.config_lamp_btn = wx.Button(self, label='config lamp', pos=(15, 130), size=(175, 30)) self.config_lamp_btn.Bind(wx.EVT_BUTTON, self.config_lamp_click) self.config_dht_btn = wx.Button(self, label='config dht', pos=(15, 165), size=(175, 30)) self.config_dht_btn.Bind(wx.EVT_BUTTON, self.config_dht_click) self.new_gpio_btn = wx.Button(self, label='Add new relay device', pos=(15, 200), size=(175, 30)) self.new_gpio_btn.Bind(wx.EVT_BUTTON, self.add_new_device_relay) self.update_settings_btn = wx.Button(self, label='update pigrow settings', pos=(15, 235), size=(175, 30)) self.update_settings_btn.Bind(wx.EVT_BUTTON, self.update_setting_click)
def __init__( self, parent ): win_height = parent.GetSize()[1] height_of_pannels_above = 230 space_left = win_height - height_of_pannels_above wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (0, height_of_pannels_above), size = wx.Size(285, space_left), style = wx.TAB_TRAVERSAL ) wx.StaticText(self, label='Cron Config Menu', pos=(25, 10)) self.read_cron_btn = wx.Button(self, label='Read Crontab', pos=(10, 40), size=(175, 30)) self.read_cron_btn.Bind(wx.EVT_BUTTON, self.read_cron_click) self.new_cron_btn = wx.Button(self, label='New cron job', pos=(10, 80), size=(175, 30)) self.new_cron_btn.Bind(wx.EVT_BUTTON, self.new_cron_click) self.update_cron_btn = wx.Button(self, label='Update Cron', pos=(10, 120), size=(175, 30)) self.update_cron_btn.Bind(wx.EVT_BUTTON, self.update_cron_click) self.SetBackgroundColour('sea green') #TESTING ONLY REMOVE WHEN SIZING IS DONE AND ALL THAT BUSINESS bSizer = wx.BoxSizer(wx.VERTICAL) bSizer.Add(self.read_cron_btn, 0, wx.ALL, 5) bSizer.Add(self.new_cron_btn, 0, wx.ALL, 5) bSizer.Add(self.update_cron_btn, 0, wx.ALL, 5) self.SetSizer(bSizer)
def InitUI(self): #draw the pannel wx.StaticText(self, label='Select elements to upload from local storage to pi\n\n ** Warning this will overwrite current pigrow files \n which may result in loss of data **', pos=(30, 5)) self.cb_conf = wx.CheckBox(self, label='Config',pos = (80,90)) self.cb_logs = wx.CheckBox(self, label='Logs',pos = (80,115)) self.cb_cron = wx.CheckBox(self, label='Crontab',pos = (80,140)) self.cb_pics = wx.CheckBox(self, label='Photos',pos = (80,165)) self.cb_graph = wx.CheckBox(self, label='Graphs',pos = (80,190)) #right side self.cb_all = wx.CheckBox(self, label='Restore Back up\nof whole Pigrow Folder',pos = (270,130)) #progress bar wx.StaticText(self, label='uploading from; '+ localfiles_info_pnl.local_path, pos=(15, 215)) self.current_file_txt = wx.StaticText(self, label='--', pos=(30, 245)) self.current_dest_txt = wx.StaticText(self, label='--', pos=(30, 270)) #buttons self.start_upload_btn = wx.Button(self, label='Upload files', pos=(40, 300), size=(175, 50)) self.start_upload_btn.Bind(wx.EVT_BUTTON, self.start_upload_click) self.close_btn = wx.Button(self, label='Close', pos=(415, 300), size=(175, 50)) self.close_btn.Bind(wx.EVT_BUTTON, self.OnClose) ## universal controls pnl = wx.Panel(self)
def __init__( self, parent ): wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (0,0), size = wx.Size( 285,190 ), style = wx.TAB_TRAVERSAL ) self.SetBackgroundColour((150,230,170)) #TESTING ONLY REMOVE WHEN SIZING IS DONE AND ALL THAT BUSINESS pi_link_pnl.target_ip = '' pi_link_pnl.target_user = '' pi_link_pnl.target_pass = '' pi_link_pnl.config_location_on_pi = '/home/pi/Pigrow/config/pigrow_config.txt' ## the three boxes for pi's connection details, IP, Username and Password self.l_ip = wx.StaticText(self, label='address', pos=(10, 20)) self.tb_ip = wx.TextCtrl(self, pos=(125, 25), size=(150, 25)) self.tb_ip.SetValue("192.168.1.") self.l_user = wx.StaticText(self, label='Username', pos=(10, 60)) self.tb_user = wx.TextCtrl(self, pos=(125, 60), size=(150, 25)) self.tb_user.SetValue("pi") self.l_pass = wx.StaticText(self, label='Password', pos=(10, 95)) self.tb_pass = wx.TextCtrl(self, pos=(125, 95), size=(150, 25)) self.tb_pass.SetValue("raspberry") ## link with pi button self.link_with_pi_btn = wx.Button(self, label='Link to Pi', pos=(10, 125), size=(175, 30)) self.link_with_pi_btn.Bind(wx.EVT_BUTTON, self.link_with_pi_btn_click) self.link_status_text = wx.StaticText(self, label='-- no link --', pos=(25, 160)) ## seek next pi button self.seek_for_pigrows_btn = wx.Button(self, label='Seek next', pos=(190,125)) self.seek_for_pigrows_btn.Bind(wx.EVT_BUTTON, self.seek_for_pigrows_click)
def on_c2_info(self, e): self.menu_c2_info.Enable(False) self.grid.ClearGrid() self.grid_set_shape(2, 2, 100) self.grid.SetColSize(1, 200) self.grid.SetCellValue(0, 0, "Event Name") self.grid.SetCellValue(1, 0, "Org Login") self.grid_column_readonly(0) if not self.read_c2_info(): self.c2_info = ["", ""] self.grid.SetCellValue(0, 1, self.c2_info[0]) self.grid.SetCellValue(1, 1, self.c2_info[1]) apply_button = wx.Button(self, wx.ID_APPLY) self.Bind(wx.EVT_BUTTON, self.on_c2_info_apply, apply_button) self.actions_panel.Add(apply_button, 1) self.Layout()
def __init__(self, parent, info): wx.Dialog.__init__(self, parent, title=_("License"), size=(500, 400), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) if parent and parent.GetIcon(): self.SetIcon(parent.GetIcon()) self.SetMinSize((400, 300)) close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close")) ctrl = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE) ctrl.SetValue(info.License) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(close) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(ctrl, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10) self.SetSizer(sizer) self.Layout() self.Show() self.SetEscapeId(close.GetId()) close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())
def __init__(self, parent): wx.Control.__init__(self, parent) main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(0) # create location text control self.Location = wx.TextCtrl(self, size=wx.Size(0, -1), style=wx.TE_PROCESS_ENTER) self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar) main_sizer.AddWindow(self.Location, flag=wx.GROW) # create browse button self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, -1)) self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) main_sizer.AddWindow(self.BrowseButton, flag=wx.GROW) self.Bind(wx.EVT_SIZE, self.OnSize) self.SetSizer(main_sizer) self.Controller = None self.VarType = None self.Default = False
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "File and Folder Dialogs Tutorial") panel = wx.Panel(self, wx.ID_ANY) self.currentDirectory = os.getcwd() # create the buttons and bindings dirDlgBtn1 = wx.Button(panel, label="Choose Source") dirDlgBtn1.Bind(wx.EVT_BUTTON, self.onDir1) dirDlgBtn2 = wx.Button(panel, label="Choose Destination") dirDlgBtn2.Bind(wx.EVT_BUTTON, self.onDir2) moveBtn=wx.Button(panel, label="Check and Move Files") moveBtn.Bind(wx.EVT_BUTTON, self.moveUFiles) # put the buttons in a sizer sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(dirDlgBtn1, 0, wx.ALL|wx.CENTER, 5) sizer.Add(dirDlgBtn2, 0, wx.ALL|wx.CENTER, 5) sizer.Add(moveBtn, 0, wx.ALL|wx.CENTER, 5) panel.SetSizer(sizer)
def __init__(self, *args, **kwds): # begin wxGlade: Add_Student.__init__ kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.STAY_ON_TOP wx.Dialog.__init__(self, *args, **kwds) self.text_ctrl_1 = wx.TextCtrl(self, -1, "") self.text_ctrl_2 = wx.TextCtrl(self, -1, "") self.text_ctrl_3 = wx.TextCtrl(self, -1, "") self.button_1 = wx.Button(self, -1, "Add") self.Bind(wx.EVT_CLOSE,self.OnClose,self) self.__set_properties() self.__do_layout() self.DB=db_operations() self.success=False self.STUDENT_INFO=[] # end wxGlade
def __init__(self, parent): # begin wxGlade: CE_TE.__init__ #kwds["style"] = wx.CLOSE_BOX|wx.MINIMIZE_BOX wx.Dialog.__init__(self, parent,id=-1,title="CE and TE") self.parent=parent self.label_1 = wx.StaticText(self, -1, "Max_CE") self.text_ctrl_1 = wx.TextCtrl(self, -1, "") self.label_2 = wx.StaticText(self, -1, "Max_TE") self.text_ctrl_2 = wx.TextCtrl(self, -1, "") self.button_1 = wx.Button(self, -1, "OK") self.button_2 = wx.Button(self, -1, "Cancel") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_TEXT_ENTER, self.On_TE_Enter, self.text_ctrl_1) self.Bind(wx.EVT_TEXT, self.On_CE_Text, self.text_ctrl_1) self.Bind(wx.EVT_TEXT_ENTER, self.On_TE_Enter, self.text_ctrl_2) self.Bind(wx.EVT_TEXT, self.On_TE_Text, self.text_ctrl_2) self.Bind(wx.EVT_BUTTON, self.On_Ok, self.button_1) self.Bind(wx.EVT_BUTTON, self.On_Cancel, self.button_2) # end wxGlade
def on_button_email_passwd(self,event):# Button save email and password email=self.text_ctrl_email.Value passwd=self.text_ctrl_email_passwd.Value if not self.V.validate_email(email)[0]: msg="Invalid Email" dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return 0 self.DB.Set_SMS_Sender_Mail(email) self.DB.Set_SMS_Sender_Mail_Password(passwd) msg="Successfully Saved" dlg = wx.MessageDialog(self, msg, 'Success',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def __init__(self, *args, **kwds): # begin wxGlade: disclaimer_win.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Dialog.__init__(self, *args, **kwds) self.label_1 = wx.StaticText(self, wx.ID_ANY, ("Disclaimer")) self.text_ctrl_1 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_WORDWRAP) self.button_disagree = wx.Button(self, wx.ID_ANY, ("Disagree")) self.button_agree = wx.Button(self, wx.ID_ANY, ("I agree")) self.text=''' This SOFTWARE PRODUCT is a an open source free software distributed with GPL 3 License. Your are free to modify it subject to the conditions laid in the license. It is also stated that the software is provided "as is" and "with all faults." THE developer makes no representations or warranties of any kind concerning the safety, suitability, lack of viruses, inaccuracies, typographical errors, or other harmful components of this SOFTWARE PRODUCT. There are inherent dangers in the use of any software, and you are solely responsible for determining whether this SOFTWARE PRODUCT is compatible with your equipment and and suits your needs. You are also solely responsible for the protection of your equipment and backup of your data, and THE PROVIDER will not be liable for any damages you may suffer in connection with using, modifying, or distributing this SOFTWARE PRODUCT.''' self.__set_properties() self.__do_layout() self.agree=False self.Bind(wx.EVT_BUTTON, self.on_disagree, self.button_disagree) self.Bind(wx.EVT_BUTTON, self.on_agree, self.button_agree) # end wxGlade
def __init__(self, *args, **kwds): # begin wxGlade: secret_win.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.label_1 = wx.StaticText(self, -1, "School Name") self.text_ctrl_1 = wx.TextCtrl(self, -1, "") self.label_2 = wx.StaticText(self, -1, "School Code") self.text_ctrl_2 = wx.TextCtrl(self, -1, "") self.button_1 = wx.Button(self, -1, "Save") self.DB=db_operations() self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.on_save, self.button_1) self.on_load() self.Center() # end wxGlade
def __init__(self, *args, **kwds): # begin wxGlade: sms_dialoge.__init__ kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.THICK_FRAME wx.Frame.__init__(self, *args, **kwds) self.panel_5 = wx.Panel(self, wx.ID_ANY) self.label_7 = wx.StaticText(self.panel_5, wx.ID_ANY, ("Username")) self.combo_box_1 = wx.ComboBox(self.panel_5, wx.ID_ANY, choices=[("Select"), ("admin"), ("teacher")], style=wx.CB_READONLY|wx.CB_DROPDOWN) self.label_8 = wx.StaticText(self.panel_5, wx.ID_ANY, ("Password")) self.text_ctrl_1 = wx.TextCtrl(self.panel_5, wx.ID_ANY, "", style=wx.TE_PASSWORD) self.button_1 = wx.Button(self.panel_5, wx.ID_ANY, ("Cancel")) self.button_2 = wx.Button(self.panel_5, wx.ID_ANY, ("Login")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_COMBOBOX, self.on_user, self.combo_box_1) self.Bind(wx.EVT_TEXT, self.on_text, self.text_ctrl_1) self.Bind(wx.EVT_BUTTON, self.on_cancel, self.button_1) self.Bind(wx.EVT_BUTTON, self.on_login, self.button_2) self.text_ctrl_1.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) self.Bind(wx.EVT_CLOSE,self.on_close,self) self.UO=user_operations(self) # end wxGlade
def __init__(self, *args, **kwds): # begin wxGlade: MyDialog.__init__ #args[ kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP wx.Dialog.__init__(self, *args, **kwds) self.text_ctrl_passwd = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD) self.button_cancel = wx.Button(self, wx.ID_ANY, _("Cancel")) self.button_ok = wx.Button(self, wx.ID_ANY, _("OK")) self.__set_properties() self.__do_layout() self.password_text='' self.Bind(wx.EVT_TEXT, self.on_passwod, self.text_ctrl_passwd) self.Bind(wx.EVT_BUTTON, self.on_button_cancel, self.button_cancel) self.Bind(wx.EVT_BUTTON, self.on_button_ok, self.button_ok) self.cancelled=False # end wxGlade
def __init__( self, parent, id, titlemsg ): wx.Dialog.__init__( self, parent, id, title=titlemsg ) MechList = [] for m in parent.ScoreServer.MechList.List: MechList.append( str(m.ID) + ": " + str(m.Name) ) self.MechText = wx.StaticText( self, -1, "Mech Selection:" ) self.MechChoice = wx.ListBox( self, -1, style=wx.LB_EXTENDED, choices=MechList ) self.CancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" ) self.OKButton = wx.Button( self, wx.ID_OK, "OK" ) TopSizer = wx.BoxSizer( wx.VERTICAL ) BtnSizer = wx.BoxSizer( wx.HORIZONTAL ) BtnSizer.Add( self.CancelButton, 0, wx.ALL, 5 ) BtnSizer.Add( self.OKButton, 0, wx.ALL, 5 ) TopSizer.Add( self.MechText, 0, wx.ALL, 5 ) TopSizer.Add( self.MechChoice, 0, wx.ALL, 5 ) TopSizer.Add( BtnSizer, 0, wx.ALL|wx.CENTER, 5 ) self.SetSizer( TopSizer ) TopSizer.Fit( self )
def __init__(self, *args, **kwds): self.settings = kwds['settings'] del kwds['settings'] # begin wxGlade: TerminalSettingsDialog.__init__ kwds["style"] = wx.DEFAULT_DIALOG_STYLE wx.Dialog.__init__(self, *args, **kwds) self.checkbox_echo = wx.CheckBox(self, -1, "Local Echo") self.checkbox_unprintable = wx.CheckBox(self, -1, "Show unprintable characters") self.radio_box_newline = wx.RadioBox(self, -1, "Newline Handling", choices=["CR only", "LF only", "CR+LF"], majorDimension=0, style=wx.RA_SPECIFY_ROWS) self.sizer_4_staticbox = wx.StaticBox(self, -1, "Input/Output") self.button_ok = wx.Button(self, wx.ID_OK, "") self.button_cancel = wx.Button(self, wx.ID_CANCEL, "") self.__set_properties() self.__do_layout() # end wxGlade self.__attach_events() self.checkbox_echo.SetValue(self.settings.echo) self.checkbox_unprintable.SetValue(self.settings.unprintable) self.radio_box_newline.SetSelection(self.settings.newline)
def __init__(self, parent, title = u"KUON FONT TOOL"): wx.Frame.__init__(self, parent, -1, title,pos=(150, 150), size=(400, 360)) panel = wx.Panel(self, -1) self.button = wx.Button(panel, -1, u"??????", pos=(50, 20)) wx.StaticText(panel ,-1 ,u"??????" ,(200, 20)) self.Bind(wx.EVT_BUTTON, self.OnClick_expng,self.button) self.button.SetDefault() self.button1 = wx.Button(panel, -1, u"?????", pos=(50, 60)) wx.StaticText(panel ,-1 ,u"?????" ,(200, 60)) self.Bind(wx.EVT_BUTTON, self.OnClick_excharlist,self.button1) self.button1.SetDefault() self.button2 = wx.Button(panel, -1, u"??????", pos=(50, 100)) wx.StaticText(panel ,-1 ,u"??????" ,(200, 100)) self.Bind(wx.EVT_BUTTON, self.OnClick_exfont_info,self.button2) self.button2.SetDefault() self.button3 = wx.Button(panel, -1, u"??????", pos=(50, 140)) wx.StaticText(panel ,-1 ,u"??????" ,(200, 140)) self.Bind(wx.EVT_BUTTON, self.OnClick_buildfont,self.button3) self.button3.SetDefault() self.Show()
def __init__(self, *args, **kwds): self.settings = kwds['settings'] del kwds['settings'] # begin wxGlade: TerminalSettingsDialog.__init__ kwds["style"] = wx.DEFAULT_DIALOG_STYLE wx.Dialog.__init__(self, *args, **kwds) self.checkbox_echo = wx.CheckBox(self, -1, "Local Echo") self.checkbox_unprintable = wx.CheckBox(self, -1, "Show unprintable characters") self.radio_box_newline = wx.RadioBox(self, -1, "Newline Handling", choices=["CR only", "LF only", "CR+LF"], majorDimension=0, style=wx.RA_SPECIFY_ROWS) self.button_ok = wx.Button(self, -1, "OK") self.button_cancel = wx.Button(self, -1, "Cancel") self.__set_properties() self.__do_layout() # end wxGlade self.__attach_events() self.checkbox_echo.SetValue(self.settings.echo) self.checkbox_unprintable.SetValue(self.settings.unprintable) self.radio_box_newline.SetSelection(self.settings.newline)
def __init__(self, parent, frame, ID, label): wx.Panel.__init__(self, parent, ID) self.frame = frame box = wx.StaticBox(self, -1, label) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) self.next_button = wx.Button(self, -1, label="Next 100") self.next_button.Bind(wx.EVT_BUTTON, self.on_next) self.previous_button = wx.Button(self, -1, label="Previous 100") self.previous_button.Bind(wx.EVT_BUTTON, self.on_previous) manual_box = wx.BoxSizer(wx.HORIZONTAL) manual_box.Add(self.previous_button, flag=wx.ALIGN_CENTER_VERTICAL) manual_box.AddSpacer(10) manual_box.Add(self.next_button, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(manual_box, 0, wx.ALL, 10) self.SetSizer(sizer) sizer.Fit(self)
def __init__(self): wx.Frame.__init__(self, parent=None, title='Hello from cx_Freeze') panel = wx.Panel(self) closeMeButton = wx.Button(panel, -1, 'Close Me') self.Connect(closeMeButton.GetId(), -1, wx.EVT_BUTTON.typeId, self.OnCloseMe) self.Connect(self.GetId(), -1, wx.EVT_CLOSE.typeId, self.OnCloseWindow) pushMeButton = wx.Button(panel, -1, 'Push Me') self.Connect(pushMeButton.GetId(), -1, wx.EVT_BUTTON.typeId, self.OnPushMe) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(closeMeButton, flag=wx.ALL, border=20) sizer.Add(pushMeButton, flag=wx.ALL, border=20) panel.SetSizer(sizer) topSizer = wx.BoxSizer(wx.VERTICAL) topSizer.Add(panel, flag=wx.ALL | wx.EXPAND) topSizer.Fit(self)
def button_clicked(self, event): log.debug("[Settings] Button clicked: {0}".format(IDS[event.GetId()])) button_id = event.GetId() keys = IDS[button_id].split(MODULE_KEY) last_key = keys[-1] if last_key in ['list_add', 'list_remove']: self.on_list_operation(MODULE_KEY.join(keys[:-1]), action=last_key) elif last_key in ['ok_button', 'apply_button']: if self.save_settings(): log.debug('Got non-dynamic changes') dialog = wx.MessageDialog(self, message=translate_key(MODULE_KEY.join(['main', 'save', 'non_dynamic'])), caption="Caption", style=wx.OK_DEFAULT, pos=wx.DefaultPosition) dialog.ShowModal() if last_key == 'ok_button': self.on_exit(event) self.settings_saved = True elif last_key == 'cancel_button': self.on_close(event) event.Skip()
def __init__(self): """Constructor""" title = 'Get Children from Sizer' wx.Frame.__init__(self, None, title=title) panel = wx.Panel(self) lbl = wx.StaticText(panel, label="I'm a label!") txt = wx.TextCtrl(panel, value="blah blah") btn = wx.Button(panel, label="Clear") btn.Bind(wx.EVT_BUTTON, self.onClear) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(lbl, 0, wx.ALL, 5) self.sizer.Add(txt, 0, wx.ALL, 5) self.sizer.Add(btn, 0, wx.ALL, 5) panel.SetSizer(self.sizer)
def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) self.logger = logging.getLogger("wxApp") self.logger.info("Test from MyPanel __init__") logText = wx.TextCtrl( self, style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL) btn = wx.Button(self, label="Press Me") btn.Bind(wx.EVT_BUTTON, self.onPress) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(logText, 1, wx.EXPAND|wx.ALL, 5) sizer.Add(btn, 0, wx.ALL, 5) self.SetSizer(sizer) txtHandler = CustomConsoleHandler(logText) self.logger.addHandler(txtHandler)
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): wx.Frame.__init__(self, None, title="Tutorial") self.eventDict = {} evt_names = [x for x in dir(wx) if x.startswith("EVT_")] for name in evt_names: evt = getattr(wx, name) if isinstance(evt, wx.PyEventBinder): self.eventDict[evt.typeId] = name grid_evt_names = [x for x in dir(wx.grid) if x.startswith("EVT_")] for name in grid_evt_names: evt = getattr(wx.grid, name) if isinstance(evt, wx.PyEventBinder): self.eventDict[evt.typeId] = name panel = wx.Panel(self, wx.ID_ANY) btn = wx.Button(panel, wx.ID_ANY, "Get POS") btn.Bind(wx.EVT_BUTTON, self.onEvent) panel.Bind(wx.EVT_LEFT_DCLICK, self.onEvent) panel.Bind(wx.EVT_RIGHT_DOWN, self.onEvent)
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 __init__(self): wx.Frame.__init__(self, None, title='Richtext Test') sizer = wx.BoxSizer(wx.VERTICAL) self.rt = wx.richtext.RichTextCtrl(self) self.rt.SetMinSize((300,200)) save_button = wx.Button(self, label="Save") save_button.Bind(wx.EVT_BUTTON, self.on_save) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.rt, 1, wx.EXPAND|wx.ALL, 6) sizer.Add(save_button, 0, wx.EXPAND|wx.ALL, 6) self.SetSizer(sizer) self.Show()
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 __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) self.currentlySelectedCell = (0, 0) self.myGrid = gridlib.Grid(self) self.myGrid.CreateGrid(12, 8) self.myGrid.Bind(gridlib.EVT_GRID_SELECT_CELL, self.onSingleSelect) self.myGrid.Bind(gridlib.EVT_GRID_RANGE_SELECT, self.onDragSelection) selectBtn = wx.Button(self, label="Get Selected Cells") selectBtn.Bind(wx.EVT_BUTTON, self.onGetSelection) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.myGrid, 1, wx.EXPAND) sizer.Add(selectBtn, 0, wx.ALL|wx.CENTER, 5) self.SetSizer(sizer)
def __init__(self, *args, **kwds): # begin wxGlade: ChatFrameGui.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel_2 = wx.Panel(self, -1, style=wx.RAISED_BORDER|wx.TAB_TRAVERSAL) self.panel_1 = wx.Panel(self, -1, style=wx.RAISED_BORDER|wx.TAB_TRAVERSAL) self.panel_3 = wx.Panel(self.panel_1, -1) self.panel_4 = wx.Panel(self.panel_1, -1) self.frmMain_statusbar = self.CreateStatusBar(1) self.lblIpAddress = wx.StaticText(self.panel_4, -1, "IP &Address") self.edtIPAddress = wx.TextCtrl(self.panel_4, -1, "127.0.0.1") self.spnConnectPort = wx.SpinCtrl(self.panel_4, -1, "8080", min=1, max=65535, style=wx.SP_ARROW_KEYS|wx.SP_WRAP) self.btnConnect = wx.ToggleButton(self.panel_4, -1, "&Connect") self.lblListenPort = wx.StaticText(self.panel_3, -1, "Listen &on port") self.spnListenPort = wx.SpinCtrl(self.panel_3, -1, "8080", min=1, max=65535, style=wx.SP_ARROW_KEYS|wx.SP_WRAP) self.btnListen = wx.ToggleButton(self.panel_3, -1, "Lis&ten") self.lblReceived = wx.StaticText(self.panel_1, -1, "Received") self.edtReceived = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2|wx.TE_AUTO_URL) self.lblSent = wx.StaticText(self.panel_1, -1, "Sent:") self.edtSent = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2|wx.TE_AUTO_URL) self.edtToSend = wx.TextCtrl(self.panel_2, -1, "") self.btnSend = wx.Button(self.panel_2, -1, "&Send") self.btnClose = wx.Button(self.panel_2, -1, "&Close") self.__set_properties() self.__do_layout() # end wxGlade
def addButtons(self): boxSizerH = wx.BoxSizer(wx.HORIZONTAL) boxSizerH.Add(wx.Button(self.panel, label='All Time Zones')) boxSizerH.Add(wx.Button(self.panel, label='Local Zone')) boxSizerH.Add(wx.Button(self.panel, label='New York')) self.statBoxSizerV.Add( boxSizerH, 1, wx.ALL ) #----------------------------------------------------------
def __init__(self, parent): wx.Panel.__init__(self, parent) parent.CreateStatusBar() menu= wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menuBar = wx.MenuBar() menuBar.Append(menu, "File") parent.SetMenuBar(menuBar) button = wx.Button(self, label="Print", pos=(0,60)) self.Bind(wx.EVT_BUTTON, self.writeToSharedQueue, button) self.textBox = wx.TextCtrl(self, size=(280,50), style=wx.TE_MULTILINE) #-----------------------------------------------------------------