def MakeToolBar(self): TBFLAGS = (wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) tb = self.CreateToolBar(TBFLAGS) tsize = (24, 24) catagory_new_bmp = images.catagory_new.GetBitmap() goods_new_bmp = images.goods_new.GetBitmap() tb.SetToolBitmapSize(tsize) tb.AddTool(10, "新增类别", catagory_new_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "新增类别", "增加物品类别,用于物品归类,便于物品管理'", None) tb.AddTool(20, "新增物品", goods_new_bmp, wx.NullBitmap, wx.ITEM_NORMAL, "新增物品", "添加新的物品", None) self.Bind(wx.EVT_TOOL, self.OnAddCatagory, id=10) self.Bind(wx.EVT_TOOL, self.OnAddGoods, id=20) tb.AddStretchableSpace() login_msg = '您好,{},欢迎使用系统! '.format( userservice.get_current_user().get('username')) login_info = wx.StaticText(tb, wx.ID_ANY, login_msg) tb.AddControl(login_info) tb.AddSeparator() bmp = StaticBitmap(tb, -1, images.setting.GetBitmap()) tb.AddControl(bmp) modifypass_lb = StaticText(tb, -1, "修改密码") tb.AddControl(modifypass_lb) modifypass_lb.Bind(wx.EVT_MOUSE_EVENTS, self.OnModifyPassword) tb.Realize()
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15)) bmp = images.Test2.GetBitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight())) bmp = images.Robin.GetBitmap() StaticBitmap(self, -1, bmp, (80, 150)) StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175))
def SetPopupBitmap(self, bitmap): """ Sets The ToasterBox Background Image. Use It Only For ToasterBoxes Created With TB_SIMPLE Style. """ bitmap = bitmap.ConvertToImage() xsize, ysize = self.GetSize() bitmap = bitmap.Scale(xsize, ysize) bitmap = bitmap.ConvertToBitmap() self._staticbitmap = StaticBitmap(self, -1, bitmap, pos=(0, 0)) if self._closingstyle & TB_ONCLICK and self._windowstyle != TB_CAPTION: self._staticbitmap.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
def addDragDropItem(self, newid, icon, dragCallback, toolTip): """ Add an item to the toolbar """ bmp = wx.Image(os.path.join(self.iconpath, icon), wx.BITMAP_TYPE_ANY).ConvertToBitmap() bmp2 = wx.EmptyBitmap(38, 32) dc = wx.MemoryDC() dc.SelectObject(bmp2) #dc.SetPen(wx.Pen(self.GetBackgroundColour(),1)) #dc.SetBrush(wx.Brush(self.GetBackgroundColour())) dc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1)) dc.SetBrush(wx.Brush(wx.Colour(0, 0, 0))) dc.DrawRectangle(0, 0, 38, 32) x = 1 y = 0 dc.DrawBitmap(bmp, 7, 0) for i in range(0, 10): dc.SetPen(wx.Pen(wx.Colour(135, 135, 135), 1)) dc.DrawLine(x, y, x + 6, y) y += 1 dc.SetPen(wx.Pen(wx.Colour(100, 100, 100), 1)) dc.DrawLine(x, y, x + 6, y) y += 1 y += 2 dc.SelectObject(wx.NullBitmap) self.icons[newid] = bmp2 sbmp = StaticBitmap(self, newid, bmp, style=wx.RAISED_BORDER, size=(40, 40)) self.sbmps[newid] = sbmp sbmp.Bind(wx.EVT_MOTION, dragCallback) #p.Bind(wx.EVT_MOTION,dragCallback) #self.sizer.Add(p,flag=wx.RIGHT,border=2) #p.Bind( wx.EVT_LEFT_UP,self.onToolClick) self.sizer.Add(sbmp, flag=wx.RIGHT, border=2) sbmp.Bind(wx.EVT_LEFT_UP, self.onToolClick) sbmp.SetHelpText(toolTip.GetTip()) sbmp.SetToolTip(toolTip)
def SetPopupBitmap(self, bitmap): """ Sets the L{ToasterBox} background image. :param `bitmap`: a valid `wx.Bitmap` object. If defaulted to ``None``, then no background bitmap is used. :note: Use this method only for a L{ToasterBox} created with the ``TB_SIMPLE`` style. """ bitmap = bitmap.ConvertToImage() xsize, ysize = self.GetSize() bitmap = bitmap.Scale(xsize, ysize) bitmap = bitmap.ConvertToBitmap() self._staticbitmap = StaticBitmap(self, -1, bitmap, pos=(0, 0)) if self._closingstyle & TB_ONCLICK and self._windowstyle != TB_CAPTION: self._staticbitmap.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
def __init__(self): """初始化登录对话框,包括用户名、密码。""" self.delta = (0,0) wx.Dialog.__init__(self, parent=None, id=-1,title=APP_TITLE,style=wx.STAY_ON_TOP) sizer = wx.GridBagSizer(hgap=5, vgap=10) self.SetBackgroundColour("#ffffff") self.SetIcon(wx.Icon('img/Loading.ico',wx.BITMAP_TYPE_ICO)) bmp = wx.Image('img/title.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.logo = wx.StaticBitmap(self, -1, bmp, size=(340, bmp.GetHeight())) sizer.Add(self.logo, pos=(0, 0), span=(1,6), flag=wx.EXPAND) bmp_logo = wx.Image('img/logo.jpg', wx.BITMAP_TYPE_JPEG).ConvertToBitmap() StaticBitmap(self, -1, bmp_logo, (0, 27), (bmp_logo.GetWidth(), bmp_logo.GetHeight())) #Link text link = hl.HyperLinkCtrl(self, wx.ID_ANY,u"IOMS集中运维管理系统", URL="http://code.google.com/p/ioms/",pos=(290, 170)) link.SetColours("BLUE", "BLUE", "BLUE") link.EnableRollover(True) link.SetUnderlines(False, False, False) link.UpdateLink() #Loging text # self.logintext=StaticText(self, -1, u"正在验证,请稍等...", (100, 160)) # self.logintext.Show(False) # Label sizer.Add(wx.StaticText(self, -1, u"用户名: "), pos=(2, 1), flag=wx.ALIGN_RIGHT) sizer.Add(wx.StaticText(self, -1, u"密 码: "), pos=(3, 1), flag=wx.ALIGN_RIGHT) # Text self.username = wx.TextCtrl(self, -1,"", size=(160, 20)) self.username.SetMaxLength(20) self.password = wx.TextCtrl(self, -1,"", size=(160, 20), style=wx.TE_PASSWORD) self.password.SetMaxLength(20) sizer.Add(self.username, pos=(2,2), span=(1,1)) sizer.Add(self.password, pos=(3,2), span=(1,1)) self.ok = wx.Button(self, -1, u"确 定", (35, 20)) self.ok.SetForegroundColour("#006699") self.cancel = wx.Button(self, -1, u"取消登录", (35, 20)) self.cancel.SetForegroundColour("#006699") # bind the evt #self.ok.Bind(wx.EVT_LEFT_DOWN,self.OnDisplayInfo) self.ok.Bind(wx.EVT_BUTTON, self.OnOK) self.ok.Bind(wx.EVT_LEFT_UP, self.OnOK) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel) self.Bind(wx.EVT_MOTION,self.OnMouseMove) self.Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP,self.OnLeftUp) sizer.Add(self.ok, pos=(4,1),flag=wx.EXPAND) sizer.Add(self.cancel, pos=(4,2)) sizer.Add((4, 2), (6, 2)) sizer.AddGrowableCol(3) sizer.AddGrowableRow(3) self.SetSizer(sizer) self.Fit()
def __init__(self, *args, **kwargs): if "pngs" in kwargs: self.pngs = kwargs["pngs"] del kwargs["pngs"] if "codes" in kwargs: self.codes = kwargs["codes"] del kwargs["codes"] if "imflag" in kwargs: self.imflag = kwargs["imflag"] del kwargs["imflag"] else: self.imflag = 0 super(TwitterWindow, self).__init__(*args, **kwargs) self.previewsize = 400 self.SetSize((420, 550)) self.SetTitle( "Twitter Extension - Bringing Mass Spectrometry to the Masses") self.APP_KEY = "tQoLvTjNPbeqZGl95ea8rqfvO" self.APP_SECRET = "6knaUv912Db37ZWMMSODuxZvmhjNOcxpHRV6YAyVNSvSfQHVz5" if self.imflag == 0: choices = [ "None", "Data and Fit", "Zero-Charge Mass", "m/z Grid", "Individual Peaks", "Mass Grid", "Bar Chart" ] else: choices = [p[1] for p in self.pngs] choices = ["None"] + choices self.pnl = wx.Panel(self) self.vbox = wx.BoxSizer(wx.VERTICAL) self.sb = wx.StaticBox(self.pnl, label='Tweet a spectrum!') self.sbs = wx.StaticBoxSizer(self.sb, orient=wx.VERTICAL) self.hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.loginbutton = wx.Button(self.pnl, label="Twitter Log In") self.hbox1.Add(wx.StaticText(self.pnl, label=''), 0, wx.ALIGN_CENTER_VERTICAL) self.hbox1.Add(self.loginbutton, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=5) self.hbox1.Add(wx.StaticText(self.pnl, label=' User: '******'Tweet: '), 0, wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.inputbox2, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=5) self.countbox = wx.TextCtrl(self.pnl, value="7", style=wx.TE_READONLY | wx.TE_RIGHT, size=(30, 25)) self.hbox2.Add(wx.StaticText(self.pnl, label=' '), 0, wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(self.countbox, 0, wx.ALIGN_CENTER_VERTICAL) self.hbox2.Add(wx.StaticText(self.pnl, label=' Characters'), 0, wx.ALIGN_CENTER_VERTICAL) self.sbs.Add(self.hbox2, 0, wx.ALIGN_CENTER_HORIZONTAL) self.sbs.AddSpacer(10) self.hbox3 = wx.BoxSizer(wx.HORIZONTAL) self.hbox3.Add(wx.StaticText(self.pnl, label='Image: '), 0, wx.ALIGN_CENTER_VERTICAL) self.imagechoice = wx.Choice(self.pnl, -1, (115, 50), choices=choices) self.imagechoice.SetSelection(0) self.previewbutton = wx.Button(self.pnl, label="Preview") self.hbox3.Add(self.imagechoice, 0, wx.ALIGN_CENTER_VERTICAL) self.hbox3.Add(self.previewbutton, 0, wx.ALIGN_CENTER_VERTICAL) self.sbs.Add(self.hbox3, 0, wx.ALIGN_CENTER_HORIZONTAL) self.hbox4 = wx.BoxSizer(wx.HORIZONTAL) self.emptyimg = wx.EmptyImage(self.previewsize, self.previewsize) self.emptyimg.Replace(0, 0, 0, 255, 255, 255) self.imageCtrl = StaticBitmap(self.pnl, wx.ID_ANY, wx.Bitmap(self.emptyimg)) self.hbox4.Add(self.imageCtrl, 0) self.sbs.Add(self.hbox4, 1, wx.ALIGN_CENTER_HORIZONTAL) self.hbox5 = wx.BoxSizer(wx.HORIZONTAL) self.hbox5.Add(wx.StaticText(self.pnl, label=''), 0, wx.ALIGN_CENTER_VERTICAL) self.tweetbutton = wx.Button(self.pnl, label="Tweet it!") self.hbox5.Add(self.tweetbutton, 0, wx.ALIGN_CENTER_VERTICAL) self.sbs.Add(self.hbox5, 0, wx.ALIGN_CENTER_HORIZONTAL) self.pnl.SetSizer(self.sbs) self.pnl.SetBackgroundColour("WHITE") self.vbox.Add(self.pnl, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) ''' hboxend = wx.BoxSizer(wx.HORIZONTAL) okButton = wx.Button(self, label='Ok') closeButton = wx.Button(self, label='Cancel') hboxend.Add(okButton) hboxend.Add(closeButton, flag=wx.LEFT, border=5) okButton.Bind(wx.EVT_BUTTON, self.on_close) closeButton.Bind(wx.EVT_BUTTON, self.on_close_cancel) self.vbox.Add(hboxend, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=10) ''' self.SetSizer(self.vbox) self.loginbutton.Bind(wx.EVT_BUTTON, self.OnLaunchWeb) self.inputbox2.Bind(wx.EVT_TEXT, self.OnCharacterCount) self.previewbutton.Bind(wx.EVT_BUTTON, self.OnPreview) self.tweetbutton.Bind(wx.EVT_BUTTON, self.Tweet) self.Center() if self.codes is not None: self.LoadScreenName()