def __init__(self): wx.Frame.__init__(self, None, -1, "Generic Button Example", size=(500, 500)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(1, 3, 20, 20) b = wx.Button(panel, -1, 'A wx.Button') b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, 'non-default wx.Button') sizer.Add(b) sizer.Add((10,10)) b = buttons.GenButton(panel, -1, 'Genric Button')#基本的通用按钮 sizer.Add(b) b = buttons.GenButton(panel, -1, 'disabled Generic')#无效的通用按钮 b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, 'F')#自定义尺寸和颜色的按钮 b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTipString("This is a BIG button...") sizer.Add(b) bmp = wx.Image("Pause.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() b = buttons.GenBitmapButton(panel, -1, bmp)#通用位图按钮 sizer.Add(b) self.btest = buttons.GenBitmapToggleButton(panel, -1, bmp)#通用位图开关按钮 sizer.Add(self.btest) b = buttons.GenBitmapTextButton(panel, -1, bmp, 'Bitmapped Text',size=(375, 75))#位图文本按钮 b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, 'Toggle Button')#通用开关按钮 sizer.Add(b) panel.SetSizer(sizer)
def __init__(self): wx.Frame.__init__(self,None,-1,u"批量修改文件名称", style=wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER)) panel = wx.Panel(self,-1) panel.SetBackgroundColour('white') self.CreateStatusBar(1, wx.ST_SIZEGRIP) self.SetStatusText(u'一个批量修改文件名字的脚本',0) self.Open = wx.TextCtrl(panel,-1,size=(250,50), style=wx.TE_MULTILINE) self.OldName = wx.TextCtrl(panel,-1,size=(250,-1)) self.NewName = wx.TextCtrl(panel,-1,size=(250,-1)) self.OpenButton = buttons.GenButton(panel,-1,u'打开文件',size=(70,-1)) self.FindButton = buttons.GenButton(panel,-1,u'查询',size=(70,-1)) self.ModButton = buttons.GenButton(panel,-1,u'修改',size=(70,-1)) self.OpenButton.SetUseFocusIndicator(False) self.FindButton.SetUseFocusIndicator(False) self.ModButton.SetUseFocusIndicator(False) self.Bind(wx.EVT_BUTTON,self.OpenFile,self.OpenButton) self.Bind(wx.EVT_BUTTON,self.FindFile,self.FindButton) self.Bind(wx.EVT_BUTTON,self.ModFile,self.ModButton) self.cmd = wx.TextCtrl(panel, -1, u''' 使用步骤: 1.选择所在文件目录; 2.输入需要批量修改的文件名并提交; 3.输入变更后的文件名; 4.提交进行批量修改。 ''', size=(330, 200), style=wx.TE_MULTILINE) self.FilePath = '' self.OldText = '' self.NewText = '' #########################布局:############################## MainSizer = wx.BoxSizer(wx.VERTICAL) B1 = wx.StaticBox(panel,-1,u'输入文件夹地址:') BOX1 = wx.StaticBoxSizer(B1,wx.VERTICAL) OpenSizer = wx.GridBagSizer(hgap=10,vgap=10) OpenSizer.Add(self.Open,pos=(0,0)) OpenSizer.Add(self.OpenButton,pos=(0,1),span=(1,2),flag=wx.EXPAND) BOX1.Add(OpenSizer) B2 = wx.StaticBox(panel,-1,u'查找和替换') BOX2 = wx.StaticBoxSizer(B2,wx.VERTICAL) FindSizer = wx.GridBagSizer(hgap=10,vgap=10) FindSizer.Add(self.OldName,pos=(0,0)) FindSizer.Add(self.FindButton,pos=(0,1)) FindSizer.Add(self.NewName,pos=(1,0)) FindSizer.Add(self.ModButton,pos=(1,1)) BOX2.Add(FindSizer) MainSizer.Add(BOX1,flag=wx.ALIGN_CENTER) MainSizer.Add(BOX2,flag=wx.ALIGN_CENTER) MainSizer.Add(self.cmd,flag=wx.ALIGN_CENTER|wx.SHAPED) panel.SetSizer(MainSizer) MainSizer.Fit(self)
def createGui(self): self.mainSizer = wx.GridBagSizer(self.xBorder, self.yBorder) nazwy = [u'DZIURA', u'SŁOWO'] kolory = ['indian red', 'yellow'] b = bt.GenButton(self, -1, nazwy[0], name=nazwy[0]) b.SetFont( wx.Font(75, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)) b.SetBezelWidth(3) b.SetBackgroundColour(self.backgroundColour) b.SetForegroundColour(kolory[0]) b.Bind(wx.EVT_LEFT_DOWN, self.onPress) self.mainSizer.Add(b, (0, 0), wx.DefaultSpan, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=self.xBorder) b = bt.GenButton(self, -1, nazwy[1], name=nazwy[1]) b.SetFont( wx.Font(75, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)) b.SetBezelWidth(3) b.SetBackgroundColour(self.backgroundColour) b.SetForegroundColour(kolory[1]) b.Bind(wx.EVT_LEFT_DOWN, self.onPress) self.mainSizer.Add(b, (1, 0), wx.DefaultSpan, wx.EXPAND | wx.LEFT | wx.RIGHT, border=self.xBorder) b = bt.GenBitmapButton(self, -1, bitmap=self.functionButtonPath[0], name=self.functionButtonName[0]) b.SetBackgroundColour(self.backgroundColour) b.SetBezelWidth(3) b.Bind(wx.EVT_LEFT_DOWN, self.onPress) self.mainSizer.Add(b, (2, 0), wx.DefaultSpan, wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT, border=self.xBorder) for number in range(self.numberOfRows[0]): self.mainSizer.AddGrowableRow(number) for number in range(self.numberOfColumns[0]): self.mainSizer.AddGrowableCol(number) self.SetSizer(self.mainSizer) self.SetBackgroundColour('black') self.Layout() self.Refresh() self.Center() self.MakeModal(True) self.flaga = 0
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 400)) panel = wx.Panel(self, -1) #Can also have rows=x. Can cause errors if set wrongly #Don't need the n = ... part, but helped for troubleshooting sizer = wx.FlexGridSizer(cols=3, vgap=20, hgap=20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) #Interesting, can reuse b, now that it is saved to sizer b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add((10, 10)) b = buttons.GenButton(panel, -1, 'Generic Button') sizer.Add(b) b = buttons.GenButton(panel, -1, 'disabled Generic') b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, 'bigger') b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) #?? Does capitalisation matter b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTipString("This is a BIG button...") sizer.Add(b) bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap() b = buttons.GenBitmapButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmapped Text", size=(175, 175)) #?? What do again b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, "ToggleButton") sizer.Add(b) panel.SetSizer(sizer)
def _create_buttons(self): self.btn_sizer = wx.BoxSizer(wx.HORIZONTAL) self.sort_filter_btn = buttons.GenBitmapTextButton(self, -1, None, "Sort & Filter ") self.sort_filter_btn.SetBitmapLabel(get_icon("data-filter", 24)) self.expand_all_btn = buttons.GenButton(self, label=" Expand All ") self.collapse_all_btn = buttons.GenButton(self, label=" Collapse All ") self.btn_sizer.Add(self.sort_filter_btn, 0, wx.EXPAND, 0) self.btn_sizer.Add(self.expand_all_btn, 0, wx.EXPAND, 0) self.btn_sizer.Add(self.collapse_all_btn, 0, wx.EXPAND, 0)
def __init__(self): wx.Frame.__init__(self, None, -1, "Generic Button Example", size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(3, 3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) b = buttons.GenButton(panel, -1, "Generic Button") sizer.Add(b) b = buttons.GenButton(panel, -1, "disabled Generic") b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, "bigger") b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTip("This is a BIG button!") sizer.Add(b) bmp = wx.Image("img/button-off.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() b = buttons.GenBitmapButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmap Text", size=(175, 75)) b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, "Toggle Button") sizer.Add(b) panel.SetSizer(sizer)
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(1, 3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add((10, 10)) b = buttons.GenButton(panel, -1, 'Generic Button') sizer.Add(b) b = buttons.GenButton(panel, -1, 'disabled Generic') b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, 'bigger') b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTipString("This is a BIG button...") sizer.Add(b) bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap() b = buttons.GenBitmapButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmapped Text", size=(175, 75)) b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, "Toggle Button") sizer.Add(b) panel.SetSizer(sizer)
def reward(self, event): self.parent.mainSizer.Clear(deleteWindows=True) self.subSizer = wx.GridSizer(1, 1, self.xBorder, self.yBorder) b = bt.GenButton(self.parent, -1, u'CHCESZ WYŁĄCZYĆ?\n \nPRZYCIŚNIJ.') b.SetFont( wx.Font(25, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)) b.SetBezelWidth(3) b.SetBackgroundColour('white') b.Bind(self.event, self.OnExit) self.subSizer.Add(b, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=self.xBorder) self.parent.mainSizer.Add(self.subSizer, proportion=1, flag=wx.EXPAND) self.parent.SetSizer(self.parent.mainSizer) self.parent.Layout() path = self.pathToAP + 'multimedia/ewriting/rewards/' song = os.listdir(path)[np.random.randint(0, len(os.listdir(path)), 1)] mixer.music.stop() mixer.music.load(path + song) mixer.music.play()
def __init__(self, *args, **kw): # ensure the parent's __init__ is called super(HelloFrame, self).__init__(*args, **kw) # create a panel in the frame pnl = wx.Panel(self) # and put some text with a larger bold font on it st = wx.StaticText(pnl, label="Hello World!", pos=(25, 25)) font = st.GetFont() font.PointSize += 10 font = font.Bold() st.SetFont(font) # create a menu bar self.makeMenuBar() # and a status bar self.CreateStatusBar() self.SetStatusText("Welcome to wxPython!") #my buttons btn1 = buttons.GenButton(pnl, -1, "Press Me", pos=(100, 75)) # What other things can I put on the panel # Would like to get a txt box and be able to read txt in? # How do I do that. '''
def InitUI(self): panel = wx.Panel(self) self.Software_Icon() image = wx.Image('hnust(black).ico', wx.BITMAP_TYPE_ICO) temp = image.ConvertToBitmap() #size = temp.GetWidth(), temp.GetHeight() self.bmp = wx.StaticBitmap(parent=panel, bitmap=temp) self.text = wx.StaticText( panel, label= '四步走:\n ①输入学号按回车获取验证码\n ②第二框输入教务网密码\n ⑤输入验证码按回车或点击"查询成绩"即可\n', pos=(10, 10)) self.text.SetForegroundColour('#FF4500') button = wxbutton.GenButton(panel, 1, 'Get!') box = wx.BoxSizer(wx.VERTICAL) box.Add(self.bmp, 0, wx.CENTER, 50) box.Add(self.text, 0, wx.CENTER, 50) box.Add(button, 0, wx.CENTER, 50) panel.SetSizerAndFit(box) self.Bind(wx.EVT_BUTTON, self.OnClick, button)
def createButtons(self): """ A method that creates as many buttons as the dataunit has timepoints, so that each button represent one time point """ nrow = 0 ncol = 0 if self.dataUnit: n = self.dataUnit.getNumberOfTimepoints() else: n = self.numberOfTimepoints for i in range(n): if ncol == 30: nrow += 1 ncol = 0 btn = buttons.GenButton(self.buttonFrame, -1, "%d" % (i + 1), size=(24, 24)) btn.SetFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL)) btn.Bind( wx.EVT_BUTTON, lambda e, btn=btn, i=i: self.buttonClickedCallback(btn, i)) btn.origColor = btn.GetBackgroundColour() btn.origFgColor = btn.GetForegroundColour() self.buttonList.append(btn) self.timepointButtonSizer.Add(btn, (nrow, ncol)) ncol = ncol + 1 self.buttonFrame.Layout() self.buttonFrame.Raise() self.timepointButtonSizer.Fit(self.buttonFrame) self.mainsizer.Fit(self)
def add_button(self, message: str, position: tuple, size: tuple, button_type: str = None, color: str = None, action: str = 'default') -> None: """Add Button.""" # Button Type if button_type == 'gradient_button': btn = GB.GradientButton(self.panel, label=message, pos=position, size=size) elif button_type == 'aqua_button': btn = AB.AquaButton(self.panel, label=message, pos=position, size=size) else: btn = buttons.GenButton(self.panel, label=message, pos=position, size=size) # You can really only set colors with GenButtons as the others # use native widgets! if color: btn.SetBackgroundColour(color) # Attach Custom Actions self.bind_action(action, btn) self.buttons.append(btn)
def InitUI(self): #绘制面板 panel = wx.Panel(self) #图标设定 self.Software_Icon() #图片插入 image = wx.Image('hnust(black).ico', wx.BITMAP_TYPE_ICO) temp = image.ConvertToBitmap() #size = temp.GetWidth(), temp.GetHeight() self.bmp = wx.StaticBitmap(parent=panel, bitmap=temp) #静态文本 self.text = wx.StaticText( panel, label= '--请检查你输入的学号、密码或验证码是否正确\n--学号输入完成记得按回车键\n--请核对你所查询的学段\n--或者刷新验证码试试吧~', pos=(10, 10)) self.text.SetForegroundColour('#FF4500') #确定按钮 button = wxbutton.GenButton(panel, 0, '好的~') #控件排版 box = wx.BoxSizer(wx.VERTICAL) box.Add(self.bmp, 0, wx.CENTER, 50) box.Add(self.text, 0, wx.CENTER, 50) box.Add(button, 0, wx.CENTER, 50) panel.SetSizerAndFit(box) #事件处理 self.Bind(wx.EVT_BUTTON, self.OnClick, button)
def InitUI(self): panel = wx.Panel(self) logo_sys = wx.Image(load_image('icon1.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(panel, id=-1, bitmap=logo_sys, pos=(90, 90), size=(100, 100)) logo_title = wx.StaticText(panel, id=-1, label='iShavanti', pos=(90, 210)) logo_title.SetForegroundColour('#0a74f7') title_font = wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False) logo_title.SetFont(title_font) button_login = wxButton.GenButton(panel, id=-1, label='登陆', pos=(40, 270), size=(200, 40), style=wx.BORDER_NONE) button_login.SetBackgroundColour('#0a74f7') button_login.SetForegroundColour('white') self.Bind(wx.EVT_BUTTON, self.loginSys, button_login)
def createGui(self): self.subSizers = [ ] self.mainSizer = wx.BoxSizer( wx.VERTICAL ) self.numberOfCells = self.numberOfRows[ 0 ] * self.numberOfColumns[ 0 ] if self.control != 'tracker': event = eval('wx.EVT_LEFT_DOWN') else: event = eval('wx.EVT_BUTTON') for panel in self.panels.keys( ): subSizer = wx.GridBagSizer( self.xBorder, self.yBorder ) self.subSizers.append( subSizer ) if self.panels != { 1 : [ [], [] ] }: index = 0 for index, logo in enumerate( self.panels[ panel ][ 1 ] ): b = bt.GenBitmapButton( self, -1, name = self.panels[ panel ][ 0 ][ index ], bitmap = logo ) b.SetBackgroundColour( self.backgroundColour ) b.SetBezelWidth( 3 ) b.Bind( event, self.onPress ) subSizer.Add( b, ( index / self.numberOfColumns[ 0 ], index % self.numberOfColumns[ 0 ] ), wx.DefaultSpan, wx.EXPAND ) else: index = -1 index_2 = 0 while index + index_2 < self.numberOfCells - (self.numberOfColumns[0]+1): index_2 += 1 b = bt.GenButton( self, -1, name = 'empty' ) b.Bind( event, self.onPress ) b.SetBackgroundColour( self.backgroundColour ) subSizer.Add( b, ( ( index + index_2 ) / self.numberOfColumns[ 0 ], ( index + index_2 ) % self.numberOfColumns[ 0 ] ), wx.DefaultSpan, wx.EXPAND ) b = bt.GenBitmapButton( self, -1, bitmap = self.functionButtonPath[ 0 ], name = self.functionButtonName[ 0 ] ) b.SetBackgroundColour( self.backgroundColour ) b.SetBezelWidth( 3 ) b.Bind( event, self.onPress ) subSizer.Add( b, ( ( index + index_2 + 1 ) / self.numberOfColumns[ 0 ], ( index + index_2 + 1 ) % self.numberOfColumns[ 0 ] ), (1, self.numberOfColumns[0]), wx.EXPAND ) for number in range( self.numberOfRows[ 0 ] ): subSizer.AddGrowableRow( number ) for number in range( self.numberOfColumns[ 0 ] ): subSizer.AddGrowableCol( number ) self.Layout( ) self. mainSizer.Add( subSizer, proportion = 1, flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border = self.xBorder ) self.SetSizer( self. mainSizer ) self.Center( True ) if panel != 1: self.mainSizer.Show( item = self.subSizers[ panel - 1 ], show = False, recursive = True ) self.SetSizer( self.mainSizer )
def MakeButton(self): if self.cpStyle & wx.CP_GTK_EXPANDER: return None selection = self.btnRB.GetSelection() if selection == 0: # standard wx.Button btn = wx.Button(self.cp, -1, self.label1) elif selection == 1: # buttons.GenButton btn = buttons.GenButton(self.cp, -1, self.label1) elif selection == 2: # buttons.GenBitmapButton bmp = images.Smiles.GetBitmap() btn = buttons.GenBitmapButton(self.cp, -1, bmp) elif selection == 3: # buttons.GenBitmapTextButton bmp = images.Mondrian.GetBitmap() btn = buttons.GenBitmapTextButton(self.cp, -1, bmp, self.label1) elif selection == 4: # buttons.ThemedGenButton btn = buttons.ThemedGenButton(self.cp, -1, self.label1) elif selection == 5: # buttons.ThemedGenBitmapTextButton bmp = images.Mondrian.GetBitmap() btn = buttons.ThemedGenBitmapTextButton(self.cp, -1, bmp, self.label1) return btn
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(4, 3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add((10, 10)) b = buttons.GenButton(panel, -1, 'Generic Button') # Базовая типовая кнопка sizer.Add(b) b = buttons.GenButton( panel, -1, 'disabled Generic') # Блокированная типовая кнопка b.Enable(False) sizer.Add(b) b = buttons.GenButton( panel, -1, 'bigger') # Кнопка с заданным пользователем размером и цветом b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTip("This is a BIG button...") sizer.Add(b) bmp = wx.Image("bird.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() b = buttons.GenBitmapButton( panel, -1, bmp) # Типовая кнопка с битовым изображением sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) # Типовая кнопка-переключатель с битовым изображением b = buttons.GenBitmapTextButton( panel, -1, bmp, "Bitmapped Text", size=(175, 75)) # Кнопка с битовым изображением и текстом b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton( panel, -1, "Toggle Button") # Типовая кнопка-переключатель sizer.Add(b) panel.SetSizer(sizer)
def __init__( self, parent , year ): wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 400,200 ), style = wx.TAB_TRAVERSAL ) bSizer15 = wx.BoxSizer( wx.VERTICAL ) bSizer16 = wx.BoxSizer( wx.HORIZONTAL ) self.sallat = year self.sal = str(year) self.m_bpButton1 = wx.BitmapButton( self, wx.ID_ANY, R.GetBitmap(), wx.DefaultPosition, wx.Size( 15,15 ), wx.BU_AUTODRAW ) bSizer16.Add( self.m_bpButton1, 0, wx.ALIGN_CENTER, 5 ) self.m_staticText18 = buttons.GenButton( self, wx.ID_ANY, self.sal, wx.DefaultPosition, wx.DefaultSize, style=wx.BORDER_NONE ) #self.m_staticText18.Wrap( -1 ) bSizer16.Add( self.m_staticText18, 1, wx.ALL, 5 ) self.m_bpButton2 = wx.BitmapButton( self, wx.ID_ANY, L.GetBitmap(), wx.DefaultPosition, wx.Size( 15,15 ), wx.BU_AUTODRAW ) bSizer16.Add( self.m_bpButton2, 0, wx.ALIGN_CENTER, 5 ) #self.m_button2.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) ) #self.m_button2.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) ) bSizer15.Add( bSizer16, 1, wx.EXPAND, 5 ) gSizer1 = wx.GridSizer( 3, 4, 0, 0 ) mont = Month_name self.moncal = [] i = 0 MID = range(12) for mah in range(12): self.moncal.append( wx.Button( self, MID[i], mont[mah], wx.DefaultPosition, wx.DefaultSize, 0 )) gSizer1.Add( self.moncal[i], 0, wx.EXPAND, 5 ) self.moncal[i].Bind( wx.EVT_BUTTON, self.Onmonth ) i = i + 1 bSizer15.Add( gSizer1, 5, wx.EXPAND, 1 ) bSizer17 = wx.BoxSizer( wx.VERTICAL ) today = datetime.date.today().isoformat() self.daytxt = wx.StaticText( self, wx.ID_ANY, u"Bugün: "+today, wx.DefaultPosition, wx.DefaultSize, 0 ) self.daytxt.Wrap( -1 ) bSizer17.Add( self.daytxt, 0, wx.ALIGN_CENTER, 1 ) bSizer15.Add( bSizer17, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer15 ) self.Layout() self.m_bpButton1.Bind( wx.EVT_BUTTON, self.Onleft ) self.m_bpButton2.Bind( wx.EVT_BUTTON, self.Onright ) self.m_staticText18.Bind( wx.EVT_BUTTON, self.Onsal )
def __init__(self): wx.Frame.__init__(self, None, -1, "Generic Button Example", size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(1, 3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() b.SetToolTipString("a wx.Button") sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add((10, 10)) b = buttons.GenButton(panel, -1, "Genric Button") sizer.Add(b) b = buttons.GenButton(panel, -1, "disabled Generic") b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, 'bigger') b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTipString("this is a Big button..") sizer.Add(b) bmp = wx.Bitmap("img/002.jpg", wx.BITMAP_TYPE_JPEG) b = buttons.GenBitmapButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmapped Text", size=(175, 75)) self.Bind(wx.EVT_BUTTON, self.OnClick, b) b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, "Toggle Button") sizer.Add(b) b = wx.ToggleButton(panel, -1, "on/off") self.Bind(wx.EVT_TOGGLEBUTTON, self.OnClick, b) sizer.Add(b) panel.SetSizer(sizer)
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(4, 3, 20, 20) btn = wx.Button(panel, -1, "A wx.Button") btn.SetDefault() sizer.Add(btn) btn = wx.Button(panel, -1, "Non-default wx.Button") sizer.Add(btn) sizer.Add((10, 10)) btn = buttons.GenButton(panel, -1, 'Generic Button') # 基本的通用按钮 sizer.Add(btn) btn = buttons.GenButton(panel, -1, 'Disabled Generic') # 无效的通用按钮 btn.Enable(False) sizer.Add(btn) btn = buttons.GenButton(panel, -1, 'Bigger') # 自定义尺寸和颜色的按钮 btn.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) btn.SetBezelWidth(5) btn.SetBackgroundColour("Navy") btn.SetForegroundColour("White") btn.SetToolTipString("This is a BIG button...") sizer.Add(btn) bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap() btn = buttons.GenBitmapButton(panel, -1, bmp) # 通用位图按钮 sizer.Add(btn) btn = buttons.GenBitmapToggleButton(panel, -1, bmp) # 通用位图开关按钮 sizer.Add(btn) btn = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmap Text", size=(175, 75)) # 位图文本按钮 btn.SetUseFocusIndicator(False) sizer.Add(btn) btn = buttons.GenToggleButton(panel, -1, "Toggle Button") # 通用开关按钮 sizer.Add(btn) panel.SetSizer(sizer)
def TestGenericButton(self, p): import wx.lib.buttons as b w = b.GenButton(p, -1, "Generic Button") w.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) w.SetBezelWidth(5) w.SetInitialSize() w.SetBackgroundColour("Navy") w.SetForegroundColour(wx.WHITE) self.DoWidget(w)
def test_lib_buttons1(self): btn = buttons.GenButton(self.frame, label='label') btn = buttons.GenButton(self.frame, -1, 'label', (10,10), (100,-1), wx.BU_LEFT) bmp = wx.Bitmap(pngFile) btn = buttons.GenBitmapButton(self.frame, bitmap=bmp) btn = buttons.GenBitmapTextButton(self.frame, label='label', bitmap=bmp) btn.SetBitmapFocus(bmp) btn.SetBitmapDisabled(bmp) btn.SetBitmapSelected(bmp) btn = buttons.GenBitmapToggleButton(self.frame, bitmap=bmp) btn.SetToggle(True) self.assertTrue(btn.GetValue()) self.assertEqual(btn.GetBitmapLabel(), bmp)
def shape_button(self,color1,color2,loc,size,id,string,where_to,add_to): """ shapes a button and presents it on the screen """ b = buttons.GenButton(where_to, id, string,loc,size) b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour(color1) b.SetForegroundColour(color2) add_to.Add(b)
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 350)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(1, 3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add((10, 10)) b = buttons.GenButton(panel, -1, 'Generic Button') sizer.Add(b) b = buttons.GenButton(panel, -1, 'disabled Generic') b.Enable(False) sizer.Add(b) b = buttons.GenButton(panel, -1, 'bigger') b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetBackgroundColour("Navy") b.SetForegroundColour("white") b.SetToolTipString("This is a BIG button...") sizer.Add(b) bmp = wx.Image( "C:\\Users\\Ashish\\.eclipse\\231700603\\configuration\\org.eclipse.equinox.launcher\\com.jrockit.mc.rcp.application_5.3.0.159881\\splash.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap() b = buttons.GenBitmapButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapToggleButton(panel, -1, bmp) sizer.Add(b) b = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmapped Text", size=(175, 75)) b.SetUseFocusIndicator(False) sizer.Add(b) b = buttons.GenToggleButton(panel, -1, "Toggle Button") sizer.Add(b) panel.SetSizer(sizer)
def __init__(self, parent, title): wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(400, 300)) panel = wx.Panel(self) # Build a bitmap button and a normal one bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_OTHER, (16, 16)) btn1 = buttons.ThemedGenBitmapButton(panel, -1, bmp, pos=(50, 50)) btn2 = buttons.GenButton(panel, -1, "Hello World!", pos=(50, 100))
def create_button(self, label, func, pos=wx.DefaultPosition, size=wx.DefaultSize): """ create a button, bind its click-event to a function """ button = buttons.GenButton(self.panel, -1, label, pos, size) self.Bind(wx.EVT_BUTTON, func, button) return button
def __init__(self): wx.Dialog.__init__(self, None, -1, '优化数据库', size=(400, 370), style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX) panel = wx.Panel(self) v_box = wx.BoxSizer(wx.VERTICAL) # ----------- h_box = wx.BoxSizer(wx.HORIZONTAL) check_button = buttons.GenButton(panel, -1, "开始优化") check_button.SetBezelWidth(1) check_button.SetBackgroundColour('white') check_button.Bind(wx.EVT_BUTTON, self.OnCheck) cancel_button = buttons.GenButton(panel, wx.ID_CANCEL, "取消") cancel_button.SetBezelWidth(1) cancel_button.SetBackgroundColour('white') h_box.Add(check_button, 1, wx.EXPAND) h_box.Add(cancel_button, 1, wx.EXPAND | wx.LEFT, 10) line = wx.StaticLine(panel, -1, size=(-1, -1), style=wx.LI_HORIZONTAL) v_box.Add(h_box, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10) v_box.Add(line, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 10) # ----------- text = "优化数据库是指:\n清除空卡片\n重置由于程序错误或设置不当造成信息错乱的词库\n点击开始优化按钮进行优化" self.tc = wx.TextCtrl(panel, -1, text, style=wx.TE_RICH | wx.TE_MULTILINE | wx.TE_READONLY) v_box.Add(self.tc, 1, wx.EXPAND | wx.ALL, 10) panel.SetSizer(v_box) self.Center()
def __init__(self): wx.Frame.__init__(self, None, -1, 'Generic Button Example', size=(500, 300)) panel = wx.Panel(self, -1) sizer = wx.FlexGridSizer(3, 20, 20) b = wx.Button(panel, -1, "A wx.Button") b.SetDefault() sizer.Add(b) b = wx.Button(panel, -1, "non-default wx.Button") sizer.Add(b) sizer.Add(10, 10) b = buttons.GenButton(panel, -1, 'Generic Button') sizer.Add(b) b = buttons.GenButton(panel, -1, "disabled Generic") b.Enable(False) sizer.Add(b)
def InitUI(self): panel = wx.Panel(self) # logo_sys = wx.Image(load_image('logo_sys.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() # wx.StaticBitmap(panel, -1, logo_sys, pos=(90, 90), size=(100, 100)) logo_title = wx.StaticText(panel, -1, '天马行空', pos=(120, 210)) logo_title.SetForegroundColour('#0a74f7') # titleFont = wx.Font(13, wx.DEFAULT, wx.BOLD, wx.NORMAL, True) # logo_title.SetFont(titleFont) button_Login = wxButton.GenButton(panel, -1, '登录', pos=(40, 270), size=(200, 40)) button_Login.SetBackgroundColour('#0a74f7') button_Login.SetForegroundColour('white') self.Bind(wx.EVT_BUTTON, self.loginSys, button_Login)
def __init__( self, parent, name, ): super(VideoItem, self).__init__(parent, name=name) # 更新下载进度条 # self.timer = wx.Timer(self) # self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.m_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.m_sizer) bmp = wx.Image(resource.img_poster).ConvertToBitmap() self.poster = wx.StaticBitmap(self, bitmap=bmp) self.video_name = wx.StaticText(self, label=u"DGUT视频下载") self.download_progress = wx.Gauge(self, -1, range=100) #self.cancel_btn = wx.Button(self, label=u"取消") self.path_label = wx.StaticText(self, label=u"存放在:") self._dir_btn = GenButton.GenButton(self, label=u" ", style=wx.BORDER_NONE, size=(-1, 18)) flags = wx.ALIGN_LEFT self.file_sizer = wx.BoxSizer(wx.HORIZONTAL) self.file_sizer.AddMany([ (self.path_label, 0, flags | wx.ALIGN_CENTER_VERTICAL | wx.ALL ^ wx.LEFT, 5), (self._dir_btn, 0, wx.ALIGN_CENTER_VERTICAL, wx.RIGHT, 5), #(self.cancel_btn, 0, flags | wx.ALL, 5) ]) self.vsizer = wx.BoxSizer(wx.VERTICAL) self.vsizer.AddMany([(self.video_name, 0, flags | wx.ALL, 5), (self.download_progress, 0, flags | wx.ALL, 5), (self.file_sizer, 0, flags | wx.ALL, 5)]) self.m_sizer.AddMany([(self.poster, 0, wx.ALL, 6), (self.vsizer, 0, wx.ALL, 5)]) self.Bind(wx.EVT_BUTTON, self.OnButton, self._dir_btn) self.app = wx.GetApp()